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

Dan Smith danms at us.ibm.com
Mon Nov 19 15:19:35 UTC 2007


# HG changeset patch
# User Dan Smith <danms at us.ibm.com>
# Date 1195488003 28800
# Node ID 66f0dde5f3fd81a495a1597033e180e251817054
# Parent  ef1552498688b0892f2c8d65c238da1d4a765e9c
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 ef1552498688 -r 66f0dde5f3fd src/Virt_ComputerSystem.c
--- a/src/Virt_ComputerSystem.c	Mon Nov 19 07:59:54 2007 -0800
+++ b/src/Virt_ComputerSystem.c	Mon Nov 19 08:00:03 2007 -0800
@@ -344,10 +344,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;
 
@@ -387,7 +384,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;
 
@@ -610,7 +607,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 ef1552498688 -r 66f0dde5f3fd src/Virt_SystemDevice.c
--- a/src/Virt_SystemDevice.c	Mon Nov 19 07:59:54 2007 -0800
+++ b/src/Virt_SystemDevice.c	Mon Nov 19 08:00:03 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