[Libvirt-cim] [PATCH] Fix class prefix to depend on established hypervisor connection

Heidi Eckhart heidieck at linux.vnet.ibm.com
Tue Nov 27 09:13:20 UTC 2007


# HG changeset patch
# User Heidi Eckhart <heidieck at linux.vnet.ibm.com>
# Date 1196158370 -3600
# Node ID 0e9ce5fd90ec7ab755c017cd5002e8115d7225b7
# Parent  690413b4aef454d03ce31003feea55a65fa5347b
Fix class prefix to depend on established hypervisor connection
Signed-off-by: Heidi Eckhart <heidieck at linux.vnet.ibm.com>

diff -r 690413b4aef4 -r 0e9ce5fd90ec src/Virt_ElementConformsToProfile.c
--- a/src/Virt_ElementConformsToProfile.c	Tue Nov 27 10:59:47 2007 +0100
+++ b/src/Virt_ElementConformsToProfile.c	Tue Nov 27 11:12:50 2007 +0100
@@ -50,7 +50,8 @@ static CMPIStatus elem_instances(const C
 static CMPIStatus elem_instances(const CMPIObjectPath *ref,
                                  struct std_assoc_info *info,
                                  struct inst_list *list,
-                                 struct reg_prof *profile)
+                                 struct reg_prof *profile,
+                                 virConnectPtr conn)
 {
         CMPIStatus s = {CMPI_RC_OK, NULL};
         CMPIObjectPath *op;
@@ -58,7 +59,8 @@ static CMPIStatus elem_instances(const C
         CMPIData data ;
         char *classname;
 
-        classname = get_typed_class("Xen", profile->provider_name);
+        classname = get_typed_class(pfx_from_conn(conn), 
+                                    profile->provider_name);
         if (classname == NULL) {
                 CMSetStatusWithChars(_BROKER, &s,
                                      CMPI_RC_ERR_FAILED, 
@@ -101,9 +103,14 @@ static CMPIStatus prof_to_elem(const CMP
                                struct inst_list *list)
 {
         CMPIStatus s = {CMPI_RC_OK, NULL};
+        virConnectPtr conn = NULL;
         char *id;
         int i;
         
+        conn = connect_by_classname(_BROKER, CLASSNAME(ref), &s);
+        if (conn == NULL)
+                return s;
+
         id = cu_get_str_path(ref, "InstanceID");
         if (id == NULL) {
                 CMSetStatusWithChars(_BROKER, &s,
@@ -114,7 +121,8 @@ static CMPIStatus prof_to_elem(const CMP
 
         for (i = 0; profiles[i] != NULL; i++) {
                 if (STREQ(id, profiles[i]->reg_id)) {
-                        s = elem_instances(ref, info, list, profiles[i]);
+                        s = elem_instances(ref, info, list, 
+                                           profiles[i], conn);
                         if ((s.rc != CMPI_RC_OK))
                                 goto error;
                         break;
@@ -124,6 +132,8 @@ static CMPIStatus prof_to_elem(const CMP
  error:
         free(id);
  out:
+        virConnectClose(conn);
+
         return s;
 }
 
@@ -182,10 +192,16 @@ static CMPIInstance *make_ref(const CMPI
                               struct std_assoc_info *info,
                               struct std_assoc *assoc)
 {
-        CMPIInstance *assoc_inst;
+        CMPIStatus s = {CMPI_RC_OK, NULL};
+        CMPIInstance *assoc_inst = NULL;
+        virConnectPtr conn = NULL;
+
+        conn = connect_by_classname(_BROKER, CLASSNAME(source_op), &s);
+        if (conn == NULL)
+                return NULL;
 
         assoc_inst = get_typed_instance(_BROKER,
-                                        "Xen",
+                                        pfx_from_conn(conn),
                                         "ElementConformsToProfile",
                                         NAMESPACE(source_op));
                 
@@ -198,6 +214,8 @@ static CMPIInstance *make_ref(const CMPI
                 CMSetProperty(assoc_inst, assoc->target_prop,
                               (CMPIValue *)&(target_op), CMPI_ref);
         }
+
+        virConnectClose(conn);
 
         return assoc_inst;
 }




More information about the Libvirt-cim mailing list