[libvirt PATCH 1/6] qemu: block: add 'top' parameter to qemuDomainBlockPullCommon()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



qemuDomainBlockPullCommon() is one of the functions in block pull
implementation that have to support 'top' to make block pull as
a whole to support it.

Signed-off-by: Pavel Mores <pmores@xxxxxxxxxx>
---
 src/qemu/qemu_driver.c | 16 +++++++++++++---
 1 file changed, 13 insertions(+), 3 deletions(-)

diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index e9a62684f0..81cca360e0 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -17311,6 +17311,7 @@ static int
 qemuDomainBlockPullCommon(virDomainObjPtr vm,
                           const char *path,
                           const char *base,
+                          const char *top,
                           unsigned long bandwidth,
                           unsigned int flags)
 {
@@ -17322,6 +17323,9 @@ qemuDomainBlockPullCommon(virDomainObjPtr vm,
     virStorageSourcePtr baseSource = NULL;
     unsigned int baseIndex = 0;
     g_autofree char *basePath = NULL;
+    virStorageSourcePtr topSource = NULL;
+    unsigned int topIndex = 0;
+    g_autofree char *topPath = NULL;
     g_autofree char *backingPath = NULL;
     unsigned long long speed = bandwidth;
     qemuBlockJobDataPtr job = NULL;
@@ -17355,6 +17359,12 @@ qemuDomainBlockPullCommon(virDomainObjPtr vm,
                                                   base, baseIndex, NULL))))
         goto endjob;
 
+    if (top &&
+        (virStorageFileParseChainIndex(disk->dst, top, &topIndex) < 0 ||
+         !(topSource = virStorageFileChainLookup(disk->src, disk->src,
+                                                  top, topIndex, NULL))))
+        goto endjob;
+
     if (baseSource) {
         if (flags & VIR_DOMAIN_BLOCK_REBASE_RELATIVE) {
             if (!virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_CHANGE_BACKING_FILE)) {
@@ -17388,7 +17398,7 @@ qemuDomainBlockPullCommon(virDomainObjPtr vm,
         speed <<= 20;
     }
 
-    if (!(job = qemuBlockJobDiskNewPull(vm, disk, baseSource, flags)))
+    if (!(job = qemuBlockJobDiskNewPull(vm, disk, baseSource, /*topSource, */flags)))
         goto endjob;
 
     if (blockdev) {
@@ -18160,7 +18170,7 @@ qemuDomainBlockRebase(virDomainPtr dom, const char *path, const char *base,
     /* For normal rebase (enhanced blockpull), the common code handles
      * everything, including vm cleanup. */
     if (!(flags & VIR_DOMAIN_BLOCK_REBASE_COPY))
-        return qemuDomainBlockPullCommon(vm, path, base, bandwidth, flags);
+        return qemuDomainBlockPullCommon(vm, path, base, NULL, bandwidth, flags);
 
     /* If we got here, we are doing a block copy rebase. */
     if (!(dest = virStorageSourceNew()))
@@ -18311,7 +18321,7 @@ qemuDomainBlockPull(virDomainPtr dom, const char *path, unsigned long bandwidth,
     }
 
     /* qemuDomainBlockPullCommon consumes the reference on @vm */
-    return qemuDomainBlockPullCommon(vm, path, NULL, bandwidth, flags);
+    return qemuDomainBlockPullCommon(vm, path, NULL, NULL, bandwidth, flags);
 }
 
 
-- 
2.24.1





[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux