[libvirt] [PATCH v2 3/3] lxc: Fix lxcDomainDestroyFlags endjob processing

John Ferlan jferlan at redhat.com
Tue May 24 22:53:18 UTC 2016

Commit id '15ccb0dbf' added job functions for the lxc driver; however,
for shutdown and nonpersistent path, the vm was removed from the domain
object list and the vm pointer cleared before the endjob.

Adjust the code to perform the endjob first and then perform the
ObjListRemove as long as the vm wasn't NULL. This follows more closely
models from qemu and libxl

Found by Coverity (FORWARD_NULL)

Signed-off-by: John Ferlan <jferlan at redhat.com>
 src/lxc/lxc_driver.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c
index d690886..9e03f1f 100644
--- a/src/lxc/lxc_driver.c
+++ b/src/lxc/lxc_driver.c
@@ -1541,13 +1541,11 @@ lxcDomainDestroyFlags(virDomainPtr dom,
     priv->doneStopEvent = true;
     virDomainAuditStop(vm, "destroyed");
-    if (!vm->persistent) {
-        virDomainObjListRemove(driver->domains, vm);
-        vm = NULL;
-    }
     virLXCDomainObjEndJob(driver, vm);
+    if (!vm->persistent)
+        virDomainObjListRemove(driver->domains, vm);

More information about the libvir-list mailing list