[Libvirt-cim] [PATCH 2 of 3] This patch exposes error messages from libvirt calls in ComputerSystem

Richard Maciel rmaciel at linux.vnet.ibm.com
Tue Feb 24 17:19:45 UTC 2009


# HG changeset patch
# User Richard Maciel <rmaciel at linux.vnet.ibm.com>
# Date 1235493767 10800
# Node ID 874a34b43248c303da834aa73333bfe26a53943c
# Parent  ec95377909381bf92beee417b5fce4f699950df5
This patch exposes error messages from libvirt calls in ComputerSystem

#2:
  Added more points of error exposition
  Changed some error messages from "Could not..." to "Unable to..." to make them more readable

Signed-off-by: Richard Maciel <rmaciel at linux.vnet.ibm.com>

diff -r ec9537790938 -r 874a34b43248 src/Virt_ComputerSystem.c
--- a/src/Virt_ComputerSystem.c	Tue Feb 24 13:42:29 2009 -0300
+++ b/src/Virt_ComputerSystem.c	Tue Feb 24 13:42:47 2009 -0300
@@ -273,7 +273,7 @@
         struct infostore_ctx *infostore = NULL;
 
         ret = virDomainGetInfo(dom, &info);
-        if (ret != 0)
+        if (ret != 0) 
                 return 0;
 
         info.state = adjust_state_xen(dom, info.state);
@@ -398,19 +398,27 @@
 
         if (get_dominfo(dom, &domain) == 0) {
                 CU_DEBUG("Unable to get domain information");
-                cu_statusf(_BROKER, &s,
-                           CMPI_RC_ERR_FAILED,
-                           "Unable to get domain information");
+                virt_set_status(broker, &s,
+                                CMPI_RC_ERR_FAILED,
+                                virDomainGetConnect(dom),
+                                "Unable to get domain XML description");
                 goto out;
         }
 
         if (!set_name_from_dom(dom, instance)) {
-                /* Print trace error */
+                virt_set_status(broker, &s,
+                                CMPI_RC_ERR_FAILED,
+                                virDomainGetConnect(dom),
+                                "Unable to get domain name");
                 goto out;
         }
 
         if (!set_uuid_from_dom(dom, instance, &uuid)) {
-                /* Print trace error */
+                virt_set_status(broker, &s,
+                                CMPI_RC_ERR_FAILED,
+                                virDomainGetConnect(dom),
+                                "Unable to get domain UUID");
+
                 goto out;
         }
 
@@ -420,7 +428,11 @@
         }
 
         if (!set_state_from_dom(broker, dom, instance)) {
-                /* Print trace error */
+                virt_set_status(broker, &s,
+                                CMPI_RC_ERR_FAILED,
+                                virDomainGetConnect(dom),
+                                "Unable to get domain info");
+
                 goto out;
         }
 
@@ -570,10 +582,11 @@
 
         dom = virDomainLookupByName(conn, name);
         if (dom == NULL) {
-                cu_statusf(broker, &s,
-                           CMPI_RC_ERR_NOT_FOUND,
-                           "No such instance (%s).",
-                           name);
+                virt_set_status(broker, &s,
+                                CMPI_RC_ERR_NOT_FOUND,
+                                conn,
+                                "Referenced domain `%s' does not exist", 
+                                name);
                 goto out;
         }
 
@@ -790,9 +803,10 @@
         xml = virDomainGetXMLDesc(dom, 0);
         if (xml == NULL) {
                 CU_DEBUG("Unable to retrieve domain XML");
-                cu_statusf(_BROKER, &s,
-                           CMPI_RC_ERR_FAILED,
-                           "Unable to get domain definition");
+                virt_set_status(_BROKER, &s,
+                                CMPI_RC_ERR_FAILED,
+                                conn,
+                                "Unable to get domain definition");
                 return s;
         }
 
@@ -1003,16 +1017,18 @@
 
         dom = virDomainLookupByName(conn, name);
         if (dom == NULL) {
-                cu_statusf(_BROKER, &s,
-                           CMPI_RC_ERR_FAILED,
-                           "Domain not found");
+                virt_set_status(_BROKER, &s,
+                                CMPI_RC_ERR_FAILED,
+                                conn,
+                                "Domain not found");
                 goto out;
         }
 
         if (virDomainGetInfo(dom, &info) != 0) {
-                cu_statusf(_BROKER, &s,
-                           CMPI_RC_ERR_FAILED,
-                           "Unable to get current state");
+                virt_set_status(_BROKER, &s,
+                                CMPI_RC_ERR_FAILED,
+                                conn,
+                                "Unable to get current state");
                 goto out;
         }
 




More information about the Libvirt-cim mailing list