[PATCH 0 of 5] Fix up associations to SBLIM host system

This patch set attempts to patch up our associations for the case where the SBLIM providers are installed and we use them for our HostSystem class. Since that class exists in root/cimv2, we have to register our associations there as well, and make sure they provide paths back to the rest of our providers. The convert_sblim_hostsystem() function that I use to do this is a bit of a hack, given that it requires knowledge of how the reference we're passing to all of our factory functions is used. However, I think it's definitely the easiest thing to do right now. Comments are welcome as usual :)

# HG changeset patch # User Dan Smith <danms@us.ibm.com> # Date 1225739070 28800 # Node ID 7e9da8337ee60e6c73f020e37d22d692c0c7d494 # Parent 0d457a0fb221a91662cdbd90ccd803941a07db48 Add a function that converts a SBLIM host system instance to something with a platform prefix. This is just used to satisfy lower layers that key off the platform prefix (i.e. KVM_) of a class name to determine how to connect to libvirt. Signed-off-by: Dan Smith <danms@us.ibm.com> diff -r 0d457a0fb221 -r 7e9da8337ee6 libxkutil/misc_util.c --- a/libxkutil/misc_util.c Wed Oct 29 15:17:11 2008 -0700 +++ b/libxkutil/misc_util.c Mon Nov 03 11:04:30 2008 -0800 @@ -37,6 +37,8 @@ #include "misc_util.h" #include "cs_util.h" + +#include <config.h> #define URI_ENV "HYPURI" @@ -580,6 +582,31 @@ return actual; } +CMPIObjectPath *convert_sblim_hostsystem(const CMPIBroker *broker, + const CMPIObjectPath *ref, + struct std_assoc_info *info) +{ + CMPIObjectPath *vref = NULL; + CMPIStatus s; + char *base = NULL; + char *cn = NULL; + + base = class_base_name(CLASSNAME(ref)); + if (base == NULL) + goto out; + + cn = get_typed_class(info->assoc_class, base); + if (cn == NULL) + goto out; + + vref = CMNewObjectPath(broker, CIM_VIRT_NS, cn, &s); + out: + free(base); + free(cn); + + return vref; +} + /* * Local Variables: * mode: C diff -r 0d457a0fb221 -r 7e9da8337ee6 libxkutil/misc_util.h --- a/libxkutil/misc_util.h Wed Oct 29 15:17:11 2008 -0700 +++ b/libxkutil/misc_util.h Mon Nov 03 11:04:30 2008 -0800 @@ -126,6 +126,10 @@ int domain_vcpu_count(virDomainPtr dom); +CMPIObjectPath *convert_sblim_hostsystem(const CMPIBroker *broker, + const CMPIObjectPath *ref, + struct std_assoc_info *info); + #define LIBVIRT_CIM_DEFAULT_MAKEREF() \ static CMPIInstance* make_ref(const CMPIObjectPath *source_ref, \ const CMPIInstance *target_inst, \

