[Libvirt-cim] [PATCH 1 of 2] Add get_rasd_instance_from_ref() to RASD

Kaitlin Rupert kaitlin at linux.vnet.ibm.com
Tue Nov 20 23:46:42 UTC 2007


# HG changeset patch
# User Kaitlin Rupert <karupert at us.ibm.com>
# Date 1195605864 28800
# Node ID 00a0b30a8d7b7d11ba03b0857962ac15b40868ed
# Parent  83aeadb6ebd9089e633013a0c65246a6d4881fcb
Add get_rasd_instance_from_ref() to RASD.

This allows other providers to get a specific RASD instance without having to do a CBGetInstance().

Updated get_rasd_instance_from_ref() to take an InstanceID parameter.  The original version used the InstanceID from the ref.  This was incorrect becasue the ref might not always have an InstanceID or the InstanceID might not correspond to the InstanceID of the RASD instance we want to return.

Signed-off-by: Kaitlin Rupert <karupert at us.ibm.com>

diff -r 83aeadb6ebd9 -r 00a0b30a8d7b src/Virt_RASD.c
--- a/src/Virt_RASD.c	Tue Nov 20 16:39:17 2007 -0800
+++ b/src/Virt_RASD.c	Tue Nov 20 16:44:24 2007 -0800
@@ -179,6 +179,7 @@ static CMPIInstance *rasd_from_vdev(cons
 
 static CMPIInstance *get_rasd_instance(const CMPIContext *context,
                                        const CMPIObjectPath *ref,
+                                       const CMPIBroker *broker,
                                        const char *id,
                                        const uint16_t type)
 {
@@ -194,13 +195,13 @@ static CMPIInstance *get_rasd_instance(c
         if (!ret)
                 return NULL;
 
-        conn = connect_by_classname(_BROKER, CLASSNAME(ref), &s);
+        conn = connect_by_classname(broker, CLASSNAME(ref), &s);
         if (conn == NULL)
                 goto out;
 
         dev = find_dev(conn, type, host, devid);
         if (dev)
-                inst = rasd_from_vdev(_BROKER, dev, host, ref);
+                inst = rasd_from_vdev(broker, dev, host, ref);
 
  out:
         virConnectClose(conn);
@@ -238,6 +239,28 @@ CMPIrc rasd_type_from_classname(const ch
        return rc;
 }
 
+CMPIInstance *get_rasd_instance_from_ref(const CMPIContext *context,
+                                         const CMPIObjectPath *ref,
+                                         const char *id,
+                                         const CMPIBroker *broker)
+{
+        CMPIStatus s = {CMPI_RC_OK, NULL};
+        CMPIInstance *inst = NULL;
+        uint16_t type;
+
+        if (rasd_type_from_classname(CLASSNAME(ref), &type) != CMPI_RC_OK) {
+                cu_statusf(broker, &s,
+                           CMPI_RC_ERR_FAILED,
+                           "Unable to determine RASD type");
+                goto out;
+        }
+
+        inst = get_rasd_instance(context, ref, broker, id, type);
+
+ out:
+        return inst;
+}
+
 static CMPIStatus GetInstance(CMPIInstanceMI *self,
                               const CMPIContext *context,
                               const CMPIResult *results,
@@ -247,7 +270,6 @@ static CMPIStatus GetInstance(CMPIInstan
         CMPIStatus s = {CMPI_RC_OK, NULL};
         CMPIInstance *inst;
         char *id = NULL;
-        uint16_t type;
 
         id = cu_get_str_path(ref, "InstanceID");
         if (id == NULL) {
@@ -257,14 +279,7 @@ static CMPIStatus GetInstance(CMPIInstan
                 goto out;
         }
 
-        if (rasd_type_from_classname(CLASSNAME(ref), &type) != CMPI_RC_OK) {
-                cu_statusf(_BROKER, &s,
-                           CMPI_RC_ERR_FAILED,
-                           "Unable to determine RASD type");
-                goto out;
-        }
-
-        inst = get_rasd_instance(context, ref, id, type);
+        inst = get_rasd_instance_from_ref(context, ref, id, _BROKER);
 
         if (inst != NULL)
                 CMReturnInstance(results, inst);
@@ -273,6 +288,8 @@ static CMPIStatus GetInstance(CMPIInstan
                            CMPI_RC_ERR_FAILED,
                            "Unknown instance");
  out:
+        free(id);
+
         return s;
 }
 
diff -r 83aeadb6ebd9 -r 00a0b30a8d7b src/Virt_RASD.h
--- a/src/Virt_RASD.h	Tue Nov 20 16:39:17 2007 -0800
+++ b/src/Virt_RASD.h	Tue Nov 20 16:44:24 2007 -0800
@@ -41,6 +41,11 @@ int rasds_for_domain(const CMPIBroker *b
 
 CMPIrc rasd_type_from_classname(const char *cn, uint16_t *type);
 
+CMPIInstance *get_rasd_instance_from_ref(const CMPIContext *context,
+                                         const CMPIObjectPath *ref,
+                                         const char *id,
+                                         const CMPIBroker *broker);
+
 #endif
 
 /*




More information about the Libvirt-cim mailing list