]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
qemu: blockjob: Clear out any irrelevant data in copied source
authorPeter Krempa <pkrempa@redhat.com>
Wed, 24 Jul 2019 15:22:05 +0000 (17:22 +0200)
committerPeter Krempa <pkrempa@redhat.com>
Thu, 25 Jul 2019 11:21:33 +0000 (13:21 +0200)
Since we copy everything from the original storage source including some
runtime data which are not relevant for the config we should clear them.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
ACKed-by: Eric Blake <eblake@redhat.com>
src/qemu/qemu_blockjob.c

index d0805dbcc5b315f8650bba81c051fad291453f1f..487ef24d5c380ba633750a09762d1b0c906b537c 100644 (file)
@@ -433,6 +433,25 @@ qemuBlockJobEmitEvents(virQEMUDriverPtr driver,
     virObjectEventStateQueue(driver->domainEventState, event2);
 }
 
+/**
+ * qemuBlockJobCleanStorageSourceRuntime:
+ * @src: storage source to clean from runtime data
+ *
+ * Remove all runtime related data from the storage source.
+ */
+static void
+qemuBlockJobCleanStorageSourceRuntime(virStorageSourcePtr src)
+{
+    src->id = 0;
+    src->detected = false;
+    VIR_FREE(src->relPath);
+    VIR_FREE(src->backingStoreRaw);
+    VIR_FREE(src->nodestorage);
+    VIR_FREE(src->nodeformat);
+    VIR_FREE(src->tlsAlias);
+    VIR_FREE(src->tlsCertdir);
+}
+
 
 /**
  * qemuBlockJobRewriteConfigDiskSource:
@@ -467,6 +486,8 @@ qemuBlockJobRewriteConfigDiskSource(virDomainObjPtr vm,
         return;
     }
 
+    qemuBlockJobCleanStorageSourceRuntime(copy);
+
     virObjectUnref(persistDisk->src);
     VIR_STEAL_PTR(persistDisk->src, copy);
 }