]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
qemu: Avoid sending STOPPED event twice
authorJiri Denemark <jdenemar@redhat.com>
Tue, 18 Jan 2011 11:07:13 +0000 (12:07 +0100)
committerJiri Denemark <jdenemar@redhat.com>
Wed, 19 Jan 2011 14:01:52 +0000 (15:01 +0100)
In some circumstances, libvirtd would issue two STOPPED events after it
stopped a domain. This was because an EOF event can arrive after a qemu
process is killed but before qemuMonitorClose() is called.

qemuHandleMonitorEOF() should ignore EOF when the domain is not running.

I wasn't able to reproduce this bug directly, only after adding an
artificial sleep() into qemudShutdownVMDaemon().

src/qemu/qemu_driver.c

index 22dc272aac61e94b8072df59f34d516d4fbbbe6a..cff7a4311199ae96162bc53792d990d8f7c0f6c2 100644 (file)
@@ -356,6 +356,12 @@ qemuHandleMonitorEOF(qemuMonitorPtr mon ATTRIBUTE_UNUSED,
 
     virDomainObjLock(vm);
 
+    if (!virDomainObjIsActive(vm)) {
+        VIR_DEBUG("Domain %p is not active, ignoring EOF", vm);
+        virDomainObjUnlock(vm);
+        return;
+    }
+
     priv = vm->privateData;
     if (!hasError && priv->monJSON && !priv->gotShutdown) {
         VIR_DEBUG("Monitor connection to '%s' closed without SHUTDOWN event; "