[Libvirt-cim] [PATCH] Fix case where connecting to hypervisor fails in VSMS functions

Dan Smith danms at us.ibm.com
Wed Sep 3 21:01:19 UTC 2008


# HG changeset patch
# User Dan Smith <danms at us.ibm.com>
# Date 1220475645 25200
# Node ID 106e277174570fe49cd2fa9fa24a674766b737e5
# Parent  86910946029f1e34f7cc7657745f0d7f19e034b8
Fix case where connecting to hypervisor fails in VSMS functions

In the associations, we want to silently exit when we can't connect to the
hypervisor because of the way the CIMOM implements the association
traversal.  In VSMS, where the user has specifically invoked a method on
a particular reference, that is not the correct behavior.

Signed-off-by: Dan Smith <danms at us.ibm.com>

diff -r 86910946029f -r 106e27717457 src/Virt_VirtualSystemManagementService.c
--- a/src/Virt_VirtualSystemManagementService.c	Wed Sep 03 13:59:55 2008 -0700
+++ b/src/Virt_VirtualSystemManagementService.c	Wed Sep 03 14:00:45 2008 -0700
@@ -1029,6 +1029,7 @@
         CMPIInstance *sys;
         CMPIArray *res;
         CMPIStatus s;
+        uint32_t rc = CIM_SVPC_RETURN_FAILED;
 
         CU_DEBUG("DefineSystem");
 
@@ -1054,6 +1055,10 @@
                            "ComputerSystemCreatedIndication",
                            reference);
  out:
+        if (s.rc == CMPI_RC_OK)
+                rc = CIM_SVPC_RETURN_COMPLETED;
+        CMReturnData(results, &rc, CMPI_uint32);
+
         return s;
 }
 
@@ -1538,16 +1543,22 @@
 
 static CMPIStatus _update_resource_settings(const CMPIObjectPath *ref,
                                             CMPIArray *resources,
+                                            const CMPIResult *results,
                                             resmod_fn func)
 {
         int i;
         virConnectPtr conn = NULL;
         CMPIStatus s;
         int count;
+        uint32_t rc = CIM_SVPC_RETURN_FAILED;
 
         conn = connect_by_classname(_BROKER, CLASSNAME(ref), &s);
-        if (conn == NULL)
+        if (conn == NULL) {
+                cu_statusf(_BROKER, &s,
+                           CMPI_RC_ERR_FAILED,
+                           "Unable to connect to hypervisor");
                 goto out;
+        }
 
         count = CMGetArrayCount(resources, NULL);
 
@@ -1596,6 +1607,11 @@
 
         }
  out:
+        if (s.rc == CMPI_RC_OK)
+                rc = CIM_SVPC_RETURN_COMPLETED;
+
+        CMReturnData(results, &rc, CMPI_uint32);
+
         virConnectClose(conn);
 
         return s;
@@ -1603,6 +1619,7 @@
 
 static CMPIStatus update_resource_settings(const CMPIObjectPath *ref,
                                            const CMPIArgs *argsin,
+                                           const CMPIResult *results,
                                            resmod_fn func)
 {
         CMPIArray *arr;
@@ -1615,7 +1632,7 @@
                 goto out;
         }
 
-        s = _update_resource_settings(ref, arr, func);
+        s = _update_resource_settings(ref, arr, results, func);
 
  out:
         return s;
@@ -1689,7 +1706,10 @@
                                         const CMPIArgs *argsin,
                                         CMPIArgs *argsout)
 {
-        return update_resource_settings(reference, argsin, resource_add);
+        return update_resource_settings(reference,
+                                        argsin,
+                                        results,
+                                        resource_add);
 }
 
 static CMPIStatus mod_resource_settings(CMPIMethodMI *self,
@@ -1699,7 +1719,10 @@
                                         const CMPIArgs *argsin,
                                         CMPIArgs *argsout)
 {
-        return update_resource_settings(reference, argsin, resource_mod);
+        return update_resource_settings(reference,
+                                        argsin,
+                                        results,
+                                        resource_mod);
 }
 
 static CMPIStatus rm_resource_settings(CMPIMethodMI *self,
@@ -1728,7 +1751,10 @@
         if (s.rc != CMPI_RC_OK)
                 goto out;
 
-        s = _update_resource_settings(reference, resource_arr, resource_del);
+        s = _update_resource_settings(reference,
+                                      resource_arr,
+                                      results,
+                                      resource_del);
  out:
         return s;
 }
diff -r 86910946029f -r 106e27717457 src/svpc_types.h
--- a/src/svpc_types.h	Wed Sep 03 13:59:55 2008 -0700
+++ b/src/svpc_types.h	Wed Sep 03 14:00:45 2008 -0700
@@ -45,6 +45,7 @@
 #define CIM_VSSD_RECOVERY_PRESERVE 123
 
 #define CIM_SVPC_RETURN_JOB_STARTED   4096
+#define CIM_SVPC_RETURN_FAILED           2
 #define CIM_SVPC_RETURN_COMPLETED        0
 
 #define CIM_EC_CHAR_DEFAULT 2




More information about the Libvirt-cim mailing list