[Libvirt-cim] [PATCH] Add three new OperationalStatus states and map them all to libvirt states

Richard Maciel rmaciel at linux.vnet.ibm.com
Mon Aug 10 17:06:01 UTC 2009


# HG changeset patch
# User Richard Maciel <rmaciel at linux.vnet.ibm.com>
# Date 1249923352 10800
# Node ID dbd688f6df87435cb97e68051fbc16c47730837d
# Parent  411a3090c6a098de809144334edaa41f5d3007b0
Add three new OperationalStatus states and map them all to libvirt states

OperationalStatus states added:
STARTED
SUSPENDED
RELOCATED

Signed-off-by: Richard Maciel <rmaciel at linux.vnet.ibm.com>

diff -r 411a3090c6a0 -r dbd688f6df87 src/Virt_ComputerSystem.c
--- a/src/Virt_ComputerSystem.c	Mon Aug 10 13:52:12 2009 -0300
+++ b/src/Virt_ComputerSystem.c	Mon Aug 10 13:55:52 2009 -0300
@@ -187,7 +187,7 @@
         }
 }
 
-static uint16_t state_lv_to_cim_os(const char lv_state)
+static uint16_t state_lv_to_cim_os(const char lv_state, const bool migrating)
 {
         enum CIM_op_status {
                 CIM_OP_STATUS_UNKNOWN = 0,
@@ -208,25 +208,33 @@
                 CIM_OP_STATUS_DORMANT = 15,
                 CIM_OP_STATUS_COMPLETED = 17,
                 CIM_OP_STATUS_POWER_MODE = 18,
+                CIM_OP_STATUS_STARTED = 32768,
+                CIM_OP_STATUS_SUSPENDED = 32769,
+                CIM_OP_STATUS_RELOCATED = 32770,
         };
 
+        
+        if (migrating)
+                return CIM_OP_STATUS_RELOCATED;
+
         switch (lv_state) {
         case VIR_DOMAIN_NOSTATE:
         case VIR_DOMAIN_SHUTDOWN:
         case VIR_DOMAIN_SHUTOFF:
-                return CIM_OP_STATUS_DORMANT;
+                return CIM_OP_STATUS_STOPPED;
 
         case VIR_DOMAIN_CRASHED:
                 return CIM_OP_STATUS_ERROR;
 
         case VIR_DOMAIN_RUNNING:
+                return CIM_OP_STATUS_STARTED;
+
         case VIR_DOMAIN_BLOCKED:
         case VIR_DOMAIN_PAUSED:
-                return CIM_OP_STATUS_OK;
+                return CIM_OP_STATUS_SUSPENDED;
 
         default:
                 return CIM_OP_STATUS_UNKNOWN;
-
         }
 }
 
@@ -271,6 +279,7 @@
         CMPIArray *array;
         CMPIStatus s;
         struct infostore_ctx *infostore = NULL;
+        bool migrating = false;
 
         ret = virDomainGetInfo(dom, &info);
         if (ret != 0) 
@@ -290,14 +299,19 @@
         array = CMNewArray(broker, 1, CMPI_uint16, &s);
         if ((s.rc != CMPI_RC_OK) || (CMIsNullObject(array)))
                 return 0;
+        
+        infostore = infostore_open(dom);
 
-        op_status = state_lv_to_cim_os((const int)info.state);
+        if (infostore != NULL) 
+                migrating = infostore_get_bool(infostore, "migrating");
+        
+        op_status = state_lv_to_cim_os((const int)info.state, migrating);
+
         CMSetArrayElementAt(array, 0, &op_status, CMPI_uint16);
 
         CMSetProperty(instance, "OperationalStatus",
                       (CMPIValue *)&array, CMPI_uint16A);
 
-        infostore = infostore_open(dom);
         if (infostore != NULL)
                 req_state = (uint16_t)infostore_get_u64(infostore, "reqstate");
         else




More information about the Libvirt-cim mailing list