Hi Deepti!
Please refer to the CIM_ManagedSystemElement.mof to see the meaning of
each state.
As you already noticed, I only use some of the states defined. I do
this, because libvirt only returns a few states. That means you can
safely ignore the libvirt-cim states not mapped to libvirt states.
About the logic used to map states, follows the method used:
I added only one state to the "OperatingStatus" attribute: Started
Now the mapping was done using the following instructions (libvirt-cim
state: libvirt state):
Started: VIR_RUNNING
Dormant (equivalent to suspend): VIR_BLOCKED or VIR_PAUSED
Migrating (equivalent to relocated): There isn't really a libvirt state to
track down migrations. So, I submitted a patch to write migration
information to the infostore when a MigrationJob is created and to clean
that information when a MigrationJob is deleted.
Stopped: VIR_NOSTATE, VIR_SHUTDOWN or VIR_SHUTOFF
Aborted: VIR_CRASHED
Unknown: Every other state not mentioned here
On 08/18/2009 08:45 AM, Deepti B Kalakeri wrote:
Richard Maciel wrote:
> # HG changeset patch
> # User Richard Maciel <rmaciel(a)linux.vnet.ibm.com>
> # Date 1250185820 10800
> # Node ID edde8b4607e96d45d2c784070c84143be4d57fef
> # Parent 69ee9e708fe8fb2f5af562fdc412290e30fa41e7
> (#3) Add a new OperatingStatus state and map them all to libvirt states
>
> OperatingStatus state added:
> STARTED
>
> #2:
> Fixed patch submission date
>
> #3:
> Previous patches were setting the wrong provider variable
> (OperationalStatus).
>
> Signed-off-by: Richard Maciel <rmaciel(a)linux.vnet.ibm.com>
>
> diff -r 69ee9e708fe8 -r edde8b4607e9 src/Virt_ComputerSystem.c
> --- a/src/Virt_ComputerSystem.c Thu Aug 13 13:51:34 2009 -0300
> +++ b/src/Virt_ComputerSystem.c Thu Aug 13 14:50:20 2009 -0300
> @@ -187,6 +187,54 @@
> }
> }
>
> +static uint16_t state_lv_to_cim_oings(const char lv_state, const bool
> migrating)
> +{
> + enum CIM_oping_status {
> + CIM_OPING_STATUS_UNKNOWN = 0,
> + CIM_OPING_STATUS_NOT_AVAILABLE = 1,
> + CIM_OPING_STATUS_SERVICING = 2,
What does SERVICING Mean ?
> + CIM_OPING_STATUS_STARTING = 3,
> + CIM_OPING_STATUS_STOPPING = 4,
Whats the difference between STOPPED and STOPPING ?
> + CIM_OPING_STATUS_STOPPED = 5,
> + CIM_OPING_STATUS_ABORTED = 6,
> + CIM_OPING_STATUS_DORMANT = 7,
> + CIM_OPING_STATUS_COMPLETED = 8,
> + CIM_OPING_STATUS_MIGRATING = 9,
> + CIM_OPING_STATUS_EMIGRATING = 10,
When does the VM go to CIM_OPING_STATUS_EMIGRATING state ?
> + CIM_OPING_STATUS_IMMIGRATING = 11,
When does the VM go to CIM_OPING_STATUS_IMMIGRATING state ?
> + CIM_OPING_STATUS_SNAPSHOTTING = 12,
> + CIM_OPING_STATUS_SHUTTING_DOWN = 13,
> + CIM_OPING_STATUS_IN_TEST = 14,
> + CIM_OPING_STATUS_TRANSITIONING = 15,
Also,CIM_OPING_STATUS_IN_TEST , CIM_OPING_STATUS_TRANSITIONING?
> + CIM_OPING_STATUS_IN_SERVICE = 16,
Which SERVICE does the VM will be in to use the
CIM_OPING_STATUS_IN_SERVICE State ?
> + CIM_OPING_STATUS_STARTED = 32768,
> + };
Not all of these states used as of now in libvirt-cim providers aint ?
> +
> + + if (migrating)
> + return CIM_OPING_STATUS_MIGRATING;
> +
> + switch (lv_state) {
> + case VIR_DOMAIN_NOSTATE:
> + case VIR_DOMAIN_SHUTDOWN:
> + case VIR_DOMAIN_SHUTOFF:
> + return CIM_OPING_STATUS_STOPPED;
> +
> + case VIR_DOMAIN_CRASHED:
> + return CIM_OPING_STATUS_ABORTED;
> +
> + case VIR_DOMAIN_RUNNING:
> + return CIM_OPING_STATUS_STARTED;
> +
> + case VIR_DOMAIN_BLOCKED:
> + case VIR_DOMAIN_PAUSED:
> + return CIM_OPING_STATUS_DORMANT;
> +
> + default:
> + return CIM_OPING_STATUS_UNKNOWN;
> + }
> +}
> +
> static uint16_t state_lv_to_cim_os(const char lv_state)
> {
> enum CIM_op_status {
> @@ -268,9 +316,11 @@
> uint16_t health_state;
> uint16_t req_state;
> uint16_t op_status;
> + uint16_t oping_status;
> CMPIArray *array;
> CMPIStatus s;
> struct infostore_ctx *infostore = NULL;
> + bool migrating = false;
>
> ret = virDomainGetInfo(dom, &info);
> if (ret != 0) @@ -298,6 +348,14 @@
> (CMPIValue *)&array, CMPI_uint16A);
>
> infostore = infostore_open(dom);
> +
> + if (infostore != NULL) + migrating = infostore_get_bool(infostore,
> "migrating");
> +
> + oping_status = state_lv_to_cim_oings((const int)info.state, migrating);
> + CMSetProperty(instance, "OperatingStatus",
> + (CMPIValue *)&oping_status, CMPI_uint16);
> +
> if (infostore != NULL)
> req_state = (uint16_t)infostore_get_u64(infostore, "reqstate");
> else
>
> _______________________________________________
> Libvirt-cim mailing list
> Libvirt-cim(a)redhat.com
>
https://www.redhat.com/mailman/listinfo/libvirt-cim
--
Richard Maciel, MSc
IBM Linux Technology Center
rmaciel(a)linux.vnet.ibm.com