# HG changeset patch # User Dan Smith <danms@us.ibm.com> # Date 1225739071 28800 # Node ID 44b096b7f0a02506efef9091854e182daf4bc812 # Parent 7e9da8337ee60e6c73f020e37d22d692c0c7d494 Make HostedResourcePool work from root/cimv2 and register it there ...so we can get back from HostSystem to our pools. Signed-off-by: Dan Smith <danms@us.ibm.com> diff -r 7e9da8337ee6 -r 44b096b7f0a0 Makefile.am --- a/Makefile.am Mon Nov 03 11:04:30 2008 -0800 +++ b/Makefile.am Mon Nov 03 11:04:31 2008 -0800 @@ -61,6 +61,8 @@ schema/ElementConformsToProfile.mof \ schema/ReferencedProfile.mof +CIMV2_MOFS = \ + schema/HostedResourcePool.mof REGS = \ schema/ComputerSystem.registration \ @@ -112,6 +114,9 @@ schema/ElementConformsToProfile.registration \ schema/ReferencedProfile.registration +CIMV2_REGS = \ + schema/HostedResourcePool.registration + pkgdata_DATA = $(MOFS) $(REGS) $(INTEROP_MOFS) $(INTEROP_REGS) pkgdata_SCRIPTS = provider-register.sh @@ -129,12 +134,14 @@ postinstall: sh provider-register.sh -v -t @CIMSERVER@ -n @CIM_VIRT_NS@ -r $(REGS) -m $(MOFS) sh provider-register.sh -v -t @CIMSERVER@ -n root/interop -r $(INTEROP_REGS) -m $(INTEROP_MOFS) + sh provider-register.sh -v -t @CIMSERVER@ -n root/cimv2 -r $(CIMV2_REGS) -m $(CIMV2_MOFS) virsh -v | grep -q '^0.3' && cp examples/diskpool.conf $(DISK_POOL_CONFIG) || true mkdir -p $(INFO_STORE) preuninstall: sh provider-register.sh -v -d -t @CIMSERVER@ -n @CIM_VIRT_NS@ -r $(REGS) -m $(MOFS) sh provider-register.sh -v -d -t @CIMSERVER@ -n root/interop -r $(INTEROP_REGS) -m $(INTEROP_MOFS) + sh provider-register.sh -v -d -t @CIMSERVER@ -n root/cimv2 -r $(CIMV2_REGS) -m $(CIMV2_MOFS) rpm: clean @(unset CDPATH ; $(MAKE) dist && rpmbuild -ta $(distdir).tar.gz) diff -r 7e9da8337ee6 -r 44b096b7f0a0 schema/HostedResourcePool.registration --- a/schema/HostedResourcePool.registration Mon Nov 03 11:04:30 2008 -0800 +++ b/schema/HostedResourcePool.registration Mon Nov 03 11:04:31 2008 -0800 @@ -3,3 +3,6 @@ Xen_HostedResourcePool root/virt Virt_HostedResourcePool Virt_HostedResourcePool association KVM_HostedResourcePool root/virt Virt_HostedResourcePool Virt_HostedResourcePool association LXC_HostedResourcePool root/virt Virt_HostedResourcePool Virt_HostedResourcePool association +Xen_HostedResourcePool root/cimv2 Virt_HostedResourcePool Virt_HostedResourcePool association +KVM_HostedResourcePool root/cimv2 Virt_HostedResourcePool Virt_HostedResourcePool association +LXC_HostedResourcePool root/cimv2 Virt_HostedResourcePool Virt_HostedResourcePool association diff -r 7e9da8337ee6 -r 44b096b7f0a0 src/Virt_HostedResourcePool.c --- a/src/Virt_HostedResourcePool.c Mon Nov 03 11:04:30 2008 -0800 +++ b/src/Virt_HostedResourcePool.c Mon Nov 03 11:04:31 2008 -0800 @@ -31,6 +31,8 @@ #include <libcmpiutil/libcmpiutil.h> #include "misc_util.h" #include <libcmpiutil/std_association.h> + +#include <config.h> #include "Virt_HostSystem.h" #include "Virt_DevicePool.h" @@ -68,15 +70,21 @@ { CMPIStatus s = {CMPI_RC_OK, NULL}; CMPIInstance *inst = NULL; + CMPIObjectPath *virtref = NULL; - if (!match_hypervisor_prefix(ref, info)) + if (!STARTS_WITH(CLASSNAME(ref), "Linux_") && + !match_hypervisor_prefix(ref, info)) + goto out; + + virtref = convert_sblim_hostsystem(_BROKER, ref, info); + if (virtref == NULL) goto out; s = get_host(_BROKER, info->context, ref, &inst, true); if (s.rc != CMPI_RC_OK) goto out; - s = enum_pools(_BROKER, ref, CIM_RES_TYPE_ALL, list); + s = enum_pools(_BROKER, virtref, CIM_RES_TYPE_ALL, list); out: return s; @@ -88,6 +96,7 @@ "Xen_HostSystem", "KVM_HostSystem", "LXC_HostSystem", + "Linux_ComputerSystem", NULL };

Dan Smith wrote:
# HG changeset patch # User Dan Smith <danms@us.ibm.com> # Date 1225739071 28800 # Node ID 44b096b7f0a02506efef9091854e182daf4bc812 # Parent 7e9da8337ee60e6c73f020e37d22d692c0c7d494 Make HostedResourcePool work from root/cimv2 and register it there ...so we can get back from HostSystem to our pools.
Signed-off-by: Dan Smith <danms@us.ibm.com>
diff -r 7e9da8337ee6 -r 44b096b7f0a0 Makefile.am
I see the following error after postinstall: Parsing error: parse error: Error adding class Xen_HostedResourcePool to the repository: CIM_ERR_INVALID_SUPERCLASS: CIM_HostedResourcePool If you just have sblim-cmpi-base installed, HRP isn't registered to cimv2. So you'll probably need to add that to the list of classes that get installed during make preinstall. -- Kaitlin Rupert IBM Linux Technology Center kaitlin@linux.vnet.ibm.com

