
# HG changeset patch # User Kaitlin Rupert <karupert@us.ibm.com> # Date 1249685637 25200 # Node ID b3412cf292d12512a3c6c6f9e266cfbaaa437fef # Parent 2cb7c25bb35e7cb7b532ed78a43a3f27cb9fcf4f Fix behavior of calling RequestStateChange() with DISABLED state... According to the CIM_EnabledLogicalElement mof, a disabled request should immediately disconnect the guest. Currently, the provider calls a shutdown. This patch changes the behavior so that DISABLED calls virDomainDestroy() and SHUTDOWN continues to call virDomainShutdown() as expected. Signed-off-by: Kaitlin Rupert <karupert@us.ibm.com> diff -r 2cb7c25bb35e -r b3412cf292d1 src/Virt_ComputerSystem.c --- a/src/Virt_ComputerSystem.c Thu Aug 06 16:53:24 2009 -0700 +++ b/src/Virt_ComputerSystem.c Fri Aug 07 15:53:57 2009 -0700 @@ -943,16 +943,41 @@ switch (info->state) { case VIR_DOMAIN_RUNNING: case VIR_DOMAIN_BLOCKED: - CU_DEBUG("Stop domain"); + CU_DEBUG("Disable domain"); + if (virDomainDestroy(dom) != 0) + virt_set_status(_BROKER, &s, + CMPI_RC_ERR_FAILED, + virDomainGetConnect(dom), + "Unable to disable domain"); + break; + default: + CU_DEBUG("Cannot go to disabled state from %i", info->state); + cu_statusf(_BROKER, &s, + CMPI_RC_ERR_FAILED, + "Invalid state transition"); + }; + + return s; +} + +static CMPIStatus state_change_shutdown(virDomainPtr dom, virDomainInfoPtr info) +{ + CMPIStatus s = {CMPI_RC_OK, NULL}; + + info->state = adjust_state_xen(dom, info->state); + + switch (info->state) { + case VIR_DOMAIN_RUNNING: + case VIR_DOMAIN_BLOCKED: + CU_DEBUG("Shudown domain"); if (virDomainShutdown(dom) != 0) virt_set_status(_BROKER, &s, CMPI_RC_ERR_FAILED, virDomainGetConnect(dom), - "Unable to stop domain"); + "Unable to shutdown domain"); break; default: - CU_DEBUG("Cannot go to disabled/shutdown state from %i", - info->state); + CU_DEBUG("Cannot go to shutdown state from %i", info->state); cu_statusf(_BROKER, &s, CMPI_RC_ERR_FAILED, "Invalid state transition"); @@ -1067,8 +1092,10 @@ if (state == CIM_STATE_ENABLED) s = state_change_enable(dom, &info); - else if ((state == CIM_STATE_DISABLED) || (state == CIM_STATE_SHUTDOWN)) + else if (state == CIM_STATE_DISABLED) s = state_change_disable(dom, &info); + else if (state == CIM_STATE_SHUTDOWN) + s = state_change_shutdown(dom, &info); else if (state == CIM_STATE_PAUSED) s = state_change_pause(dom, &info); else if (state == CIM_STATE_REBOOT)