[Libvirt-cim] [PATCH] (#2) Add Enumeration support to RASD

Dan Smith danms at us.ibm.com
Mon Feb 18 22:32:45 UTC 2008


# HG changeset patch
# User Dan Smith <danms at us.ibm.com>
# Date 1203373962 28800
# Node ID c118dc77598088e3bd866df48787e5999aeb9d10
# Parent  7b5611c03994d1568ba69560f5afad284df06bd0
(#2) Add Enumeration support to RASD

Supports enumerating a specific RASD type, as well as the parent classes
KVM_RASD, Xen_RASD, as well as CIM_RASD.

Changes:
 - Remove printf() in place of a CU_DEBUG() (before Kaitlin got a chance to
   complain, I'll have you know)

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

diff -r 7b5611c03994 -r c118dc775980 src/Virt_RASD.c
--- a/src/Virt_RASD.c	Fri Feb 15 13:35:31 2008 -0800
+++ b/src/Virt_RASD.c	Mon Feb 18 14:32:42 2008 -0800
@@ -34,6 +34,7 @@
 
 #include "device_parsing.h"
 #include "misc_util.h"
+#include "cs_util.h"
 
 #include "Virt_RASD.h"
 #include "svpc_types.h"
@@ -442,6 +443,100 @@ CMPIrc rasd_classname_from_type(uint16_t
         return rc;
 }
 
+static CMPIStatus _enum_rasds(const CMPIObjectPath *ref,
+                              struct inst_list *list)
+{
+        virConnectPtr conn = NULL;
+        virDomainPtr *domains = NULL;
+        int count;
+        int i, j;
+        uint16_t type;
+        CMPIStatus s;
+        uint16_t types[] = {CIM_RASD_TYPE_PROC,
+                            CIM_RASD_TYPE_DISK,
+                            CIM_RASD_TYPE_NET,
+                            CIM_RASD_TYPE_MEM,
+                            0};
+
+        conn = connect_by_classname(_BROKER, CLASSNAME(ref), &s);
+        if (conn == NULL)
+                return s;
+
+        count = get_domain_list(conn, &domains);
+        if (count <= 0) {
+                cu_statusf(_BROKER, &s,
+                           CMPI_RC_ERR_FAILED,
+                           "Unable to get domain list");
+                goto out;
+        }
+
+        if (rasd_type_from_classname(CLASSNAME(ref), &type) == CMPI_RC_OK) {
+                types[0] = type;
+                types[1] = 0;
+        }
+
+        for (i = 0; i < count; i++) {
+                for (j = 0; types[j] != 0; j++) {
+                        CU_DEBUG(("Doing RASD type %i for %s",
+                                  type, virDomainGetName(domains[i]));
+                        rasds_for_domain(_BROKER,
+                                         virDomainGetName(domains[i]),
+                                         types[j],
+                                         ref,
+                                         list);
+                }
+                virDomainFree(domains[i]);
+        }
+
+        s = (CMPIStatus){CMPI_RC_OK, NULL};
+
+ out:
+        virConnectClose(conn);
+        free(domains);
+
+        return s;
+}
+
+static CMPIStatus return_enum_rasds(const CMPIObjectPath *ref,
+                                    const CMPIResult *results,
+                                    const bool names_only)
+{
+        struct inst_list list;
+        CMPIStatus s;
+
+        inst_list_init(&list);
+
+        s = _enum_rasds(ref, &list);
+        if (s.rc == CMPI_RC_OK) {
+                if (names_only)
+                        cu_return_instance_names(results, &list);
+                else
+                        cu_return_instances(results, &list);
+        }
+
+        inst_list_free(&list);
+
+        return s;
+}
+
+static CMPIStatus EnumInstanceNames(CMPIInstanceMI *self,
+                                    const CMPIContext *context,
+                                    const CMPIResult *results,
+                                    const CMPIObjectPath *reference)
+{
+        return return_enum_rasds(reference, results, true);
+}
+
+static CMPIStatus EnumInstances(CMPIInstanceMI *self,
+                                const CMPIContext *context,
+                                const CMPIResult *results,
+                                const CMPIObjectPath *reference,
+                                const char **properties)
+{
+
+        return return_enum_rasds(reference, results, false);
+}
+
 static CMPIStatus GetInstance(CMPIInstanceMI *self,
                               const CMPIContext *context,
                               const CMPIResult *results,
@@ -516,8 +611,6 @@ DEFAULT_CI();
 DEFAULT_CI();
 DEFAULT_MI();
 DEFAULT_DI();
-DEFAULT_EI();
-DEFAULT_EIN();
 DEFAULT_INST_CLEANUP();
 DEFAULT_EQ();
 




More information about the Libvirt-cim mailing list