
# HG changeset patch # User Richard Maciel <rmaciel@linux.vnet.ibm.com> # Date 1250173962 10800 # Node ID cb885d38b2d89130c13342aa6e7455f991e8fda5 # Parent fc6b58380e5f04b09514bdfe8aef54ed0a013e42 (#2) Add three new OperationalStatus states and map them all to libvirt states OperationalStatus states added: STARTED SUSPENDED RELOCATED #2: Fixed patch submission date Signed-off-by: Richard Maciel <rmaciel@linux.vnet.ibm.com> diff -r fc6b58380e5f -r cb885d38b2d8 src/Virt_ComputerSystem.c --- a/src/Virt_ComputerSystem.c Thu Aug 13 11:31:46 2009 -0300 +++ b/src/Virt_ComputerSystem.c Thu Aug 13 11:32:42 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