[PATCH 09/12] qemu: blockjob: Copy non-detected chain fully in qemuBlockJobRewriteConfigDiskSource

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

 



Rather than copying just the top level image, let's copy the full user
provided backing chain.

Signed-off-by: Peter Krempa <pkrempa@xxxxxxxxxx>
---
 src/qemu/qemu_blockjob.c | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)

diff --git a/src/qemu/qemu_blockjob.c b/src/qemu/qemu_blockjob.c
index 8303567aed..6ac60e86d7 100644
--- a/src/qemu/qemu_blockjob.c
+++ b/src/qemu/qemu_blockjob.c
@@ -521,6 +521,7 @@ qemuBlockJobRewriteConfigDiskSource(virDomainObjPtr vm,
 {
     virDomainDiskDefPtr persistDisk = NULL;
     VIR_AUTOUNREF(virStorageSourcePtr) copy = NULL;
+    virStorageSourcePtr n;

     if (!vm->newDef)
         return;
@@ -531,14 +532,24 @@ qemuBlockJobRewriteConfigDiskSource(virDomainObjPtr vm,
     if (!virStorageSourceIsSameLocation(disk->src, persistDisk->src))
         return;

-    if (!(copy = virStorageSourceCopy(newsrc, false)) ||
+    if (!(copy = virStorageSourceCopy(newsrc, true)) ||
         virStorageSourceInitChainElement(copy, persistDisk->src, true) < 0) {
         VIR_WARN("Unable to update persistent definition on vm %s after block job",
                  vm->def->name);
         return;
     }

-    qemuBlockJobCleanStorageSourceRuntime(copy);
+    for (n = copy; virStorageSourceIsBacking(n); n = n->backingStore) {
+        qemuBlockJobCleanStorageSourceRuntime(n);
+
+        /* discard any detected backing store */
+        if (virStorageSourceIsBacking(n->backingStore) &&
+            n->backingStore->detected) {
+            virObjectUnref(n->backingStore);
+            n->backingStore = NULL;
+            break;
+        }
+    }

     virObjectUnref(persistDisk->src);
     VIR_STEAL_PTR(persistDisk->src, copy);
-- 
2.21.0

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[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