[PATCH 5/5] ch: use virDomainJob enum instead of virCHDomainJob

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

 



Signed-off-by: Kristina Hanicova <khanicov@xxxxxxxxxx>
---
 src/ch/ch_domain.c | 24 ++++++++----------------
 src/ch/ch_domain.h | 18 +++---------------
 src/ch/ch_driver.c | 20 ++++++++++----------
 3 files changed, 21 insertions(+), 41 deletions(-)

diff --git a/src/ch/ch_domain.c b/src/ch/ch_domain.c
index 25f581c1c3..bb489a74e3 100644
--- a/src/ch/ch_domain.c
+++ b/src/ch/ch_domain.c
@@ -31,14 +31,6 @@
 
 #define VIR_FROM_THIS VIR_FROM_CH
 
-VIR_ENUM_IMPL(virCHDomainJob,
-              CH_JOB_LAST,
-              "none",
-              "query",
-              "destroy",
-              "modify",
-);
-
 VIR_LOG_INIT("ch.ch_domain");
 
 static int
@@ -57,7 +49,7 @@ virCHDomainObjResetJob(virCHDomainObjPrivate *priv)
 {
     struct virCHDomainJobObj *job = &priv->job;
 
-    job->active = CH_JOB_NONE;
+    job->active = VIR_JOB_NONE;
     job->owner = 0;
 }
 
@@ -77,7 +69,7 @@ virCHDomainObjFreeJob(virCHDomainObjPrivate *priv)
  * Successful calls must be followed by EndJob eventually.
  */
 int
-virCHDomainObjBeginJob(virDomainObj *obj, enum virCHDomainJob job)
+virCHDomainObjBeginJob(virDomainObj *obj, virDomainJob job)
 {
     virCHDomainObjPrivate *priv = obj->privateData;
     unsigned long long now;
@@ -89,13 +81,13 @@ virCHDomainObjBeginJob(virDomainObj *obj, enum virCHDomainJob job)
 
     while (priv->job.active) {
         VIR_DEBUG("Wait normal job condition for starting job: %s",
-                  virCHDomainJobTypeToString(job));
+                  virDomainJobTypeToString(job));
         if (virCondWaitUntil(&priv->job.cond, &obj->parent.lock, then) < 0) {
             VIR_WARN("Cannot start job (%s) for domain %s;"
                      " current job is (%s) owned by (%d)",
-                     virCHDomainJobTypeToString(job),
+                     virDomainJobTypeToString(job),
                      obj->def->name,
-                     virCHDomainJobTypeToString(priv->job.active),
+                     virDomainJobTypeToString(priv->job.active),
                      priv->job.owner);
 
             if (errno == ETIMEDOUT)
@@ -110,7 +102,7 @@ virCHDomainObjBeginJob(virDomainObj *obj, enum virCHDomainJob job)
 
     virCHDomainObjResetJob(priv);
 
-    VIR_DEBUG("Starting job: %s", virCHDomainJobTypeToString(job));
+    VIR_DEBUG("Starting job: %s", virDomainJobTypeToString(job));
     priv->job.active = job;
     priv->job.owner = virThreadSelfID();
 
@@ -127,10 +119,10 @@ void
 virCHDomainObjEndJob(virDomainObj *obj)
 {
     virCHDomainObjPrivate *priv = obj->privateData;
-    enum virCHDomainJob job = priv->job.active;
+    virDomainJob job = priv->job.active;
 
     VIR_DEBUG("Stopping job: %s",
-              virCHDomainJobTypeToString(job));
+              virDomainJobTypeToString(job));
 
     virCHDomainObjResetJob(priv);
     virCondSignal(&priv->job.cond);
diff --git a/src/ch/ch_domain.h b/src/ch/ch_domain.h
index 11a20a874a..f75a08ec87 100644
--- a/src/ch/ch_domain.h
+++ b/src/ch/ch_domain.h
@@ -24,27 +24,15 @@
 #include "ch_monitor.h"
 #include "virchrdev.h"
 #include "vircgroup.h"
+#include "domain_job.h"
 
 /* Give up waiting for mutex after 30 seconds */
 #define CH_JOB_WAIT_TIME (1000ull * 30)
 
-/* Only 1 job is allowed at any time
- * A job includes *all* ch.so api, even those just querying
- * information, not merely actions */
-
-enum virCHDomainJob {
-    CH_JOB_NONE = 0,      /* Always set to 0 for easy if (jobActive) conditions */
-    CH_JOB_QUERY,         /* Doesn't change any state */
-    CH_JOB_DESTROY,       /* Destroys the domain (cannot be masked out) */
-    CH_JOB_MODIFY,        /* May change state */
-    CH_JOB_LAST
-};
-VIR_ENUM_DECL(virCHDomainJob);
-
 
 struct virCHDomainJobObj {
     virCond cond;                       /* Use to coordinate jobs */
-    enum virCHDomainJob active;        /* Currently running job */
+    virDomainJob active;                /* Currently running job */
     int owner;                          /* Thread which set current job */
 };
 
@@ -82,7 +70,7 @@ extern virDomainXMLPrivateDataCallbacks virCHDriverPrivateDataCallbacks;
 extern virDomainDefParserConfig virCHDriverDomainDefParserConfig;
 
 int
-virCHDomainObjBeginJob(virDomainObj *obj, enum virCHDomainJob job)
+virCHDomainObjBeginJob(virDomainObj *obj, virDomainJob job)
     G_GNUC_WARN_UNUSED_RESULT;
 
 void
diff --git a/src/ch/ch_driver.c b/src/ch/ch_driver.c
index ac9298c0b5..2fe7aba9d0 100644
--- a/src/ch/ch_driver.c
+++ b/src/ch/ch_driver.c
@@ -224,7 +224,7 @@ chDomainCreateXML(virConnectPtr conn,
                                    NULL)))
         goto cleanup;
 
