[PATCH 10/17] CH: use virDomainObjBeginJob()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This patch removes virCHDomainObjBeginJob() and replaces it with
call to the generalized virDomainObjBeginJob().

Signed-off-by: Kristina Hanicova <khanicov@xxxxxxxxxx>
---
 src/ch/ch_domain.c | 51 +---------------------------------------------
 src/ch/ch_domain.h |  4 ----
 src/ch/ch_driver.c | 20 +++++++++---------
 3 files changed, 11 insertions(+), 64 deletions(-)

diff --git a/src/ch/ch_domain.c b/src/ch/ch_domain.c
index 9ddf9a8584..c592c6ffbb 100644
--- a/src/ch/ch_domain.c
+++ b/src/ch/ch_domain.c
@@ -32,60 +32,11 @@
 
 VIR_LOG_INIT("ch.ch_domain");
 
-/*
- * obj must be locked before calling, virCHDriver must NOT be locked
- *
- * This must be called by anything that will change the VM state
- * in any way
- *
- * Upon successful return, the object will have its ref count increased.
- * Successful calls must be followed by EndJob eventually.
- */
-int
-virCHDomainObjBeginJob(virDomainObj *obj, virDomainJob job)
-{
-    unsigned long long now;
-    unsigned long long then;
-
-    if (virTimeMillisNow(&now) < 0)
-        return -1;
-    then = now + CH_JOB_WAIT_TIME;
-
-    while (obj->job->active) {
-        VIR_DEBUG("Wait normal job condition for starting job: %s",
-                  virDomainJobTypeToString(job));
-        if (virCondWaitUntil(&obj->job->cond, &obj->parent.lock, then) < 0) {
-            VIR_WARN("Cannot start job (%s) for domain %s;"
-                     " current job is (%s) owned by (%llu)",
-                     virDomainJobTypeToString(job),
-                     obj->def->name,
-                     virDomainJobTypeToString(obj->job->active),
-                     obj->job->owner);
-
-            if (errno == ETIMEDOUT)
-                virReportError(VIR_ERR_OPERATION_TIMEOUT,
-                               "%s", _("cannot acquire state change lock"));
-            else
-                virReportSystemError(errno,
-                                     "%s", _("cannot acquire job mutex"));
-            return -1;
-        }
-    }
-
-    virDomainObjResetJob(obj->job);
-
-    VIR_DEBUG("Starting job: %s", virDomainJobTypeToString(job));
-    obj->job->active = job;
-    obj->job->owner = virThreadSelfID();
-
-    return 0;
-}
-
 /*
  * obj must be locked and have a reference before calling
  *
  * To be called after completing the work associated with the
- * earlier virCHDomainBeginJob() call
+ * earlier virDomainObjBeginJob() call
  */
 void
 virCHDomainObjEndJob(virDomainObj *obj)
diff --git a/src/ch/ch_domain.h b/src/ch/ch_domain.h
index c7dfde601e..076043f772 100644
--- a/src/ch/ch_domain.h
+++ b/src/ch/ch_domain.h
@@ -60,10 +60,6 @@ struct _virCHDomainVcpuPrivate {
 extern virDomainXMLPrivateDataCallbacks virCHDriverPrivateDataCallbacks;
 extern virDomainDefParserConfig virCHDriverDomainDefParserConfig;
 
-int
-virCHDomainObjBeginJob(virDomainObj *obj, virDomainJob job)
-    G_GNUC_WARN_UNUSED_RESULT;
-
 void
 virCHDomainObjEndJob(virDomainObj *obj);
 
diff --git a/src/ch/ch_driver.c b/src/ch/ch_driver.c
index e7c172c894..b089a7c9c7 100644
--- a/src/ch/ch_driver.c
+++ b/src/ch/ch_driver.c
@@ -217,7 +217,7 @@ chDomainCreateXML(virConnectPtr conn,
                                    NULL)))
         goto cleanup;
 
-    if (virCHDomainObjBeginJob(vm, VIR_JOB_MODIFY) < 0)
+    if (virDomainObjBeginJob(vm, VIR_JOB_MODIFY) < 0)
         goto cleanup;
 
     if (virCHProcessStart(driver, vm, VIR_DOMAIN_RUNNING_BOOTED) < 0)
@@ -251,7 +251,7 @@ chDomainCreateWithFlags(virDomainPtr dom, unsigned int flags)
     if (virDomainCreateWithFlagsEnsureACL(dom->conn, vm->def) < 0)
         goto cleanup;
 
-    if (virCHDomainObjBeginJob(vm, VIR_JOB_MODIFY) < 0)
+    if (virDomainObjBeginJob(vm, VIR_JOB_MODIFY) < 0)
         goto cleanup;
 
     ret = virCHProcessStart(driver, vm, VIR_DOMAIN_RUNNING_BOOTED);
@@ -390,7 +390,7 @@ chDomainShutdownFlags(virDomainPtr dom,
     if (virDomainShutdownFlagsEnsureACL(dom->conn, vm->def, flags) < 0)
         goto cleanup;
 
-    if (virCHDomainObjBeginJob(vm, VIR_JOB_MODIFY) < 0)
+    if (virDomainObjBeginJob(vm, VIR_JOB_MODIFY) < 0)
         goto cleanup;
 
     if (virDomainObjCheckActive(vm) < 0)
@@ -446,7 +446,7 @@ chDomainReboot(virDomainPtr dom, unsigned int flags)
     if (virDomainRebootEnsureACL(dom->conn, vm->def, flags) < 0)
         goto cleanup;
 
-    if (virCHDomainObjBeginJob(vm, VIR_JOB_MODIFY) < 0)
+    if (virDomainObjBeginJob(vm, VIR_JOB_MODIFY) < 0)
         goto cleanup;
 
     if (virDomainObjCheckActive(vm) < 0)
@@ -495,7 +495,7 @@ chDomainSuspend(virDomainPtr dom)
     if (virDomainSuspendEnsureACL(dom->conn, vm->def) < 0)
         goto cleanup;
 
-    if (virCHDomainObjBeginJob(vm, VIR_JOB_MODIFY) < 0)
+    if (virDomainObjBeginJob(vm, VIR_JOB_MODIFY) < 0)
         goto cleanup;
 
     if (virDomainObjCheckActive(vm) < 0)
@@ -540,7 +540,7 @@ chDomainResume(virDomainPtr dom)
     if (virDomainResumeEnsureACL(dom->conn, vm->def) < 0)
         goto cleanup;
 
-    if (virCHDomainObjBeginJob(vm, VIR_JOB_MODIFY) < 0)
+    if (virDomainObjBeginJob(vm, VIR_JOB_MODIFY) < 0)
         goto cleanup;
 
     if (virDomainObjCheckActive(vm) < 0)
@@ -594,7 +594,7 @@ chDomainDestroyFlags(virDomainPtr dom, unsigned int flags)
     if (virDomainDestroyFlagsEnsureACL(dom->conn, vm->def) < 0)
         goto cleanup;
 
-    if (virCHDomainObjBeginJob(vm, VIR_JOB_DESTROY) < 0)
+    if (virDomainObjBeginJob(vm, VIR_JOB_DESTROY) < 0)
         goto cleanup;
 
     if (virDomainObjCheckActive(vm) < 0)
@@ -1217,7 +1217,7 @@ chDomainPinVcpuFlags(virDomainPtr dom,
     if (virDomainPinVcpuFlagsEnsureACL(dom->conn, vm->def, flags) < 0)
         goto cleanup;
 
-    if (virCHDomainObjBeginJob(vm, VIR_JOB_MODIFY) < 0)
+    if (virDomainObjBeginJob(vm, VIR_JOB_MODIFY) < 0)
         goto cleanup;
 
     if (virDomainObjGetDefs(vm, flags, &def, &persistentDef) < 0)
@@ -1354,7 +1354,7 @@ chDomainPinEmulator(virDomainPtr dom,
     if (virDomainPinEmulatorEnsureACL(dom->conn, vm->def, flags) < 0)
         goto cleanup;
 
-    if (virCHDomainObjBeginJob(vm, VIR_JOB_MODIFY) < 0)
+    if (virDomainObjBeginJob(vm, VIR_JOB_MODIFY) < 0)
         goto cleanup;
 
     if (virDomainObjGetDefs(vm, flags, &def, &persistentDef) < 0)
@@ -1625,7 +1625,7 @@ chDomainSetNumaParameters(virDomainPtr dom,
         }
     }
 
-    if (virCHDomainObjBeginJob(vm, VIR_JOB_MODIFY) < 0)
+    if (virDomainObjBeginJob(vm, VIR_JOB_MODIFY) < 0)
         goto cleanup;
 
     if (virDomainObjGetDefs(vm, flags, &def, &persistentDef) < 0)
-- 
2.37.1




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux