[Libvirt-cim] [PATCH 1 of 2] Add property filtering to RASD provider

Kaitlin Rupert kaitlin at linux.vnet.ibm.com
Fri Feb 22 18:13:32 UTC 2008


# HG changeset patch
# User Kaitlin Rupert <karupert at us.ibm.com>
# Date 1203702578 28800
# Node ID 2bff66d74872c62ef38fca81fafd32f0d7fb126a
# Parent  d02f5729977381ec6f5aec3503dc5f970a428b88
Add property filtering to RASD provider.

wbemcli is unable to parse embedded instance arrays, so this additional property filtering support will allow queries to exclude the HostResource property.

Failing Query:
wbemcli ei http://localhost/root/virt:Xen_ProcResourceAllocationSettingData
*
* wbemcli: Parse Exception: Unknown attribute in list for PROPERTY.ARRAY (EMBEDDEDOB)

Passing Query:
wbemcli ei http://localhost/root/virt:Xen_ProcResourceAllocationSettingData ResourceType

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

diff -r d02f57299773 -r 2bff66d74872 src/Virt_RASD.c
--- a/src/Virt_RASD.c	Fri Feb 22 12:54:52 2008 +0100
+++ b/src/Virt_RASD.c	Fri Feb 22 09:49:38 2008 -0800
@@ -283,8 +283,10 @@ static CMPIInstance *rasd_from_vdev(cons
 static CMPIInstance *rasd_from_vdev(const CMPIBroker *broker,
                                     struct virt_device *dev,
                                     const char *host,
-                                    const CMPIObjectPath *ref)
-{
+                                    const CMPIObjectPath *ref,
+                                    const char **properties)
+{
+        CMPIStatus s;
         CMPIInstance *inst;
         uint16_t type;
         char *base;
@@ -312,6 +314,14 @@ static CMPIInstance *rasd_from_vdev(cons
                                   NAMESPACE(ref));
         if (inst == NULL)
                 return inst;
+
+        if (properties != NULL) {
+                const char *keys[] = {"InstanceID", NULL};
+                s = CMSetPropertyFilter(inst, properties, keys);
+                /* FIXME - in case of an error, should we continue on? */
+                if (s.rc != CMPI_RC_OK)
+                        CU_DEBUG("Unable to set property filter: %d", s.rc);
+        }
 
         id = get_fq_devid((char *)host, dev->id);
 
@@ -361,6 +371,7 @@ CMPIStatus get_rasd_by_name(const CMPIBr
                             const CMPIObjectPath *reference,
                             const char *name,
                             const uint16_t type,
+                            const char **properties,
                             CMPIInstance **_inst)
 {
         CMPIInstance *inst = NULL;
@@ -397,7 +408,7 @@ CMPIStatus get_rasd_by_name(const CMPIBr
                 goto out;
         }
 
-        inst = rasd_from_vdev(broker, dev, host, reference);
+        inst = rasd_from_vdev(broker, dev, host, reference, properties);
         if (inst == NULL)
                 cu_statusf(broker, &s,
                            CMPI_RC_ERR_FAILED,
@@ -415,6 +426,7 @@ CMPIStatus get_rasd_by_name(const CMPIBr
 
 CMPIStatus get_rasd_by_ref(const CMPIBroker *broker,
                            const CMPIObjectPath *reference,
+                           const char **properties,
                            CMPIInstance **_inst)
 {
         CMPIStatus s = {CMPI_RC_OK, NULL};
@@ -435,7 +447,7 @@ CMPIStatus get_rasd_by_ref(const CMPIBro
                 goto out;
         }
 
-        s = get_rasd_by_name(broker, reference, name, type, _inst);
+        s = get_rasd_by_name(broker, reference, name, type, properties, _inst);
         if (s.rc != CMPI_RC_OK)
                 goto out;
         
@@ -498,6 +510,7 @@ CMPIrc rasd_classname_from_type(uint16_t
 }
 
 static CMPIStatus _enum_rasds(const CMPIObjectPath *ref,
+                              const char **properties,
                               struct inst_list *list)
 {
         virConnectPtr conn = NULL;
@@ -537,6 +550,7 @@ static CMPIStatus _enum_rasds(const CMPI
                                          virDomainGetName(domains[i]),
                                          types[j],
                                          ref,
+                                         properties,
                                          list);
                 }
                 virDomainFree(domains[i]);
@@ -553,6 +567,7 @@ static CMPIStatus _enum_rasds(const CMPI
 
 static CMPIStatus return_enum_rasds(const CMPIObjectPath *ref,
                                     const CMPIResult *results,
+                                    const char **properties,
                                     const bool names_only)
 {
         struct inst_list list;
@@ -560,7 +575,7 @@ static CMPIStatus return_enum_rasds(cons
 
         inst_list_init(&list);
 
-        s = _enum_rasds(ref, &list);
+        s = _enum_rasds(ref, properties, &list);
         if (s.rc == CMPI_RC_OK) {
                 if (names_only)
                         cu_return_instance_names(results, &list);
@@ -578,7 +593,7 @@ static CMPIStatus EnumInstanceNames(CMPI
                                     const CMPIResult *results,
                                     const CMPIObjectPath *reference)
 {
-        return return_enum_rasds(reference, results, true);
+        return return_enum_rasds(reference, results, NULL, true);
 }
 
 static CMPIStatus EnumInstances(CMPIInstanceMI *self,
@@ -588,7 +603,7 @@ static CMPIStatus EnumInstances(CMPIInst
                                 const char **properties)
 {
 
-        return return_enum_rasds(reference, results, false);
+        return return_enum_rasds(reference, results, properties, false);
 }
 
 static CMPIStatus GetInstance(CMPIInstanceMI *self,
@@ -600,7 +615,7 @@ static CMPIStatus GetInstance(CMPIInstan
         CMPIStatus s = {CMPI_RC_OK, NULL};
         CMPIInstance *inst = NULL;
 
-        s = get_rasd_by_ref(_BROKER, ref, &inst);
+        s = get_rasd_by_ref(_BROKER, ref, properties, &inst);
         if (s.rc != CMPI_RC_OK)
                 goto out;
 
@@ -614,6 +629,7 @@ int rasds_for_domain(const CMPIBroker *b
                      const char *name,
                      const uint16_t type,
                      const CMPIObjectPath *ref,
+                     const char **properties,
                      struct inst_list *_list)
 {
         struct virt_device *list;
@@ -631,7 +647,7 @@ int rasds_for_domain(const CMPIBroker *b
         for (i = 0; i < count; i++) {
                 CMPIInstance *inst;
 
-                inst = rasd_from_vdev(broker, &list[i], name, ref);
+                inst = rasd_from_vdev(broker, &list[i], name, ref, properties);
                 if (inst != NULL)
                         inst_list_add(_list, inst);
         }
diff -r d02f57299773 -r 2bff66d74872 src/Virt_RASD.h
--- a/src/Virt_RASD.h	Fri Feb 22 12:54:52 2008 +0100
+++ b/src/Virt_RASD.h	Fri Feb 22 09:49:38 2008 -0800
@@ -37,6 +37,7 @@ int rasds_for_domain(const CMPIBroker *b
                      const char *name,
                      const uint16_t type,
                      const CMPIObjectPath *ref,
+                     const char **properties,
                      struct inst_list *_list);
 
 CMPIrc rasd_type_from_classname(const char *cn, uint16_t *type);
@@ -46,10 +47,12 @@ CMPIStatus get_rasd_by_name(const CMPIBr
                             const CMPIObjectPath *reference,
                             const char *name,
                             const uint16_t type,
+                            const char **properties,
                             CMPIInstance **_inst);
 
 CMPIStatus get_rasd_by_ref(const CMPIBroker *broker,
                            const CMPIObjectPath *reference,
+                           const char **properties,
                            CMPIInstance **_inst);
 
 #endif




More information about the Libvirt-cim mailing list