qemu: hotplug: Use automatic freeing for virJSONValue

There are a few uses which still explicitly free JSON objects, fix them.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
Peter Krempa 2021-12-01 09:04:56 +01:00
parent 31e08a365d
commit 85d9a0e58a
1 changed files with 4 additions and 9 deletions

View File

@ -411,7 +411,7 @@ qemuHotplugAttachManagedPR(virQEMUDriver *driver,
qemuDomainAsyncJob asyncJob) qemuDomainAsyncJob asyncJob)
{ {
qemuDomainObjPrivate *priv = vm->privateData; qemuDomainObjPrivate *priv = vm->privateData;
virJSONValue *props = NULL; g_autoptr(virJSONValue) props = NULL;
bool daemonStarted = false; bool daemonStarted = false;
int ret = -1; int ret = -1;
int rc; int rc;
@ -442,7 +442,6 @@ qemuHotplugAttachManagedPR(virQEMUDriver *driver,
cleanup: cleanup:
if (ret < 0 && daemonStarted) if (ret < 0 && daemonStarted)
qemuProcessKillManagedPRDaemon(vm); qemuProcessKillManagedPRDaemon(vm);
virJSONValueFree(props);
return ret; return ret;
} }
@ -2286,7 +2285,7 @@ qemuDomainAttachRNGDevice(virQEMUDriver *driver,
bool teardowncgroup = false; bool teardowncgroup = false;
bool teardowndevice = false; bool teardowndevice = false;
bool chardevAdded = false; bool chardevAdded = false;
virJSONValue *props = NULL; g_autoptr(virJSONValue) props = NULL;
int ret = -1; int ret = -1;
qemuAssignDeviceRNGAlias(vm->def, rng); qemuAssignDeviceRNGAlias(vm->def, rng);
@ -2349,7 +2348,6 @@ qemuDomainAttachRNGDevice(virQEMUDriver *driver,
audit: audit:
virDomainAuditRNG(vm, NULL, rng, "attach", ret == 0); virDomainAuditRNG(vm, NULL, rng, "attach", ret == 0);
cleanup: cleanup:
virJSONValueFree(props);
if (ret < 0) { if (ret < 0) {
if (releaseaddr) if (releaseaddr)
qemuDomainReleaseDeviceAddress(vm, &rng->info); qemuDomainReleaseDeviceAddress(vm, &rng->info);
@ -2403,7 +2401,7 @@ qemuDomainAttachMemory(virQEMUDriver *driver,
bool teardownlabel = false; bool teardownlabel = false;
bool teardowncgroup = false; bool teardowncgroup = false;
bool teardowndevice = false; bool teardowndevice = false;
virJSONValue *props = NULL; g_autoptr(virJSONValue) props = NULL;
virObjectEvent *event; virObjectEvent *event;
int id; int id;
int ret = -1; int ret = -1;
@ -2492,7 +2490,6 @@ qemuDomainAttachMemory(virQEMUDriver *driver,
qemuDomainReleaseMemoryDeviceSlot(vm, mem); qemuDomainReleaseMemoryDeviceSlot(vm, mem);
} }
virJSONValueFree(props);
virDomainMemoryDefFree(mem); virDomainMemoryDefFree(mem);
return ret; return ret;
@ -2970,7 +2967,7 @@ qemuDomainAttachShmemDevice(virQEMUDriver *driver,
bool release_backing = false; bool release_backing = false;
bool release_address = true; bool release_address = true;
virErrorPtr orig_err = NULL; virErrorPtr orig_err = NULL;
virJSONValue *props = NULL; g_autoptr(virJSONValue) props = NULL;
qemuDomainObjPrivate *priv = vm->privateData; qemuDomainObjPrivate *priv = vm->privateData;
virDomainDeviceDef dev = { VIR_DOMAIN_DEVICE_SHMEM, { .shmem = shmem } }; virDomainDeviceDef dev = { VIR_DOMAIN_DEVICE_SHMEM, { .shmem = shmem } };
@ -3046,8 +3043,6 @@ qemuDomainAttachShmemDevice(virQEMUDriver *driver,
if (release_address) if (release_address)
qemuDomainReleaseDeviceAddress(vm, &shmem->info); qemuDomainReleaseDeviceAddress(vm, &shmem->info);
virJSONValueFree(props);
return ret; return ret;
exit_monitor: exit_monitor: