A recent adjustment to qemuDomainAttachRNGDevice to properly cleanup
the props object after a qemuMonitorAddObject also would affect this
code. Alter the cleanup to be similar to RNG changes.
Signed-off-by: John Ferlan <jferlan(a)redhat.com>
---
src/qemu/qemu_hotplug.c | 38 +++++++++++++++++++++++---------------
1 file changed, 23 insertions(+), 15 deletions(-)
diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
index c5a1a91..7cc52e7 100644
--- a/src/qemu/qemu_hotplug.c
+++ b/src/qemu/qemu_hotplug.c
@@ -1713,16 +1713,19 @@ qemuDomainAttachMemory(virQEMUDriverPtr driver,
virDomainMemoryDefPtr mem)
{
qemuDomainObjPrivatePtr priv = vm->privateData;
+ virErrorPtr orig_err;
virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver);
unsigned long long oldmem = virDomainDefGetMemoryTotal(vm->def);
unsigned long long newmem = oldmem + mem->size;
char *devstr = NULL;
char *objalias = NULL;
const char *backendType;
+ bool cleanupObjAlias = false;
virJSONValuePtr props = NULL;
virObjectEventPtr event;
int id;
int ret = -1;
+ int rv;
qemuDomainMemoryDeviceAlignSize(vm->def, mem);
@@ -1755,16 +1758,14 @@ qemuDomainAttachMemory(virQEMUDriverPtr driver,
}
qemuDomainObjEnterMonitor(driver, vm);
- if (qemuMonitorAddObject(priv->mon, backendType, objalias, props) < 0)
- goto exit_monitor;
+ rv = qemuMonitorAddObject(priv->mon, backendType, objalias, props);
+ props = NULL; /* qemuMonitorAddObject consumes */
+ if (rv < 0)
+ goto monitor_error;
+ cleanupObjAlias = true;
- if (qemuMonitorAddDevice(priv->mon, devstr) < 0) {
- virErrorPtr err = virSaveLastError();
- ignore_value(qemuMonitorDelObject(priv->mon, objalias));
- virSetError(err);
- virFreeError(err);
- goto exit_monitor;
- }
+ if (qemuMonitorAddDevice(priv->mon, devstr) < 0)
+ goto monitor_error;
if (qemuDomainObjExitMonitor(driver, vm) < 0) {
/* we shouldn't touch mem now, as the def might be freed */
@@ -1796,11 +1797,18 @@ qemuDomainAttachMemory(virQEMUDriverPtr driver,
virDomainMemoryDefFree(mem);
return ret;
- exit_monitor:
- if (qemuDomainObjExitMonitor(driver, vm) < 0) {
+ monitor_error:
+ orig_err = virSaveLastError();
+ if (cleanupObjAlias)
+ ignore_value(qemuMonitorDelObject(priv->mon, objalias));
+ if (qemuDomainObjExitMonitor(driver, vm) < 0)
mem = NULL;
- goto audit;
+ if (orig_err) {
+ virSetError(orig_err);
+ virFreeError(orig_err);
}
+ if (!mem)
+ goto audit;
removedef:
if ((id = virDomainMemoryFindByDef(vm->def, mem)) >= 0)
@@ -1809,10 +1817,10 @@ qemuDomainAttachMemory(virQEMUDriverPtr driver,
mem = NULL;
/* reset the mlock limit */
- virErrorPtr err = virSaveLastError();
+ orig_err = virSaveLastError();
ignore_value(qemuDomainAdjustMaxMemLock(vm));
- virSetError(err);
- virFreeError(err);
+ virSetError(orig_err);
+ virFreeError(orig_err);
goto audit;
}
--
2.5.5