[Libvirt-cim] [PATCH 1 of 9] EAFP: Provider registered per subclass

Heidi Eckhart heidieck at linux.vnet.ibm.com
Wed Dec 5 08:30:10 UTC 2007


# HG changeset patch
# User Heidi Eckhart <heidieck at linux.vnet.ibm.com>
# Date 1196844139 -3600
# Node ID 6500573879debb5d6086df84e17d4336090d8e92
# Parent  8140438a647cd53017d79b7036702fc053fe9e9c
EAFP: Provider registered per subclass

The provider registration approach - registering one provider
per subclass (Xen_<classname>Provider, KVM_<classname>Provider)
caused interoperability issues with Pegasus and sfcb. The same
call returned duplicates with sfcb and worked with Pegasus.
Signed-off-by: Heidi Eckhart <heidieck at linux.vnet.ibm.com>

diff -r 8140438a647c -r 6500573879de schema/ElementAllocatedFromPool.registration
--- a/schema/ElementAllocatedFromPool.registration	Fri Nov 30 17:21:33 2007 -0800
+++ b/schema/ElementAllocatedFromPool.registration	Wed Dec 05 09:42:19 2007 +0100
@@ -1,4 +1,4 @@
 # Copyright IBM Corp. 2007
 # Classname Namespace ProviderName ProviderModule ProviderTypes
-Xen_ElementAllocatedFromPool root/virt Xen_ElementAllocatedFromPoolProvider Virt_ElementAllocatedFromPool association
-KVM_ElementAllocatedFromPool root/virt KVM_ElementAllocatedFromPoolProvider Virt_ElementAllocatedFromPool association
+Xen_ElementAllocatedFromPool root/virt Virt_ElementAllocatedFromPoolProvider Virt_ElementAllocatedFromPool association
+KVM_ElementAllocatedFromPool root/virt Virt_ElementAllocatedFromPoolProvider Virt_ElementAllocatedFromPool association
diff -r 8140438a647c -r 6500573879de src/Virt_ElementAllocatedFromPool.c
--- a/src/Virt_ElementAllocatedFromPool.c	Fri Nov 30 17:21:33 2007 -0800
+++ b/src/Virt_ElementAllocatedFromPool.c	Wed Dec 05 09:42:19 2007 +0100
@@ -61,12 +61,15 @@ static CMPIStatus vdev_to_pool(const CMP
                                struct std_assoc_info *info,
                                struct inst_list *list)
 {
-        CMPIStatus s;
+        CMPIStatus s = {CMPI_RC_OK, NULL};
         uint16_t type;
         const char *id = NULL;
         char *poolid = NULL;
         virConnectPtr conn = NULL;
         CMPIInstance *pool = NULL;
+
+        if (!match_hypervisor_prefix(ref, info))
+                return s;
 
         type = class_to_type(ref);
         if (type == 0) {
@@ -196,7 +199,10 @@ static CMPIStatus pool_to_vdev(const CMP
                                struct inst_list *list)
 {
         const char *poolid;
-        CMPIStatus s;
+        CMPIStatus s = {CMPI_RC_OK, NULL};
+
+        if (!match_hypervisor_prefix(ref, info))
+                return s;
 
         if (cu_get_str_path(ref, "InstanceID", &poolid) != CMPI_RC_OK) {
                 cu_statusf(_BROKER, &s,
@@ -326,8 +332,7 @@ static struct std_assoc *handlers[] = {
         NULL
 };
 
-STDA_AssocMIStub(, Xen_ElementAllocatedFromPoolProvider, _BROKER, libvirt_cim_init(), handlers);
-STDA_AssocMIStub(, KVM_ElementAllocatedFromPoolProvider, _BROKER, libvirt_cim_init(), handlers);
+STDA_AssocMIStub(, Virt_ElementAllocatedFromPoolProvider, _BROKER, libvirt_cim_init(), handlers);
 
 /*
  * Local Variables:




More information about the Libvirt-cim mailing list