]> xenbits.xensource.com Git - libvirt.git/commitdiff
uml: Fix umlInotifyEvent dom object handling
authorJohn Ferlan <jferlan@redhat.com>
Tue, 27 Mar 2018 18:26:02 +0000 (14:26 -0400)
committerJohn Ferlan <jferlan@redhat.com>
Thu, 19 Apr 2018 18:44:35 +0000 (14:44 -0400)
The virDomainObjListFindByName will return a locked and reffed
object. If we call virDomainObjListRemove that will unlock the
object upon return, thus we need to relock the object before
making the call to virDomainObjEndAPI.

Signed-off-by: John Ferlan <jferlan@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
src/uml/uml_driver.c

index 23d09891f4771d56ce2671fa4bfd8bfc1ca4d84f..e9283242bafd502e553536d334f6164b51ec959e 100644 (file)
@@ -346,8 +346,10 @@ umlInotifyEvent(int watch,
             event = virDomainEventLifecycleNewFromObj(dom,
                                              VIR_DOMAIN_EVENT_STOPPED,
                                              VIR_DOMAIN_EVENT_STOPPED_SHUTDOWN);
-            if (!dom->persistent)
+            if (!dom->persistent) {
                 virDomainObjListRemove(driver->domains, dom);
+                virObjectLock(dom);
+            }
         } else if (e.mask & (IN_CREATE | IN_MODIFY)) {
             VIR_DEBUG("Got inotify domain startup '%s'", name);
             if (virDomainObjIsActive(dom)) {
@@ -377,8 +379,10 @@ umlInotifyEvent(int watch,
                 event = virDomainEventLifecycleNewFromObj(dom,
                                                  VIR_DOMAIN_EVENT_STOPPED,
                                                  VIR_DOMAIN_EVENT_STOPPED_FAILED);
-                if (!dom->persistent)
+                if (!dom->persistent) {
                     virDomainObjListRemove(driver->domains, dom);
+                    virObjectLock(dom);
+                }
             } else if (umlIdentifyChrPTY(driver, dom) < 0) {
                 VIR_WARN("Could not identify character devices for new domain");
                 umlShutdownVMDaemon(driver, dom,
@@ -387,8 +391,10 @@ umlInotifyEvent(int watch,
                 event = virDomainEventLifecycleNewFromObj(dom,
                                                  VIR_DOMAIN_EVENT_STOPPED,
                                                  VIR_DOMAIN_EVENT_STOPPED_FAILED);
-                if (!dom->persistent)
+                if (!dom->persistent) {
                     virDomainObjListRemove(driver->domains, dom);
+                    virObjectLock(dom);
+                }
             }
         }
         virDomainObjEndAPI(&dom);