KR> If you just have sblim-cmpi-base installed, HRP isn't registered to KR> cimv2. So you'll probably need to add that to the list of classes KR> that get installed during make preinstall. Yep, and I did. If you re-run preinstall you should be good. -- Dan Smith IBM Linux Technology Center Open Hypervisor Team email: danms@us.ibm.com

# HG changeset patch # User Dan Smith <danms@us.ibm.com> # Date 1225741851 28800 # Node ID adc1744e281a77c4e8a0ee7726b42af035b7656b # Parent 44b096b7f0a02506efef9091854e182daf4bc812 Make ElementCapabilities work from root/cimv2 and register it there ...so we can get back from HostSystem to our Capabilities Signed-off-by: Dan Smith <danms@us.ibm.com> diff -r 44b096b7f0a0 -r adc1744e281a Makefile.am --- a/Makefile.am Mon Nov 03 11:04:31 2008 -0800 +++ b/Makefile.am Mon Nov 03 11:50:51 2008 -0800 @@ -62,7 +62,8 @@ schema/ReferencedProfile.mof CIMV2_MOFS = \ - schema/HostedResourcePool.mof + schema/HostedResourcePool.mof \ + schema/ElementCapabilities.mof REGS = \ schema/ComputerSystem.registration \ @@ -115,7 +116,8 @@ schema/ReferencedProfile.registration CIMV2_REGS = \ - schema/HostedResourcePool.registration + schema/HostedResourcePool.registration \ + schema/ElementCapabilities.registration pkgdata_DATA = $(MOFS) $(REGS) $(INTEROP_MOFS) $(INTEROP_REGS) pkgdata_SCRIPTS = provider-register.sh diff -r 44b096b7f0a0 -r adc1744e281a schema/ElementCapabilities.registration --- a/schema/ElementCapabilities.registration Mon Nov 03 11:04:31 2008 -0800 +++ b/schema/ElementCapabilities.registration Mon Nov 03 11:50:51 2008 -0800 @@ -3,3 +3,6 @@ Xen_ElementCapabilities root/virt Virt_ElementCapabilities Virt_ElementCapabilities association KVM_ElementCapabilities root/virt Virt_ElementCapabilities Virt_ElementCapabilities association LXC_ElementCapabilities root/virt Virt_ElementCapabilities Virt_ElementCapabilities association +Xen_ElementCapabilities root/cimv2 Virt_ElementCapabilities Virt_ElementCapabilities association +KVM_ElementCapabilities root/cimv2 Virt_ElementCapabilities Virt_ElementCapabilities association +LXC_ElementCapabilities root/cimv2 Virt_ElementCapabilities Virt_ElementCapabilities association diff -r 44b096b7f0a0 -r adc1744e281a src/Virt_ElementCapabilities.c --- a/src/Virt_ElementCapabilities.c Mon Nov 03 11:04:31 2008 -0800 +++ b/src/Virt_ElementCapabilities.c Mon Nov 03 11:50:51 2008 -0800 @@ -146,27 +146,33 @@ { CMPIInstance *inst = NULL; CMPIStatus s = {CMPI_RC_OK, NULL}; + CMPIObjectPath *vref = NULL; - if (!match_hypervisor_prefix(ref, info)) + if (!STARTS_WITH(CLASSNAME(ref), "Linux_") && + !match_hypervisor_prefix(ref, info)) goto out; s = get_host(_BROKER, info->context, ref, &inst, true); if (s.rc != CMPI_RC_OK) goto out; - s = get_vsm_cap(_BROKER, ref, &inst, false); + vref = convert_sblim_hostsystem(_BROKER, ref, info); + if (vref == NULL) + goto out; + + s = get_vsm_cap(_BROKER, vref, &inst, false); if (s.rc == CMPI_RC_OK) inst_list_add(list, inst); - s = get_migration_caps(ref, &inst, _BROKER, false); + s = get_migration_caps(vref, &inst, _BROKER, false); if (s.rc == CMPI_RC_OK) inst_list_add(list, inst); - s = get_console_rs_caps(_BROKER, ref, &inst, false); + s = get_console_rs_caps(_BROKER, vref, &inst, false); if (s.rc == CMPI_RC_OK) inst_list_add(list, inst); - s = enum_alloc_cap_instances(_BROKER, ref, NULL, NULL, list); + s = enum_alloc_cap_instances(_BROKER, vref, NULL, NULL, list); if (s.rc != CMPI_RC_OK) { CU_DEBUG("Failed to enum AC: %s", CMGetCharPtr(s.msg)); @@ -393,6 +399,7 @@ "Xen_HostSystem", "KVM_HostSystem", "LXC_HostSystem", + "Linux_ComputerSystem", NULL }; @@ -409,6 +416,7 @@ "LXC_VirtualSystemManagementService", "LXC_VirtualSystemMigrationService", "LXC_ConsoleRedirectionService", + "Linux_ComputerSystem", NULL };

