[Libvirt-cim] [PATCH 2 of 2] Make ElementCapabilities not assume a devid-style InstanceID

Dan Smith danms at us.ibm.com
Fri Nov 30 20:56:08 UTC 2007


# HG changeset patch
# User Dan Smith <danms at us.ibm.com>
# Date 1196459649 28800
# Node ID 73ebe077a44586f83b28741943308a4009227f2e
# Parent  801398c33b0a6486b096dc415c3d4aba47d9dc04
Make ElementCapabilities not assume a devid-style InstanceID

For the cap_to_sys case, grab the host_cs and use cu_compare_ref()
instead of inspecting the InstanceID directly.

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

diff -r 801398c33b0a -r 73ebe077a445 src/Virt_ElementCapabilities.c
--- a/src/Virt_ElementCapabilities.c	Fri Nov 30 13:51:05 2007 -0800
+++ b/src/Virt_ElementCapabilities.c	Fri Nov 30 13:54:09 2007 -0800
@@ -52,33 +52,22 @@ static CMPIStatus sys_to_cap(const CMPIO
                              struct inst_list *list)
 {
         CMPIInstance *inst;
-        CMPIrc host_rc;
-        const char *host_name = NULL;
-        const char *sys_name = NULL;
-        CMPIStatus s = {CMPI_RC_OK, NULL};
+        CMPIStatus s = {CMPI_RC_OK, NULL};
+        const char *prop = NULL;
 
         s = get_host_cs(_BROKER, ref, &inst);
         if (s.rc != CMPI_RC_OK)
                 goto out;
 
-        host_rc = cu_get_str_prop(inst, "Name", &host_name);
-        if (host_rc != CMPI_RC_OK)
-                goto out;
-        
-        if (cu_get_str_path(ref, "Name", &sys_name) != CMPI_RC_OK) {
+        prop = cu_compare_ref(ref, inst);
+        if (prop != NULL) {
                 cu_statusf(_BROKER, &s,
-                           CMPI_RC_ERR_FAILED,
-                           "Missing `Name' property");
-                goto out;
-        }
-
-        if (!STREQ(sys_name, host_name)) {
-                cu_statusf(_BROKER, &s, CMPI_RC_ERR_FAILED,
-                           "System '%s' is not a host system.", sys_name);
-                goto out;
-        }
-
-        s = get_vsm_cap(_BROKER, ref, sys_name, &inst);
+                           CMPI_RC_ERR_NOT_FOUND,
+                           "No such HostSystem (%s)", prop);
+                goto out;
+        }
+
+        s = get_vsm_cap(_BROKER, ref, &inst);
         if (s.rc == CMPI_RC_OK)
                 inst_list_add(list, inst);
  out:
@@ -89,44 +78,16 @@ static CMPIStatus cap_to_sys(const CMPIO
                              struct std_assoc_info *info,
                              struct inst_list *list)
 {
-        const char *inst_id;
-        char *host;
-        char *device;
-        const char *host_name;
-        CMPIrc host_rc;
-        CMPIInstance *inst;
-        CMPIStatus s = {CMPI_RC_OK, NULL};
-
-        if (cu_get_str_path(ref, "InstanceID", &inst_id) != CMPI_RC_OK) {
-                cu_statusf(_BROKER, &s, 
-                           CMPI_RC_ERR_FAILED,
-                           "Could not get InstanceID.");
-                goto out;
-        }
-
-        if (!parse_fq_devid(inst_id, &host, &device)) {
-                cu_statusf(_BROKER, &s, 
-                           CMPI_RC_ERR_FAILED,
-                           "Could not get system name.");
-                goto out;
-        }
+        CMPIInstance *inst;
+        CMPIStatus s = {CMPI_RC_OK, NULL};
 
         s = get_host_cs(_BROKER, ref, &inst);
         if (s.rc != CMPI_RC_OK)
                 goto out;
 
-        host_rc = cu_get_str_prop(inst, "Name", &host_name);
-        if (host_rc != CMPI_RC_OK)
-                goto out;
-
-        if (!STREQ(host_name, host))
-                goto out;
-
         inst_list_add(list, inst);
 
  out:
-        free(host);
-        free(device);
         return s;
 }
 




More information about the Libvirt-cim mailing list