]> xenbits.xensource.com Git - libvirt.git/commitdiff
qemu: Split up qemuDomainRemoveInactive
authorWang Yechao <wang.yechao255@zte.com.cn>
Fri, 21 Sep 2018 04:35:08 +0000 (12:35 +0800)
committerJohn Ferlan <jferlan@redhat.com>
Sat, 22 Sep 2018 11:11:22 +0000 (07:11 -0400)
Introduce qemuDomainRemoveInactiveJobCommon to handle what will
be the common parts of the code with a new function that will
be used to call virDomainObjListRemoveLocked instead of the
unlocked variant.

Signed-off-by: Wang Yechao <wang.yechao255@zte.com.cn>
Reviewed-by: John Ferlan <jferlan@redhat.com>
src/qemu/qemu_domain.c

index 2fd8a2a268cd586539dbb1d7fdd95e623863098d..191113a728a0e49a0cff5fc447212f5d4137a774 100644 (file)
@@ -8344,23 +8344,13 @@ qemuDomainSnapshotDiscardAllMetadata(virQEMUDriverPtr driver,
 }
 
 
-/**
- * qemuDomainRemoveInactive:
- *
- * The caller must hold a lock to the vm.
- */
-void
-qemuDomainRemoveInactive(virQEMUDriverPtr driver,
-                         virDomainObjPtr vm)
+static void
+qemuDomainRemoveInactiveCommon(virQEMUDriverPtr driver,
+                               virDomainObjPtr vm)
 {
     char *snapDir;
     virQEMUDriverConfigPtr cfg;
 
-    if (vm->persistent) {
-        /* Short-circuit, we don't want to remove a persistent domain */
-        return;
-    }
-
     cfg = virQEMUDriverGetConfig(driver);
 
     /* Remove any snapshot metadata prior to removing the domain */
@@ -8379,12 +8369,30 @@ qemuDomainRemoveInactive(virQEMUDriverPtr driver,
     }
     qemuExtDevicesCleanupHost(driver, vm->def);
 
-    virDomainObjListRemove(driver->domains, vm);
-
     virObjectUnref(cfg);
 }
 
 
+/**
+ * qemuDomainRemoveInactive:
+ *
+ * The caller must hold a lock to the vm.
+ */
+void
+qemuDomainRemoveInactive(virQEMUDriverPtr driver,
+                         virDomainObjPtr vm)
+{
+    if (vm->persistent) {
+        /* Short-circuit, we don't want to remove a persistent domain */
+        return;
+    }
+
+    qemuDomainRemoveInactiveCommon(driver, vm);
+
+    virDomainObjListRemove(driver->domains, vm);
+}
+
+
 /**
  * qemuDomainRemoveInactiveJob:
  *