Richard W.M. Jones
2022-Jan-19 18:57 UTC
[Libguestfs] [PATCH v2v 0/3] Fix test-v2v-trim.sh test
Final 3 patches needed to fix "make check-slow", specifically the test-v2v-trim.sh test. This revealed a nasty bug in our sparsification if the input disk format is qcow2. Rich.
Richard W.M. Jones
2022-Jan-19 18:57 UTC
[Libguestfs] [PATCH v2v 1/3] tests/test-v2v-trim.sh: Use -of qcow2 to preserve output format
Old virt-v2v used the same output format as input format when doing disk to disk copies. Modular virt-v2v doesn't do this, it requires using -of to set the output format to the same as the input format if that is desired. --- tests/test-v2v-trim.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test-v2v-trim.sh b/tests/test-v2v-trim.sh index 8eab4792b2..ed6c031df3 100755 --- a/tests/test-v2v-trim.sh +++ b/tests/test-v2v-trim.sh @@ -66,7 +66,7 @@ fi virt-v2v --debug-gc \ -i disk $d/fedora.qcow2 \ - -o local -os $d + -o local -of qcow2 -os $d # Test the libvirt XML metadata and a disk was created. test -f $d/fedora.xml -- 2.32.0
Richard W.M. Jones
2022-Jan-19 18:57 UTC
[Libguestfs] [PATCH v2v 2/3] lib/qemuNBD.ml: Use qemu-nbd --shared=0 flag to allow multiple connections
qemu-nbd --shared (-e) flag controls how many clients can connect concurrently. 0 means unlimited. We want to allow the sockets to be queried by other processes while virt-v2v is running and it should be safe to do this. The default configuration of qemu-nbd doesn't allow this so add --shared=0. Note this does not (in current qemu) enable multi-conn because we aren't using the -r (read-only) flag. --- lib/qemuNBD.ml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/qemuNBD.ml b/lib/qemuNBD.ml index 12d083aeb7..89c93d7072 100644 --- a/lib/qemuNBD.ml +++ b/lib/qemuNBD.ml @@ -90,7 +90,11 @@ let run_unix ?socket { disk; snapshot; format } (* Construct the qemu-nbd command line. *) let args = ref [] in List.push_back_list args - ["qemu-nbd"; "-t"; "--pid-file"; pidfile; "--socket"; socket]; + ["qemu-nbd"; + "-t"; + "--shared=0"; + "--pid-file"; pidfile; + "--socket"; socket]; (* -s adds a protective overlay. *) if snapshot then List.push_back args "-s"; -- 2.32.0
Richard W.M. Jones
2022-Jan-19 18:57 UTC
[Libguestfs] [PATCH v2v 3/3] lib/qemuNBD.ml: Use qemu-nbd --discard=unmap
The default for qemu-nbd is to ignore discard requests. This meant that for input files in qcow2 format the "Mapping ..." (ie. fstrim) step did nothing, all the work was ignored and we copied deleted data over to the destination. This was detected by the test-v2v-trim.sh test. Fixes: commit 255722cbf39afc0b012e2ac00d16fa6ba2f8c21f --- lib/qemuNBD.ml | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/qemuNBD.ml b/lib/qemuNBD.ml index 89c93d7072..54139ce0b4 100644 --- a/lib/qemuNBD.ml +++ b/lib/qemuNBD.ml @@ -93,6 +93,7 @@ let run_unix ?socket { disk; snapshot; format } ["qemu-nbd"; "-t"; "--shared=0"; + "--discard=unmap"; "--pid-file"; pidfile; "--socket"; socket]; -- 2.32.0