[Libvirt-cim] [PATCH 3 of 3] Transition back to connect_by_classname()

Dan Smith danms at us.ibm.com
Fri Nov 16 19:26:36 UTC 2007


# HG changeset patch
# User Dan Smith <danms at us.ibm.com>
# Date 1195244699 28800
# Node ID 5ccd8aa18359f59d02f664ec9ebd9f07b422a698
# Parent  86766ef3c2479a9a5f6146e1865d94d17768a5a8
Transition back to connect_by_classname()

This patch contains the previously-discussed changes to ComputerSystem and
SystemDevice (including Heidi's change to remove provider_is_responsible()).
If this looks okay to people, then I'll start in on provider-by-provider
conversions.

Previously, we used the incoming reference for all operations to determine
the URI to pass to libvirt during a connect operation.  For some reason,
we transitioned away from that to a detection-based mechanism, which would
not support multiple technologies to be managed from the provider
simultaneously.

I think that we have enough other infrastructure in place now that this is
no longer a problem.  As a test, I offer this patch with a few key instances
of lv_connect() replaced with connect_by_classname() for discussion.

I have tested that enumeration of Xen_ComputerSystem, KVM_ComputerSystem,
and CIM_ComputerSystem are exclusive, and do not return any duplicate
results.

Further, I have confirmed that resolving Xen_SystemDevice against a
KVM_ComputerSystem instance does not work, and that no duplicate results
are returned in the case of CIM_SystemDevice.

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

diff -r 86766ef3c247 -r 5ccd8aa18359 src/Virt_ComputerSystem.c
--- a/src/Virt_ComputerSystem.c	Fri Nov 16 12:24:58 2007 -0800
+++ b/src/Virt_ComputerSystem.c	Fri Nov 16 12:24:59 2007 -0800
@@ -345,10 +345,7 @@ static CMPIStatus return_enum_domains(co
         virConnectPtr conn = NULL;
         int ret;
 
-        if (!provider_is_responsible(_BROKER, reference, &s))
-                return s;
-
-        conn = lv_connect(_BROKER, &s);
+        conn = connect_by_classname(_BROKER, CLASSNAME(reference), &s);
         if (conn == NULL)
                 return s;
 
@@ -388,7 +385,7 @@ static CMPIStatus get_domain(const CMPIO
                 return s;
         }
 
-        conn = lv_connect(_BROKER, &s);
+        conn = connect_by_classname(_BROKER, CLASSNAME(reference), &s);
         if (conn == NULL)
                 return s;
 
@@ -611,7 +608,7 @@ static CMPIStatus __state_change(char *n
         virDomainPtr dom = NULL;
         virDomainInfo info;
 
-        conn = lv_connect(_BROKER, &s);
+        conn = connect_by_classname(_BROKER, CLASSNAME(ref), &s);
         if (conn == NULL)
                 goto out;
 
diff -r 86766ef3c247 -r 5ccd8aa18359 src/Virt_SystemDevice.c
--- a/src/Virt_SystemDevice.c	Fri Nov 16 12:24:58 2007 -0800
+++ b/src/Virt_SystemDevice.c	Fri Nov 16 12:24:59 2007 -0800
@@ -61,6 +61,7 @@ static int get_dom_devices(const char *n
 static int get_dom_devices(const char *name,
                            struct inst_list *list,
                            int type,
+                           const char *host_cn,
                            const char *ns)
 {
         virConnectPtr conn = NULL;
@@ -68,7 +69,7 @@ static int get_dom_devices(const char *n
         CMPIStatus s;
         int ret = 0;
 
-        conn = lv_connect(_BROKER, &s);
+        conn = connect_by_classname(_BROKER, host_cn, &s);
         if (conn == NULL)
                 goto out;
 
@@ -87,17 +88,19 @@ static int get_dom_devices(const char *n
 
 static int get_all_devices(const char *name,
                            struct inst_list *list,
-                           char *ns)
+                           const char *host_cn,
+                           const char *ns)
 {
         int i;
 
         for (i = 0; i < DEV_TYPE_COUNT; i++)
-                get_dom_devices(name, list, device_types[i], ns);
+                get_dom_devices(name, list, device_types[i], host_cn, ns);
 
         return i;
 }
 
 static CMPIInstance *host_instance(char *name,
+                                   const char *host_cn,
                                    const char *ns)
 {
         CMPIInstance *inst = NULL;
@@ -114,7 +117,7 @@ static CMPIInstance *host_instance(char 
         if ((s.rc != CMPI_RC_OK) || CMIsNullObject(op))
                 goto out;
 
-        conn = lv_connect(_BROKER, &s);
+        conn = connect_by_classname(_BROKER, host_cn, &s);
         if (conn == NULL)
                 goto out;
 
@@ -173,9 +176,16 @@ static CMPIStatus sys_to_dev(const CMPIO
 
                 type = device_type_from_classname(info->result_class);
 
-                ret = get_dom_devices(host, list, type, NAMESPACE(ref));
+                ret = get_dom_devices(host,
+                                      list,
+                                      type,
+                                      CLASSNAME(ref),
+                                      NAMESPACE(ref));
         } else {
-                ret = get_all_devices(host, list, NAMESPACE(ref));
+                ret = get_all_devices(host,
+                                      list,
+                                      CLASSNAME(ref),
+                                      NAMESPACE(ref));
         }
 
         if (ret >= 0) {
@@ -218,6 +228,7 @@ static CMPIStatus dev_to_sys(const CMPIO
         }
 
         sys = host_instance(host,
+                            CLASSNAME(ref),
                             NAMESPACE(ref));
 
         if (sys == NULL)




More information about the Libvirt-cim mailing list