From: John Ferlan Date: Tue, 27 Mar 2018 17:39:52 +0000 (-0400) Subject: test: Need to relock afer virDomainObjListRemove X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=7f8ac4bbc468121a80dcfb4e23e1f7c9f2aafc2c;p=libvirt.git test: Need to relock afer virDomainObjListRemove 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 Reviewed-by: Marc Hartmayer --- diff --git a/src/test/test_driver.c b/src/test/test_driver.c index 99c27cc0a0..35ee19bc10 100644 --- a/src/test/test_driver.c +++ b/src/test/test_driver.c @@ -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;