mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-24 14:45:24 +00:00
qemuCheckpointGetXMLDescUpdateSize: Don't combine automatic freeing with manual
'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@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com> Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
This commit is contained in:
parent
e552a0d502
commit
b326b4eeaa
@ -647,7 +647,8 @@ qemuCheckpointGetXMLDescUpdateSize(virDomainObj *vm,
|
|||||||
{
|
{
|
||||||
qemuDomainObjPrivate *priv = vm->privateData;
|
qemuDomainObjPrivate *priv = vm->privateData;
|
||||||
virQEMUDriver *driver = priv->driver;
|
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_autofree struct qemuCheckpointDiskMap *diskmap = NULL;
|
||||||
g_autoptr(virJSONValue) recoveractions = NULL;
|
g_autoptr(virJSONValue) recoveractions = NULL;
|
||||||
g_autoptr(virJSONValue) mergeactions = virJSONValueNewArray();
|
g_autoptr(virJSONValue) mergeactions = virJSONValueNewArray();
|
||||||
@ -663,7 +664,7 @@ qemuCheckpointGetXMLDescUpdateSize(virDomainObj *vm,
|
|||||||
if (virDomainObjCheckActive(vm) < 0)
|
if (virDomainObjCheckActive(vm) < 0)
|
||||||
goto endjob;
|
goto endjob;
|
||||||
|
|
||||||
if (!(blockNamedNodeData = qemuBlockGetNamedNodeData(vm, QEMU_ASYNC_JOB_NONE)))
|
if (!(nodedataMerge = qemuBlockGetNamedNodeData(vm, QEMU_ASYNC_JOB_NONE)))
|
||||||
goto endjob;
|
goto endjob;
|
||||||
|
|
||||||
/* enumerate disks relevant for the checkpoint which are also present in the
|
/* 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)))
|
if (!(domdisk = virDomainDiskByTarget(vm->def, chkdisk->name)))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (!qemuBlockBitmapChainIsValid(domdisk->src, chkdef->parent.name, blockNamedNodeData))
|
if (!qemuBlockBitmapChainIsValid(domdisk->src, chkdef->parent.name, nodedataMerge))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
diskmap[ndisks].chkdisk = chkdisk;
|
diskmap[ndisks].chkdisk = chkdisk;
|
||||||
@ -702,7 +703,7 @@ qemuCheckpointGetXMLDescUpdateSize(virDomainObj *vm,
|
|||||||
g_autoptr(virJSONValue) actions = NULL;
|
g_autoptr(virJSONValue) actions = NULL;
|
||||||
|
|
||||||
/* possibly delete leftovers from previous cases */
|
/* possibly delete leftovers from previous cases */
|
||||||
if (qemuBlockNamedNodeDataGetBitmapByName(blockNamedNodeData, domdisk->src,
|
if (qemuBlockNamedNodeDataGetBitmapByName(nodedataMerge, domdisk->src,
|
||||||
"libvirt-tmp-size-xml")) {
|
"libvirt-tmp-size-xml")) {
|
||||||
if (!recoveractions)
|
if (!recoveractions)
|
||||||
recoveractions = virJSONValueNewArray();
|
recoveractions = virJSONValueNewArray();
|
||||||
@ -715,7 +716,7 @@ qemuCheckpointGetXMLDescUpdateSize(virDomainObj *vm,
|
|||||||
|
|
||||||
if (qemuBlockGetBitmapMergeActions(domdisk->src, NULL, domdisk->src,
|
if (qemuBlockGetBitmapMergeActions(domdisk->src, NULL, domdisk->src,
|
||||||
chkdef->parent.name, "libvirt-tmp-size-xml",
|
chkdef->parent.name, "libvirt-tmp-size-xml",
|
||||||
NULL, &actions, blockNamedNodeData) < 0)
|
NULL, &actions, nodedataMerge) < 0)
|
||||||
goto endjob;
|
goto endjob;
|
||||||
|
|
||||||
if (virJSONValueArrayConcat(mergeactions, actions) < 0)
|
if (virJSONValueArrayConcat(mergeactions, actions) < 0)
|
||||||
@ -740,8 +741,7 @@ qemuCheckpointGetXMLDescUpdateSize(virDomainObj *vm,
|
|||||||
goto endjob;
|
goto endjob;
|
||||||
|
|
||||||
/* now do a final refresh */
|
/* now do a final refresh */
|
||||||
virHashFree(blockNamedNodeData);
|
if (!(nodedataStats = qemuBlockGetNamedNodeData(vm, QEMU_ASYNC_JOB_NONE)))
|
||||||
if (!(blockNamedNodeData = qemuBlockGetNamedNodeData(vm, QEMU_ASYNC_JOB_NONE)))
|
|
||||||
goto endjob;
|
goto endjob;
|
||||||
|
|
||||||
qemuDomainObjEnterMonitor(driver, vm);
|
qemuDomainObjEnterMonitor(driver, vm);
|
||||||
@ -758,7 +758,7 @@ qemuCheckpointGetXMLDescUpdateSize(virDomainObj *vm,
|
|||||||
virDomainDiskDef *domdisk = diskmap[i].domdisk;
|
virDomainDiskDef *domdisk = diskmap[i].domdisk;
|
||||||
qemuBlockNamedNodeDataBitmap *bitmap;
|
qemuBlockNamedNodeDataBitmap *bitmap;
|
||||||
|
|
||||||
if ((bitmap = qemuBlockNamedNodeDataGetBitmapByName(blockNamedNodeData, domdisk->src,
|
if ((bitmap = qemuBlockNamedNodeDataGetBitmapByName(nodedataStats, domdisk->src,
|
||||||
"libvirt-tmp-size-xml"))) {
|
"libvirt-tmp-size-xml"))) {
|
||||||
chkdisk->size = bitmap->dirtybytes;
|
chkdisk->size = bitmap->dirtybytes;
|
||||||
chkdisk->sizeValid = true;
|
chkdisk->sizeValid = true;
|
||||||
|
Loading…
Reference in New Issue
Block a user