[libvirt] [PATCH RFC 21/22] qemu: Add support for networked disks for block commit

Peter Krempa pkrempa at redhat.com
Tue May 6 13:37:10 UTC 2014


Now that we are able to select images from the backing chain via indexed
access we should also convert possible network sources to
qemu-compatible strings before passing them to qemu.
---
 src/qemu/qemu_driver.c | 23 +++++++++++++++++++++--
 1 file changed, 21 insertions(+), 2 deletions(-)

diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index e9cf5d5..1188300 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -15355,6 +15355,8 @@ qemuDomainBlockCommit(virDomainPtr dom,
     unsigned int baseIndex = 0;
     const char *top_parent = NULL;
     bool clean_access = false;
+    char *topPath = NULL;
+    char *basePath = NULL;

     virCheckFlags(VIR_DOMAIN_BLOCK_COMMIT_SHALLOW, -1);

@@ -15441,6 +15443,22 @@ qemuDomainBlockCommit(virDomainPtr dom,
                                                VIR_DISK_CHAIN_READ_WRITE) < 0))
         goto endjob;

+    if (top && !topIndex) {
+        if (VIR_STRDUP(topPath, top) < 0)
+            goto endjob;
+    } else {
+        if (qemuGetDriveSourceString(topSource, NULL, &topPath) < 0)
+            goto endjob;
+    }
+
+    if (base && !baseIndex) {
+        if (VIR_STRDUP(basePath, base) < 0)
+            goto endjob;
+    } else {
+        if (qemuGetDriveSourceString(baseSource, NULL, &basePath) < 0)
+            goto endjob;
+    }
+
     /* Start the commit operation.  Pass the user's original spelling,
      * if any, through to qemu, since qemu may behave differently
      * depending on whether the input was specified as relative or
@@ -15448,8 +15466,7 @@ qemuDomainBlockCommit(virDomainPtr dom,
      * thing if the user specified a relative name). */
     qemuDomainObjEnterMonitor(driver, vm);
     ret = qemuMonitorBlockCommit(priv->mon, device,
-                                 top && !topIndex ? top : topSource->path,
-                                 base && !baseIndex ? base : baseSource->path,
+                                 topPath, basePath,
                                  bandwidth);
     qemuDomainObjExitMonitor(driver, vm);

@@ -15467,6 +15484,8 @@ qemuDomainBlockCommit(virDomainPtr dom,
         vm = NULL;

  cleanup:
+    VIR_FREE(topPath);
+    VIR_FREE(basePath);
     VIR_FREE(device);
     if (vm)
         virObjectUnlock(vm);
-- 
1.9.2




More information about the libvir-list mailing list