[libvirt] [PATCH v4 2/4] qemu: Create a qemuDomainRemoveInactiveLocked

Wang Yechao wang.yechao255 at zte.com.cn
Fri Sep 21 04:35:09 UTC 2018


Create a qemuDomainRemoveInactiveLocked which is a copy of
qemuDomainRemoveInactive except that instead of calling
virDomainObjListRemove it calls virDomainObjListRemoveLocked.

Signed-off-by: Wang Yechao <wang.yechao255 at zte.com.cn>
---
 src/qemu/qemu_domain.c | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)

diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index 191113a..22436d2 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -8394,6 +8394,28 @@ qemuDomainRemoveInactive(virQEMUDriverPtr driver,
 
 
 /**
+ * qemuDomainRemoveInactiveLocked:
+ *
+ * The caller must hold a lock to the vm and must hold the
+ * lock on driver->domains in order to call the remove obj
+ * from locked list method.
+ */
+static void
+qemuDomainRemoveInactiveLocked(virQEMUDriverPtr driver,
+                               virDomainObjPtr vm)
+{
+    if (vm->persistent) {
+        /* Short-circuit, we don't want to remove a persistent domain */
+        return;
+    }
+
+    qemuDomainRemoveInactiveCommon(driver, vm);
+
+    virDomainObjListRemoveLocked(driver->domains, vm);
+}
+
+
+/**
  * qemuDomainRemoveInactiveJob:
  *
  * Just like qemuDomainRemoveInactive but it tries to grab a
-- 
1.8.3.1




More information about the libvir-list mailing list