# HG changeset patch # User Dan Smith <danms@us.ibm.com> # Date 1225741860 28800 # Node ID 75e2ff1a50ea0bc13256fae712e6a96aba024d80 # Parent adc1744e281a77c4e8a0ee7726b42af035b7656b Make HostedService work from root/cimv2 and register it there ...so we can get back from HostSystem to our Services. Signed-off-by: Dan Smith <danms@us.ibm.com> diff -r adc1744e281a -r 75e2ff1a50ea Makefile.am --- a/Makefile.am Mon Nov 03 11:50:51 2008 -0800 +++ b/Makefile.am Mon Nov 03 11:51:00 2008 -0800 @@ -63,7 +63,8 @@ CIMV2_MOFS = \ schema/HostedResourcePool.mof \ - schema/ElementCapabilities.mof + schema/ElementCapabilities.mof \ + schema/HostedService.mof REGS = \ schema/ComputerSystem.registration \ @@ -117,7 +118,8 @@ CIMV2_REGS = \ schema/HostedResourcePool.registration \ - schema/ElementCapabilities.registration + schema/ElementCapabilities.registration \ + schema/HostedService.registration pkgdata_DATA = $(MOFS) $(REGS) $(INTEROP_MOFS) $(INTEROP_REGS) pkgdata_SCRIPTS = provider-register.sh diff -r adc1744e281a -r 75e2ff1a50ea schema/HostedService.registration --- a/schema/HostedService.registration Mon Nov 03 11:50:51 2008 -0800 +++ b/schema/HostedService.registration Mon Nov 03 11:51:00 2008 -0800 @@ -3,3 +3,6 @@ Xen_HostedService root/virt Virt_HostedService Virt_HostedService association KVM_HostedService root/virt Virt_HostedService Virt_HostedService association LXC_HostedService root/virt Virt_HostedService Virt_HostedService association +Xen_HostedService root/cimv2 Virt_HostedService Virt_HostedService association +KVM_HostedService root/cimv2 Virt_HostedService Virt_HostedService association +LXC_HostedService root/cimv2 Virt_HostedService Virt_HostedService association diff -r adc1744e281a -r 75e2ff1a50ea src/Virt_HostedService.c --- a/src/Virt_HostedService.c Mon Nov 03 11:50:51 2008 -0800 +++ b/src/Virt_HostedService.c Mon Nov 03 11:51:00 2008 -0800 @@ -89,38 +89,44 @@ { CMPIStatus s = {CMPI_RC_OK, NULL}; CMPIInstance *inst = NULL; + CMPIObjectPath *vref = NULL; - if (!match_hypervisor_prefix(ref, info)) + if (!STARTS_WITH(CLASSNAME(ref), "Linux_") && + !match_hypervisor_prefix(ref, info)) return s; s = get_host(_BROKER, info->context, ref, &inst, true); if (s.rc != CMPI_RC_OK) return s; - s = get_rpcs(ref, &inst, _BROKER, info->context, false); + vref = convert_sblim_hostsystem(_BROKER, ref, info); + if (vref == NULL) + goto out; + + s = get_rpcs(vref, &inst, _BROKER, info->context, false); if (s.rc != CMPI_RC_OK) return s; if (!CMIsNullObject(inst)) inst_list_add(list, inst); - s = get_vsms(ref, &inst, _BROKER, info->context, false); + s = get_vsms(vref, &inst, _BROKER, info->context, false); if (s.rc != CMPI_RC_OK) return s; if (!CMIsNullObject(inst)) inst_list_add(list, inst); - s = get_migration_service(ref, &inst, _BROKER, info->context, false); + s = get_migration_service(vref, &inst, _BROKER, info->context, false); if (s.rc != CMPI_RC_OK) return s; if (!CMIsNullObject(inst)) inst_list_add(list, inst); - s = get_console_rs(ref, &inst, _BROKER, info->context, false); + s = get_console_rs(vref, &inst, _BROKER, info->context, false); if (s.rc != CMPI_RC_OK) return s; if (!CMIsNullObject(inst)) inst_list_add(list, inst); - + out: return s; } @@ -130,6 +136,7 @@ "Xen_HostSystem", "KVM_HostSystem", "LXC_HostSystem", + "Linux_ComputerSystem", NULL };

