Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
openSUSE:Evergreen:11.1:kernel-2.6.32
libvirt-cim
768_error.patch
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File 768_error.patch of Package libvirt-cim
# HG changeset patch # User Dan Smith <danms@us.ibm.com> # Date 1227560778 28800 # Node ID f21e9ebf0ad0573bf55be7c16a9d32a07d9ac899 # Parent 11147ca6980ce2d1999b600e316fd3c415f744b6 Make DefineSystem() and RequestStateChange() provide rich errors This patch adds use of the new virt_set_status() function to a couple of providers where it's likely to be the most effective. A DefineSystem() call can fail for a variety of reasons, as can an attempt to change the state of a guest. By pulling in the libvirt error message, we're much more likely to be able to debug the issue from just the error message the CIM client gets. Signed-off-by: Dan Smith <danms@us.ibm.com> Index: libvirt-cim-0.5.2/src/Virt_ComputerSystem.c =================================================================== --- libvirt-cim-0.5.2.orig/src/Virt_ComputerSystem.c +++ libvirt-cim-0.5.2/src/Virt_ComputerSystem.c @@ -771,27 +771,39 @@ static void set_scheduler_params(virDoma /* This composite operation may be supported as a flag to reboot */ -static int domain_reset(virDomainPtr dom) +static CMPIStatus domain_reset(virDomainPtr dom) { int ret; virConnectPtr conn = NULL; char *xml = NULL; + CMPIStatus s = {CMPI_RC_OK, NULL}; conn = virDomainGetConnect(dom); if (conn == NULL) { CU_DEBUG("Unable to get connection from domain"); - return 1; + cu_statusf(_BROKER, &s, + CMPI_RC_ERR_FAILED, + "Unable to get domain connection"); + return s; } xml = virDomainGetXMLDesc(dom, 0); if (xml == NULL) { CU_DEBUG("Unable to retrieve domain XML"); - return 1; + cu_statusf(_BROKER, &s, + CMPI_RC_ERR_FAILED, + "Unable to get domain definition"); + return s; } ret = virDomainDestroy(dom); - if (ret) + if (ret != 0) { + virt_set_status(_BROKER, &s, + CMPI_RC_ERR_FAILED, + virDomainGetConnect(dom), + "Unable to destroy domain"); goto out; + } dom = virDomainLookupByName(virDomainGetConnect(dom), virDomainGetName(dom)); @@ -799,8 +811,11 @@ static int domain_reset(virDomainPtr dom if (dom == NULL) { dom = virDomainDefineXML(conn, xml); if (dom == NULL) { - CU_DEBUG("Failed to define domain from XML"); - ret = 1; + CU_DEBUG("Failed to define domain from XML"); + virt_set_status(_BROKER, &s, + CMPI_RC_ERR_FAILED, + virDomainGetConnect(dom), + "Unable to define domain"); goto out; } } @@ -809,11 +824,16 @@ static int domain_reset(virDomainPtr dom CU_DEBUG("Guest is now offline"); ret = virDomainCreate(dom); + if (ret != 0) + virt_set_status(_BROKER, &s, + CMPI_RC_ERR_FAILED, + virDomainGetConnect(dom), + "Failed to start domain"); out: free(xml); - return ret; + return s; } static CMPIStatus start_domain(virDomainPtr dom) @@ -828,9 +848,10 @@ static CMPIStatus start_domain(virDomain } if (virDomainCreate(dom) != 0) { - cu_statusf(_BROKER, &s, - CMPI_RC_ERR_FAILED, - "Unable to start domain"); + virt_set_status(_BROKER, &s, + CMPI_RC_ERR_FAILED, + virDomainGetConnect(dom), + "Unable to start domain"); return s; } @@ -842,7 +863,6 @@ static CMPIStatus start_domain(virDomain static CMPIStatus state_change_enable(virDomainPtr dom, virDomainInfoPtr info) { CMPIStatus s = {CMPI_RC_OK, NULL}; - int ret = 0; switch (info->state) { case VIR_DOMAIN_SHUTOFF: @@ -851,7 +871,11 @@ static CMPIStatus state_change_enable(vi break; case VIR_DOMAIN_PAUSED: CU_DEBUG("Unpause domain"); - ret = virDomainResume(dom); + if (virDomainResume(dom) != 0) + virt_set_status(_BROKER, &s, + CMPI_RC_ERR_FAILED, + virDomainGetConnect(dom), + "Unable to unpause domain"); break; default: CU_DEBUG("Cannot go to enabled state from %i", info->state); @@ -860,18 +884,12 @@ static CMPIStatus state_change_enable(vi "Invalid state transition"); }; - if (ret != 0) - cu_statusf(_BROKER, &s, - CMPI_RC_ERR_FAILED, - "Domain Operation Failed"); - return s; } static CMPIStatus state_change_disable(virDomainPtr dom, virDomainInfoPtr info) { CMPIStatus s = {CMPI_RC_OK, NULL}; - int ret = 0; info->state = adjust_state_xen(dom, info->state); @@ -879,7 +897,11 @@ static CMPIStatus state_change_disable(v case VIR_DOMAIN_RUNNING: case VIR_DOMAIN_BLOCKED: CU_DEBUG("Stop domain"); - ret = virDomainShutdown(dom); + if (virDomainShutdown(dom) != 0) + virt_set_status(_BROKER, &s, + CMPI_RC_ERR_FAILED, + virDomainGetConnect(dom), + "Unable to stop domain"); break; default: CU_DEBUG("Cannot go to disabled/shutdown state from %i", @@ -889,18 +911,12 @@ static CMPIStatus state_change_disable(v "Invalid state transition"); }; - if (ret != 0) - cu_statusf(_BROKER, &s, - CMPI_RC_ERR_FAILED, - "Domain Operation Failed"); - return s; } static CMPIStatus state_change_pause(virDomainPtr dom, virDomainInfoPtr info) { CMPIStatus s = {CMPI_RC_OK, NULL}; - int ret = 0; info->state = adjust_state_xen(dom, info->state); @@ -908,7 +924,11 @@ static CMPIStatus state_change_pause(vir case VIR_DOMAIN_RUNNING: case VIR_DOMAIN_BLOCKED: CU_DEBUG("Pause domain"); - ret = virDomainSuspend(dom); + if (virDomainSuspend(dom) != 0) + virt_set_status(_BROKER, &s, + CMPI_RC_ERR_FAILED, + virDomainGetConnect(dom), + "Unable to pause domain"); break; default: cu_statusf(_BROKER, &s, @@ -916,18 +936,12 @@ static CMPIStatus state_change_pause(vir "Domain not running"); }; - if (ret != 0) - cu_statusf(_BROKER, &s, - CMPI_RC_ERR_FAILED, - "Domain Operation Failed"); - return s; } static CMPIStatus state_change_reboot(virDomainPtr dom, virDomainInfoPtr info) { CMPIStatus s = {CMPI_RC_OK, NULL}; - int ret = 0; info->state = adjust_state_xen(dom, info->state); @@ -936,7 +950,11 @@ static CMPIStatus state_change_reboot(vi case VIR_DOMAIN_BLOCKED: case VIR_DOMAIN_PAUSED: CU_DEBUG("Reboot domain"); - ret = virDomainReboot(dom, 0); + if (virDomainReboot(dom, 0) != 0) + virt_set_status(_BROKER, &s, + CMPI_RC_ERR_FAILED, + virDomainGetConnect(dom), + "Unable to reboot domain"); break; default: cu_statusf(_BROKER, &s, @@ -944,18 +962,12 @@ static CMPIStatus state_change_reboot(vi "Domain not running"); }; - if (ret != 0) - cu_statusf(_BROKER, &s, - CMPI_RC_ERR_FAILED, - "Domain Operation Failed"); - return s; } static CMPIStatus state_change_reset(virDomainPtr dom, virDomainInfoPtr info) { CMPIStatus s = {CMPI_RC_OK, NULL}; - int ret = 0; info->state = adjust_state_xen(dom, info->state); @@ -964,7 +976,7 @@ static CMPIStatus state_change_reset(vir case VIR_DOMAIN_BLOCKED: case VIR_DOMAIN_PAUSED: CU_DEBUG("Reset domain"); - ret = domain_reset(dom); + s = domain_reset(dom); break; default: cu_statusf(_BROKER, &s, @@ -972,11 +984,6 @@ static CMPIStatus state_change_reset(vir "Domain not running"); }; - if (ret != 0) - cu_statusf(_BROKER, &s, - CMPI_RC_ERR_FAILED, - "Domain Operation Failed"); - return s; } Index: libvirt-cim-0.5.2/src/Virt_VirtualSystemManagementService.c =================================================================== --- libvirt-cim-0.5.2.orig/src/Virt_VirtualSystemManagementService.c +++ libvirt-cim-0.5.2/src/Virt_VirtualSystemManagementService.c @@ -788,9 +788,10 @@ static CMPIInstance *connect_and_create( dom = virDomainDefineXML(conn, xml); if (dom == NULL) { CU_DEBUG("Failed to define domain from XML"); - cu_statusf(_BROKER, s, - CMPI_RC_ERR_FAILED, - "Failed to create domain"); + virt_set_status(_BROKER, s, + CMPI_RC_ERR_FAILED, + conn, + "Failed to define domain"); return NULL; }
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor