[PATCH 04/25] qemu: driver: Use virDomainDiskDefParseSource in qemuDomainBlockCopy

Peter Krempa pkrempa at redhat.com
Fri Apr 16 15:34:22 UTC 2021


qemuDomainBlockCopy needs just the source portion of the disk but uses
the disk parser for it. Since we have a specific function now, refactor
the code to avoid having to deal with the unused virDomainDiskDef.

Signed-off-by: Peter Krempa <pkrempa at redhat.com>
---
 src/qemu/qemu_driver.c | 9 ++-------
 1 file changed, 2 insertions(+), 7 deletions(-)

diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 88ee9e5d5e..d908e95ba7 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -15273,7 +15273,6 @@ qemuDomainBlockCopy(virDomainPtr dom, const char *disk, const char *destxml,
     unsigned long long bandwidth = 0;
     unsigned int granularity = 0;
     unsigned long long buf_size = 0;
-    virDomainDiskDef *diskdef = NULL;
     virStorageSource *dest = NULL;
     size_t i;

@@ -15326,18 +15325,14 @@ qemuDomainBlockCopy(virDomainPtr dom, const char *disk, const char *destxml,
         }
     }

-    if (!(diskdef = virDomainDiskDefParse(destxml, driver->xmlopt,
-                                          VIR_DOMAIN_DEF_PARSE_INACTIVE |
-                                          VIR_DOMAIN_DEF_PARSE_DISK_SOURCE)))
+    if (!(dest = virDomainDiskDefParseSource(destxml, driver->xmlopt,
+                                             VIR_DOMAIN_DEF_PARSE_INACTIVE)))
         goto cleanup;

-    dest = g_steal_pointer(&diskdef->src);
-
     ret = qemuDomainBlockCopyCommon(vm, dom->conn, disk, dest, bandwidth,
                                     granularity, buf_size, flags, false);

  cleanup:
-    virDomainDiskDefFree(diskdef);
     virDomainObjEndAPI(&vm);
     return ret;
 }
-- 
2.30.2




More information about the libvir-list mailing list