[PATCH 15/23] qemuCheckpointGetXMLDescUpdateSize: Don't combine automatic freeing with manual

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

 



'blockNamedNodeData' is declared for automatic freeing but we also free
it manually and reuse which is a code pattern we don't normally allow.

Rewrite the code to have actually two separate hash tables.

Signed-off-by: Peter Krempa <pkrempa@xxxxxxxxxx>
---
 src/qemu/qemu_checkpoint.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/src/qemu/qemu_checkpoint.c b/src/qemu/qemu_checkpoint.c
index 4902585e5d..72f34ec86d 100644
--- a/src/qemu/qemu_checkpoint.c
+++ b/src/qemu/qemu_checkpoint.c
@@ -647,7 +647,8 @@ qemuCheckpointGetXMLDescUpdateSize(virDomainObj *vm,
 {
     qemuDomainObjPrivate *priv = vm->privateData;
     virQEMUDriver *driver = priv->driver;
-    g_autoptr(GHashTable) blockNamedNodeData = NULL;
+    g_autoptr(GHashTable) nodedataMerge = NULL;
+    g_autoptr(GHashTable) nodedataStats = NULL;
     g_autofree struct qemuCheckpointDiskMap *diskmap = NULL;
     g_autoptr(virJSONValue) recoveractions = NULL;
     g_autoptr(virJSONValue) mergeactions = virJSONValueNewArray();
@@ -663,7 +664,7 @@ qemuCheckpointGetXMLDescUpdateSize(virDomainObj *vm,
     if (virDomainObjCheckActive(vm) < 0)
         goto endjob;

-    if (!(blockNamedNodeData = qemuBlockGetNamedNodeData(vm, QEMU_ASYNC_JOB_NONE)))
+    if (!(nodedataMerge = qemuBlockGetNamedNodeData(vm, QEMU_ASYNC_JOB_NONE)))
         goto endjob;

     /* enumerate disks relevant for the checkpoint which are also present in the
@@ -683,7 +684,7 @@ qemuCheckpointGetXMLDescUpdateSize(virDomainObj *vm,
         if (!(domdisk = virDomainDiskByTarget(vm->def, chkdisk->name)))
             continue;

-        if (!qemuBlockBitmapChainIsValid(domdisk->src, chkdef->parent.name, blockNamedNodeData))
+        if (!qemuBlockBitmapChainIsValid(domdisk->src, chkdef->parent.name, nodedataMerge))
             continue;

         diskmap[ndisks].chkdisk = chkdisk;
@@ -702,7 +703,7 @@ qemuCheckpointGetXMLDescUpdateSize(virDomainObj *vm,
         g_autoptr(virJSONValue) actions = NULL;

         /* possibly delete leftovers from previous cases */
-        if (qemuBlockNamedNodeDataGetBitmapByName(blockNamedNodeData, domdisk->src,
+        if (qemuBlockNamedNodeDataGetBitmapByName(nodedataMerge, domdisk->src,
                                                   "libvirt-tmp-size-xml")) {
             if (!recoveractions)
                 recoveractions = virJSONValueNewArray();
@@ -715,7 +716,7 @@ qemuCheckpointGetXMLDescUpdateSize(virDomainObj *vm,

         if (qemuBlockGetBitmapMergeActions(domdisk->src, NULL, domdisk->src,
                                            chkdef->parent.name, "libvirt-tmp-size-xml",
-                                           NULL, &actions, blockNamedNodeData) < 0)
+                                           NULL, &actions, nodedataMerge) < 0)
             goto endjob;

         if (virJSONValueArrayConcat(mergeactions, actions) < 0)
@@ -739,8 +740,7 @@ qemuCheckpointGetXMLDescUpdateSize(virDomainObj *vm,
         goto endjob;

     /* now do a final refresh */
-    virHashFree(blockNamedNodeData);
-    if (!(blockNamedNodeData = qemuBlockGetNamedNodeData(vm, QEMU_ASYNC_JOB_NONE)))
+    if (!(nodedataStats = qemuBlockGetNamedNodeData(vm, QEMU_ASYNC_JOB_NONE)))
         goto endjob;

     qemuDomainObjEnterMonitor(driver, vm);
@@ -756,7 +756,7 @@ qemuCheckpointGetXMLDescUpdateSize(virDomainObj *vm,
         virDomainDiskDef *domdisk = diskmap[i].domdisk;
         qemuBlockNamedNodeDataBitmap *bitmap;

-        if ((bitmap = qemuBlockNamedNodeDataGetBitmapByName(blockNamedNodeData, domdisk->src,
+        if ((bitmap = qemuBlockNamedNodeDataGetBitmapByName(nodedataStats, domdisk->src,
                                                             "libvirt-tmp-size-xml"))) {
             chkdisk->size = bitmap->dirtybytes;
             chkdisk->sizeValid = true;
-- 
2.31.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