[libvirt] [PATCH 6/9] qemu: blockjob: Esure that persistent definition source does not copy irrelevant data

Peter Krempa pkrempa at redhat.com
Wed Jul 24 21:07:33 UTC 2019


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 at redhat.com>
---
 src/qemu/qemu_blockjob.c | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

diff --git a/src/qemu/qemu_blockjob.c b/src/qemu/qemu_blockjob.c
index f9e79db131..f5574b7e03 100644
--- a/src/qemu/qemu_blockjob.c
+++ b/src/qemu/qemu_blockjob.c
@@ -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);
 }
-- 
2.21.0




More information about the libvir-list mailing list