
# HG changeset patch # User Kaitlin Rupert <karupert@us.ibm.com> # Date 1214850941 25200 # Node ID 98e6e7b6160be701c4124cb04eef9c893fdfaa1d # Parent b123b6b1fb08c3ab956f1c33801e743e082192b9 Add state transition poll to DestroySystem() call. Signed-off-by: Kaitlin Rupert <karupert@us.ibm.com> diff -r b123b6b1fb08 -r 98e6e7b6160b src/Virt_VirtualSystemManagementService.c --- a/src/Virt_VirtualSystemManagementService.c Fri Jun 27 08:59:09 2008 -0700 +++ b/src/Virt_VirtualSystemManagementService.c Mon Jun 30 11:35:41 2008 -0700 @@ -56,6 +56,7 @@ #define DEFAULT_MAC_PREFIX "00:16:3e" #define DEFAULT_XEN_WEIGHT 1024 +#define STATE_TRANSITION_TIMEOUT 120 const static CMPIBroker *_BROKER; @@ -832,6 +833,8 @@ CMPIObjectPath *sys; virConnectPtr conn = NULL; virDomainPtr dom = NULL; + virDomainInfo info; + int i; conn = connect_by_classname(_BROKER, CLASSNAME(reference), @@ -858,6 +861,34 @@ infostore_delete(virConnectGetType(conn), dom_name); virDomainDestroy(dom); /* Okay for this to fail */ + + for (i = 0; i < STATE_TRANSITION_TIMEOUT; i++) { + if ((i % 30) == 0) { + CU_DEBUG("Polling for destroy completion..."); + } + + dom = virDomainLookupByName(conn, dom_name); + if (dom == NULL) { + CU_DEBUG("Domain successfully destroyed"); + rc = IM_RC_OK; + trigger_indication(context, + "ComputerSystemDeletedIndication", + NAMESPACE(reference)); + goto error; + } + + if (virDomainGetInfo(dom, &info) != 0) { + CU_DEBUG("Unable to get domain current state"); + rc = IM_RC_SYS_NOT_FOUND; + goto error; + } + + if (info.state == VIR_DOMAIN_SHUTOFF) + break; + + sleep(1); + } + if (virDomainUndefine(dom) == 0) { rc = IM_RC_OK; trigger_indication(context,