]> xenbits.xensource.com Git - libvirt.git/commitdiff
qemu: Introduce qemuDomainRemoveInactiveJobLocked
authorWang Yechao <wang.yechao255@zte.com.cn>
Fri, 21 Sep 2018 04:35:09 +0000 (12:35 +0800)
committerJohn Ferlan <jferlan@redhat.com>
Sat, 22 Sep 2018 11:11:22 +0000 (07:11 -0400)
Create a qemuDomainRemoveInactiveJobLocked which copies
qemuDomainRemoveInactiveJob except of course calling
another new helper qemuDomainRemoveInactiveLocked.

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

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

index 191113a728a0e49a0cff5fc447212f5d4137a774..b20d43059e59c0c185261988af8235d8365f5727 100644 (file)
@@ -8393,6 +8393,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:
  *
@@ -8416,6 +8438,27 @@ qemuDomainRemoveInactiveJob(virQEMUDriverPtr driver,
 }
 
 
+/**
+ * qemuDomainRemoveInactiveJobLocked:
+ *
+ * Similar to qemuDomainRemoveInactiveJob, except that the caller must
+ * also hold the lock @driver->domains
+ */
+void
+qemuDomainRemoveInactiveJobLocked(virQEMUDriverPtr driver,
+                                  virDomainObjPtr vm)
+{
+    bool haveJob;
+
+    haveJob = qemuDomainObjBeginJob(driver, vm, QEMU_JOB_MODIFY) >= 0;
+
+    qemuDomainRemoveInactiveLocked(driver, vm);
+
+    if (haveJob)
+        qemuDomainObjEndJob(driver, vm);
+}
+
+
 void
 qemuDomainSetFakeReboot(virQEMUDriverPtr driver,
                         virDomainObjPtr vm,
index 914c9a6a8d14d18bec1e982377ba1dadc1179124..ecbe2e85336dfddd91ecde936d422e4bdaf57afc 100644 (file)
@@ -704,6 +704,9 @@ void qemuDomainRemoveInactive(virQEMUDriverPtr driver,
 void qemuDomainRemoveInactiveJob(virQEMUDriverPtr driver,
                                  virDomainObjPtr vm);
 
+void qemuDomainRemoveInactiveJobLocked(virQEMUDriverPtr driver,
+                                       virDomainObjPtr vm);
+
 void qemuDomainSetFakeReboot(virQEMUDriverPtr driver,
                              virDomainObjPtr vm,
                              bool value);