-    if (virCHDomainObjBeginJob(vm, CH_JOB_MODIFY) < 0)
+    if (virCHDomainObjBeginJob(vm, VIR_JOB_MODIFY) < 0)
         goto cleanup;
 
     if (virCHProcessStart(driver, vm, VIR_DOMAIN_RUNNING_BOOTED) < 0)
@@ -258,7 +258,7 @@ chDomainCreateWithFlags(virDomainPtr dom, unsigned int flags)
     if (virDomainCreateWithFlagsEnsureACL(dom->conn, vm->def) < 0)
         goto cleanup;
 
-    if (virCHDomainObjBeginJob(vm, CH_JOB_MODIFY) < 0)
+    if (virCHDomainObjBeginJob(vm, VIR_JOB_MODIFY) < 0)
         goto cleanup;
 
     ret = virCHProcessStart(driver, vm, VIR_DOMAIN_RUNNING_BOOTED);
@@ -397,7 +397,7 @@ chDomainShutdownFlags(virDomainPtr dom,
     if (virDomainShutdownFlagsEnsureACL(dom->conn, vm->def, flags) < 0)
         goto cleanup;
 
-    if (virCHDomainObjBeginJob(vm, CH_JOB_MODIFY) < 0)
+    if (virCHDomainObjBeginJob(vm, VIR_JOB_MODIFY) < 0)
         goto cleanup;
 
     if (virDomainObjCheckActive(vm) < 0)
@@ -453,7 +453,7 @@ chDomainReboot(virDomainPtr dom, unsigned int flags)
     if (virDomainRebootEnsureACL(dom->conn, vm->def, flags) < 0)
         goto cleanup;
 
-    if (virCHDomainObjBeginJob(vm, CH_JOB_MODIFY) < 0)
+    if (virCHDomainObjBeginJob(vm, VIR_JOB_MODIFY) < 0)
         goto cleanup;
 
     if (virDomainObjCheckActive(vm) < 0)
@@ -502,7 +502,7 @@ chDomainSuspend(virDomainPtr dom)
     if (virDomainSuspendEnsureACL(dom->conn, vm->def) < 0)
         goto cleanup;
 
-    if (virCHDomainObjBeginJob(vm, CH_JOB_MODIFY) < 0)
+    if (virCHDomainObjBeginJob(vm, VIR_JOB_MODIFY) < 0)
         goto cleanup;
 
     if (virDomainObjCheckActive(vm) < 0)
@@ -547,7 +547,7 @@ chDomainResume(virDomainPtr dom)
     if (virDomainResumeEnsureACL(dom->conn, vm->def) < 0)
         goto cleanup;
 
-    if (virCHDomainObjBeginJob(vm, CH_JOB_MODIFY) < 0)
+    if (virCHDomainObjBeginJob(vm, VIR_JOB_MODIFY) < 0)
         goto cleanup;
 
     if (virDomainObjCheckActive(vm) < 0)
@@ -601,7 +601,7 @@ chDomainDestroyFlags(virDomainPtr dom, unsigned int flags)
     if (virDomainDestroyFlagsEnsureACL(dom->conn, vm->def) < 0)
         goto cleanup;
 
-    if (virCHDomainObjBeginJob(vm, CH_JOB_DESTROY) < 0)
+    if (virCHDomainObjBeginJob(vm, VIR_JOB_DESTROY) < 0)
         goto cleanup;
 
     if (virDomainObjCheckActive(vm) < 0)
@@ -1221,7 +1221,7 @@ chDomainPinVcpuFlags(virDomainPtr dom,
     if (virDomainPinVcpuFlagsEnsureACL(dom->conn, vm->def, flags) < 0)
         goto cleanup;
 
-    if (virCHDomainObjBeginJob(vm, CH_JOB_MODIFY) < 0)
+    if (virCHDomainObjBeginJob(vm, VIR_JOB_MODIFY) < 0)
         goto cleanup;
 
     if (virDomainObjGetDefs(vm, flags, &def, &persistentDef) < 0)
@@ -1358,7 +1358,7 @@ chDomainPinEmulator(virDomainPtr dom,
     if (virDomainPinEmulatorEnsureACL(dom->conn, vm->def, flags) < 0)
         goto cleanup;
 
-    if (virCHDomainObjBeginJob(vm, CH_JOB_MODIFY) < 0)
+    if (virCHDomainObjBeginJob(vm, VIR_JOB_MODIFY) < 0)
         goto cleanup;
 
     if (virDomainObjGetDefs(vm, flags, &def, &persistentDef) < 0)
@@ -1629,7 +1629,7 @@ chDomainSetNumaParameters(virDomainPtr dom,
         }
     }
 
-    if (virCHDomainObjBeginJob(vm, CH_JOB_MODIFY) < 0)
+    if (virCHDomainObjBeginJob(vm, VIR_JOB_MODIFY) < 0)
         goto cleanup;
 
     if (virDomainObjGetDefs(vm, flags, &def, &persistentDef) < 0)
-- 
2.35.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