# HG changeset patch
# User Kaitlin Rupert <karupert(a)us.ibm.com>
# Date 1218134457 25200
# Node ID 98bc9888014993a2b9642ad91202161f07941e94
# Parent 9f2f9b117797907bfa2b89a499b4eb5bb62cd458
(#4) For pause, reboot, and enable add support for guests in the NOSTATE state.
It's possible that a XenFV guest might return no state instead of blocked or running.
This can occur when the guest is active, but isn't running of the CPU or blocked
waiting for it.
This should be a safe approach - we return an error if the guest is in some other state or
if libvirt is unable to successfully change the state of the guest.
Updates from 3 to 4:
-Use single function to convert Xen NOSTATE to RUNNING.
Updates from 2 to 3:
-Add logic to check connection type so NOSTATE only applied to Xen guests.
Updates from 1 to 2:
-For the reboot and reset operations, add support for paused guests (per the VSP).
-If the guest returns VIR_DOMAIN_NOSTATE, the provider should return the value
CIM_STATE_ENABLED, not CIM_STATE_UNKNOWN.
Signed-off-by: Kaitlin Rupert <karupert(a)us.ibm.com>
diff -r 9f2f9b117797 -r 98bc98880149 src/Virt_ComputerSystem.c
--- a/src/Virt_ComputerSystem.c Mon Aug 04 11:57:27 2008 -0700
+++ b/src/Virt_ComputerSystem.c Thu Aug 07 11:40:57 2008 -0700
@@ -230,6 +230,22 @@
}
}
+static unsigned char adjust_state_xen(virDomainPtr dom,
+ unsigned char state)
+{
+ virConnectPtr conn;
+
+ if (state != VIR_DOMAIN_NOSTATE)
+ return state;
+
+ conn = virDomainGetConnect(dom);
+
+ if (STREQC(virConnectGetType(conn), "Xen"))
+ return VIR_DOMAIN_RUNNING;
+
+ return state;
+}
+
static uint16_t adjust_state_if_saved(const char *name,
uint16_t state)
{
@@ -259,6 +275,8 @@
ret = virDomainGetInfo(dom, &info);
if (ret != 0)
return 0;
+
+ info.state = adjust_state_xen(dom, info.state);
cim_state = state_lv_to_cim((const int)info.state);
cim_state = adjust_state_if_saved(virDomainGetName(dom), cim_state);
@@ -812,6 +830,8 @@
CMPIStatus s = {CMPI_RC_OK, NULL};
int ret = 0;
+ info->state = adjust_state_xen(dom, info->state);
+
switch (info->state) {
case VIR_DOMAIN_RUNNING:
case VIR_DOMAIN_BLOCKED:
@@ -837,9 +857,12 @@
CMPIStatus s = {CMPI_RC_OK, NULL};
int ret = 0;
+ info->state = adjust_state_xen(dom, info->state);
+
switch (info->state) {
case VIR_DOMAIN_RUNNING:
case VIR_DOMAIN_BLOCKED:
+ case VIR_DOMAIN_PAUSED:
CU_DEBUG("Reboot domain");
ret = virDomainReboot(dom, 0);
break;
@@ -862,9 +885,12 @@
CMPIStatus s = {CMPI_RC_OK, NULL};
int ret = 0;
+ info->state = adjust_state_xen(dom, info->state);
+
switch (info->state) {
case VIR_DOMAIN_RUNNING:
case VIR_DOMAIN_BLOCKED:
+ case VIR_DOMAIN_PAUSED:
CU_DEBUG("Reset domain");
ret = domain_reset(dom);
break;
Show replies by date