[Libvirt-cim] [PATCH]

Kaitlin Rupert kaitlin at linux.vnet.ibm.com
Tue Dec 11 22:08:03 UTC 2007


# HG changeset patch
# User Kaitlin Rupert <karupert at us.ibm.com>
# Date 1197410852 28800
# Node ID 8761c7b39ea87feb54f89e41e1a7044104ec9399
# Parent  6c3ca59055416d7bb07716d3a750800e6087878e
#2 GetInstance() does not return an instance that matches the instanceID given.

Updates - removed boolean and now use a string, get instanceID in GetInstance() call instead.

Add a argument to return_ele_cap() that handles the GetInstance().  If this argument is set, get the InstanceID from the ref.  In the loop that walks through the domains on the system, check to see if this id matches one of the names returned.  If there is a match, create the instance and then exit from the loop.

If no match is found, an error is returned.

Failing query:
wbemcli gi http://localhost:5988/root/virt:Xen_EnabledLogicalElementCapabilities.InstanceID="kaitlin_test"

localhost:5988/root/virt:Xen_EnabledLogicalElementCapabilities.InstanceID="kaitlin_test" Caption,Description,InstanceID="hd_domain",ElementName,ElementNameEditSupported=FALSE,MaxElementNameLen,RequestedStatesSupported=2,3,9,10,11,ElementNameMask,StateAwareness,CreationClassName="Xen_EnabledLogicalElementCapabilities"

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

diff -r 6c3ca5905541 -r 8761c7b39ea8 src/Virt_EnabledLogicalElementCapabilities.c
--- a/src/Virt_EnabledLogicalElementCapabilities.c	Tue Dec 11 09:42:24 2007 -0800
+++ b/src/Virt_EnabledLogicalElementCapabilities.c	Tue Dec 11 14:07:32 2007 -0800
@@ -21,6 +21,7 @@
  */
 #include <stdlib.h>
 #include <unistd.h>
+#include <string.h>
 
 #include <cmpidt.h>
 #include <cmpift.h>
@@ -135,7 +136,8 @@ CMPIStatus get_ele_cap(const CMPIBroker 
 
 static CMPIStatus return_ele_cap(const CMPIObjectPath *ref,
                                  const CMPIResult *results,
-                                 int names_only)
+                                 int names_only,
+                                 const char *id)
 {
         CMPIStatus s = {CMPI_RC_OK, NULL};
         CMPIInstance *inst = NULL;
@@ -162,6 +164,9 @@ static CMPIStatus return_ele_cap(const C
                         goto end;
                 }
 
+                if (id && (!STREQ(name, id)))
+                        goto end;
+
                 s = get_ele_cap(_BROKER, ref, name, &inst);
                 if (s.rc != CMPI_RC_OK)
                         goto end;
@@ -174,7 +179,7 @@ static CMPIStatus return_ele_cap(const C
           end:
                 virDomainFree(list[i]);
 
-                if (s.rc != CMPI_RC_OK)
+                if ((s.rc != CMPI_RC_OK) || (id && (STREQ(name, id))))
                         goto out;
         }
 
@@ -191,7 +196,7 @@ static CMPIStatus EnumInstanceNames(CMPI
                                     const CMPIResult *results,
                                     const CMPIObjectPath *reference)
 {
-        return return_ele_cap(reference, results, 1);
+        return return_ele_cap(reference, results, 1, NULL);
 }
 
 static CMPIStatus EnumInstances(CMPIInstanceMI *self,
@@ -201,7 +206,7 @@ static CMPIStatus EnumInstances(CMPIInst
                                 const char **properties)
 {
 
-        return return_ele_cap(reference, results, 0);
+        return return_ele_cap(reference, results, 0, NULL);
 }
 
 static CMPIStatus GetInstance(CMPIInstanceMI *self,
@@ -210,7 +215,17 @@ static CMPIStatus GetInstance(CMPIInstan
                               const CMPIObjectPath *reference,
                               const char **properties)
 {
-        return return_ele_cap(reference, results, 0);
+        CMPIStatus s = {CMPI_RC_OK, NULL};
+        const char* id;
+
+        if (cu_get_str_path(reference, "InstanceID", &id) != CMPI_RC_OK) {
+                cu_statusf(_BROKER, &s,
+                           CMPI_RC_ERR_FAILED,
+                           "No InstanceID specified");
+                return s;
+        }
+
+        return return_ele_cap(reference, results, 0, id);
 }
 
 DEFAULT_CI();




More information about the Libvirt-cim mailing list