aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel P. Berrange <berrange@redhat.com>2009-11-13 11:43:09 +0000
committerDaniel P. Berrange <berrange@redhat.com>2009-11-13 15:10:55 +0000
commit5313dc372ba5871abb7ad0e8d4a99f3c9c7ad8be (patch)
tree81dedeffcef94168652b94de6f143d459fe1113c
parentDon't return fatal error in HAL driver init if HAL isn't running (diff)
downloadlibvirt-5313dc372ba5871abb7ad0e8d4a99f3c9c7ad8be.tar.gz
libvirt-5313dc372ba5871abb7ad0e8d4a99f3c9c7ad8be.tar.bz2
libvirt-5313dc372ba5871abb7ad0e8d4a99f3c9c7ad8be.zip
Fix incorrect reference counting logic in qemu monitor open
The QEMU monitor open method would not take a reference on the virDomainObjPtr until it had successfully opened the monitor. The cleanup code upon failure to open though would call qemuMonitorClose() which would in turn decrement the reference count. This caused the virDoaminObjPtr to be mistakenly freed and then the whole driver crashes * src/qemu/qemu_monitor.c: Fix reference counting in qemuMonitorOpen
-rw-r--r--src/qemu/qemu_monitor.c3
1 files changed, 1 insertions, 2 deletions
diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c
index 235773446..f0ef81b05 100644
--- a/src/qemu/qemu_monitor.c
+++ b/src/qemu/qemu_monitor.c
@@ -456,6 +456,7 @@ qemuMonitorOpen(virDomainObjPtr vm,
mon->vm = vm;
mon->eofCB = eofCB;
qemuMonitorLock(mon);
+ virDomainObjRef(vm);
switch (vm->monitor_chr->type) {
case VIR_DOMAIN_CHR_TYPE_UNIX:
@@ -499,8 +500,6 @@ qemuMonitorOpen(virDomainObjPtr vm,
goto cleanup;
}
- virDomainObjRef(vm);
-
VIR_DEBUG("New mon %p fd =%d watch=%d", mon, mon->fd, mon->watch);
qemuMonitorUnlock(mon);