[libvirt PATCH 08/20] qemu_snapshot: allow using alternate domain definition when creating qcow2 files

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

 



To create new overlay files when external snapshot revert support is
introduced we will be using different domain definition than what is
currently used by the domain.

Signed-off-by: Pavel Hrdina <phrdina@xxxxxxxxxx>
---
 src/qemu/qemu_snapshot.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/src/qemu/qemu_snapshot.c b/src/qemu/qemu_snapshot.c
index 06ed20c815..9e4b978b1b 100644
--- a/src/qemu/qemu_snapshot.c
+++ b/src/qemu/qemu_snapshot.c
@@ -183,6 +183,7 @@ qemuSnapshotDomainDefUpdateDisk(virDomainDef *domdef,
 
 static int
 qemuSnapshotCreateQcow2Files(virDomainObj *vm,
+                             virDomainDef *def,
                              virDomainSnapshotDef *snapdef,
                              virBitmap *created,
                              bool reuse)
@@ -194,6 +195,9 @@ qemuSnapshotCreateQcow2Files(virDomainObj *vm,
     virDomainSnapshotDiskDef *snapdisk = NULL;
     virDomainDiskDef *defdisk = NULL;
 
+    if (!def)
+        def = vm->def;
+
     if (!(qemuImgPath = qemuFindQemuImgBinary(driver)))
         return -1;
 
@@ -203,7 +207,7 @@ qemuSnapshotCreateQcow2Files(virDomainObj *vm,
     for (i = 0; i < snapdef->ndisks && !reuse; i++) {
         g_autoptr(virCommand) cmd = NULL;
         snapdisk = &(snapdef->disks[i]);
-        defdisk = vm->def->disks[i];
+        defdisk = def->disks[i];
 
         if (snapdisk->snapshot != VIR_DOMAIN_SNAPSHOT_LOCATION_EXTERNAL)
             continue;
@@ -268,7 +272,7 @@ qemuSnapshotCreateInactiveExternal(virQEMUDriver *driver,
     virDomainSnapshotDef *snapdef = virDomainSnapshotObjGetDef(snap);
     g_autoptr(virBitmap) created = virBitmapNew(snapdef->ndisks);
 
-    if (qemuSnapshotCreateQcow2Files(vm, snapdef, created, reuse) < 0)
+    if (qemuSnapshotCreateQcow2Files(vm, NULL, snapdef, created, reuse) < 0)
         goto cleanup;
 
     /* update disk definitions */
-- 
2.39.2




[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