# HG changeset patch # User Dan Smith <danms@us.ibm.com> # Date 1225741865 28800 # Node ID a154c8327a1217cb27339059600f0bcf7347ecd5 # Parent 75e2ff1a50ea0bc13256fae712e6a96aba024d80 Make HostedDependency work from root/cimv2 and register it there ...so we can get back from HostSystem to our ComputerSystems Signed-off-by: Dan Smith <danms@us.ibm.com> diff -r 75e2ff1a50ea -r a154c8327a12 Makefile.am --- a/Makefile.am Mon Nov 03 11:51:00 2008 -0800 +++ b/Makefile.am Mon Nov 03 11:51:05 2008 -0800 @@ -64,7 +64,8 @@ CIMV2_MOFS = \ schema/HostedResourcePool.mof \ schema/ElementCapabilities.mof \ - schema/HostedService.mof + schema/HostedService.mof \ + schema/HostedDependency.mof REGS = \ schema/ComputerSystem.registration \ @@ -119,7 +120,8 @@ CIMV2_REGS = \ schema/HostedResourcePool.registration \ schema/ElementCapabilities.registration \ - schema/HostedService.registration + schema/HostedService.registration \ + schema/HostedDependency.registration pkgdata_DATA = $(MOFS) $(REGS) $(INTEROP_MOFS) $(INTEROP_REGS) pkgdata_SCRIPTS = provider-register.sh diff -r 75e2ff1a50ea -r a154c8327a12 schema/HostedDependency.registration --- a/schema/HostedDependency.registration Mon Nov 03 11:51:00 2008 -0800 +++ b/schema/HostedDependency.registration Mon Nov 03 11:51:05 2008 -0800 @@ -3,3 +3,6 @@ Xen_HostedDependency root/virt Virt_HostedDependency Virt_HostedDependency association KVM_HostedDependency root/virt Virt_HostedDependency Virt_HostedDependency association LXC_HostedDependency root/virt Virt_HostedDependency Virt_HostedDependency association +Xen_HostedDependency root/cimv2 Virt_HostedDependency Virt_HostedDependency association +KVM_HostedDependency root/cimv2 Virt_HostedDependency Virt_HostedDependency association +LXC_HostedDependency root/cimv2 Virt_HostedDependency Virt_HostedDependency association diff -r 75e2ff1a50ea -r a154c8327a12 src/Virt_HostedDependency.c --- a/src/Virt_HostedDependency.c Mon Nov 03 11:51:00 2008 -0800 +++ b/src/Virt_HostedDependency.c Mon Nov 03 11:51:05 2008 -0800 @@ -64,15 +64,21 @@ { CMPIStatus s = {CMPI_RC_OK, NULL}; CMPIInstance *instance = NULL; + CMPIObjectPath *vref = NULL; - if (!match_hypervisor_prefix(ref, info)) + if (!STARTS_WITH(CLASSNAME(ref), "Linux_") && + !match_hypervisor_prefix(ref, info)) goto out; s = get_host(_BROKER, info->context, ref, &instance, true); if (s.rc != CMPI_RC_OK) goto out; - s = enum_domains(_BROKER, ref, list); + vref = convert_sblim_hostsystem(_BROKER, ref, info); + if (vref == NULL) + goto out; + + s = enum_domains(_BROKER, vref, list); out: return s; @@ -91,6 +97,7 @@ "Xen_HostSystem", "KVM_HostSystem", "LXC_HostSystem", + "Linux_ComputerSystem", NULL };

Dan Smith wrote:
This patch set attempts to patch up our associations for the case where the SBLIM providers are installed and we use them for our HostSystem class. Since that class exists in root/cimv2, we have to register our associations there as well, and make sure they provide paths back to the rest of our providers.
The convert_sblim_hostsystem() function that I use to do this is a bit of a hack, given that it requires knowledge of how the reference we're passing to all of our factory functions is used. However, I think it's definitely the easiest thing to do right now.
Comments are welcome as usual :)
I think this is a reasonable enough away to handle the cross-namespace issue. We make the same kind of assumptions about the reference elsewhere in the code. So if this ever changes in the future, this will just be one of many changes that'll need to be made changed. Is there any need to update ECTP as well? -- Kaitlin Rupert IBM Linux Technology Center kaitlin@linux.vnet.ibm.com

KR> Is there any need to update ECTP as well? ECTP should work for the profile->hostsys direction now, but if you want to make it back from hostsys->profile, I guess we do need a change. -- Dan Smith IBM Linux Technology Center Open Hypervisor Team email: danms@us.ibm.com
participants (2)
-
Dan Smith
-
Kaitlin Rupert