]> xenbits.xensource.com Git - libvirt.git/commitdiff
test: Need to relock afer virDomainObjListRemove
authorJohn Ferlan <jferlan@redhat.com>
Tue, 27 Mar 2018 17:39:52 +0000 (13:39 -0400)
committerJohn Ferlan <jferlan@redhat.com>
Wed, 4 Apr 2018 10:53:22 +0000 (06:53 -0400)
For all @dom's fetched from a testDomObjFromDomain because
virDomainObjListRemove will return an unlocked domain object
we should relock it prior to the cleanup label which will use
virDomainObjEndAPI which would Unlock and Unref the passed
object (and we should avoid unlocking an unlocked object).

Signed-off-by: John Ferlan <jferlan@redhat.com>
Reviewed-by: Marc Hartmayer <mhartmay@linux.vnet.ibm.com>
src/test/test_driver.c

index 99c27cc0a05c49ea95cdf8869f667b661acfa262..35ee19bc10ea7ae1915e5b766cac78da92b561c6 100644 (file)
@@ -1806,8 +1806,10 @@ static int testDomainDestroyFlags(virDomainPtr domain,
                                      VIR_DOMAIN_EVENT_STOPPED,
                                      VIR_DOMAIN_EVENT_STOPPED_DESTROYED);
 
-    if (!privdom->persistent)
+    if (!privdom->persistent) {
         virDomainObjListRemove(privconn->domains, privdom);
+        virObjectLock(privdom);
+    }
 
     ret = 0;
  cleanup:
@@ -1905,8 +1907,10 @@ static int testDomainShutdownFlags(virDomainPtr domain,
                                      VIR_DOMAIN_EVENT_STOPPED,
                                      VIR_DOMAIN_EVENT_STOPPED_SHUTDOWN);
 
-    if (!privdom->persistent)
+    if (!privdom->persistent) {
         virDomainObjListRemove(privconn->domains, privdom);
+        virObjectLock(privdom);
+    }
 
     ret = 0;
  cleanup:
@@ -1975,8 +1979,10 @@ static int testDomainReboot(virDomainPtr domain,
                                          VIR_DOMAIN_EVENT_STOPPED,
                                          VIR_DOMAIN_EVENT_STOPPED_SHUTDOWN);
 
-        if (!privdom->persistent)
+        if (!privdom->persistent) {
             virDomainObjListRemove(privconn->domains, privdom);
+            virObjectLock(privdom);
+        }
     }
 
     ret = 0;
@@ -2114,8 +2120,10 @@ testDomainSaveFlags(virDomainPtr domain, const char *path,
                                      VIR_DOMAIN_EVENT_STOPPED,
                                      VIR_DOMAIN_EVENT_STOPPED_SAVED);
 
-    if (!privdom->persistent)
+    if (!privdom->persistent) {
         virDomainObjListRemove(privconn->domains, privdom);
+        virObjectLock(privdom);
+    }
 
     ret = 0;
  cleanup:
@@ -2300,8 +2308,10 @@ static int testDomainCoreDumpWithFormat(virDomainPtr domain,
         event = virDomainEventLifecycleNewFromObj(privdom,
                                          VIR_DOMAIN_EVENT_STOPPED,
                                          VIR_DOMAIN_EVENT_STOPPED_CRASHED);
-        if (!privdom->persistent)
+        if (!privdom->persistent) {
             virDomainObjListRemove(privconn->domains, privdom);
+            virObjectLock(privdom);
+        }
     }
 
     ret = 0;
@@ -3080,10 +3090,12 @@ static int testDomainUndefineFlags(virDomainPtr domain,
                                      VIR_DOMAIN_EVENT_UNDEFINED_REMOVED);
     privdom->hasManagedSave = false;
 
-    if (virDomainObjIsActive(privdom))
+    if (virDomainObjIsActive(privdom)) {
         privdom->persistent = 0;
-    else
+    } else {
         virDomainObjListRemove(privconn->domains, privdom);
+        virObjectLock(privdom);
+    }
 
     ret = 0;