[PATCH 0 of 3] Transition back to connect_by_classname()

A more formal version of the last set, this time as a proposed change instead of an RFC. Some testing of the first patch would be good to make sure that I didn't change a provider name to be incongruent with what is in the registration files.

# HG changeset patch # User Dan Smith <danms@us.ibm.com> # Date 1195244693 28800 # Node ID f6c11dd07703ae3f398592143b4fd31fc78f3a5d # Parent bb9245e8f41c56ced574551677534f24071fa48d Initialize libvirt at provider load This defines a function in the utility librart that does the libvirt initialization, and could be extended to do anything else we need in the future. This replaces CMNoHook in all of the providers with a call to this function. This fixes the errant behavior we see with parallel calls to connect_by_classname(). This behavior was certainly possible with lv_connect(), but I imagine we were getting lucky most of the time. Also in this patch is a change to all non-association providers to use a #define for the provider name to avoid duplication and improve readability. I figured I'd make this cleanup while I was touching every MIStub in the tree. As a part of this, I fixed the provider name of VSMS, which means there is an associated schema change. Signed-off-by: Dan Smith <danms@us.ibm.com> diff -r bb9245e8f41c -r f6c11dd07703 libxkutil/misc_util.c --- a/libxkutil/misc_util.c Fri Nov 16 10:22:13 2007 -0800 +++ b/libxkutil/misc_util.c Fri Nov 16 12:24:53 2007 -0800 @@ -421,6 +421,11 @@ bool parse_instanceid(const CMPIObjectPa return true; } +bool libvirt_cim_init(void) +{ + return virInitialize == 0; +} + /* * Local Variables: * mode: C diff -r bb9245e8f41c -r f6c11dd07703 libxkutil/misc_util.h --- a/libxkutil/misc_util.h Fri Nov 16 10:22:13 2007 -0800 +++ b/libxkutil/misc_util.h Fri Nov 16 12:24:53 2007 -0800 @@ -92,6 +92,8 @@ int parse_id(char *id, char **pfx, char int parse_id(char *id, char **pfx, char **name); bool parse_instanceid(const CMPIObjectPath *ref, char **pfx, char **name); +bool libvirt_cim_init(void); + #define ASSOC_MATCH(pn, cn) \ if (!match_pn_to_cn((pn), (cn))) { \ return (CMPIStatus){CMPI_RC_OK, NULL}; \ diff -r bb9245e8f41c -r f6c11dd07703 schema/VirtualSystemManagementService.registration --- a/schema/VirtualSystemManagementService.registration Fri Nov 16 10:22:13 2007 -0800 +++ b/schema/VirtualSystemManagementService.registration Fri Nov 16 12:24:53 2007 -0800 @@ -1,4 +1,4 @@ # Copyright IBM Corp. 2007 # Classname Namespace ProviderName ProviderModule ProviderTypes -Xen_VirtualSystemManagementService root/virt Virt_VirtualSystemManagementService Virt_VirtualSystemManagementService method instance -KVM_VirtualSystemManagementService root/virt Virt_VirtualSystemManagementService Virt_VirtualSystemManagementService method instance +Xen_VirtualSystemManagementService root/virt Virt_VirtualSystemManagementServiceProvider Virt_VirtualSystemManagementService method instance +KVM_VirtualSystemManagementService root/virt Virt_VirtualSystemManagementServiceProvider Virt_VirtualSystemManagementService method instance diff -r bb9245e8f41c -r f6c11dd07703 src/Virt_AllocationCapabilities.c --- a/src/Virt_AllocationCapabilities.c Fri Nov 16 10:22:13 2007 -0800 +++ b/src/Virt_AllocationCapabilities.c Fri Nov 16 12:24:53 2007 -0800 @@ -30,6 +30,8 @@ #include "Virt_AllocationCapabilities.h" #include "Virt_RASD.h" + +#define PN Virt_AllocationCapabilitiesProvider const static CMPIBroker *_BROKER; @@ -103,12 +105,11 @@ DEFAULT_INST_CLEANUP(); /* Avoid a warning in the stub macro below */ CMPIInstanceMI * -Virt_AllocationCapabilitiesProvider_Create_InstanceMI(const CMPIBroker *, - const CMPIContext *, - CMPIStatus *rc); +PN_Create_InstanceMI(const CMPIBroker *, + const CMPIContext *, + CMPIStatus *rc); -CMInstanceMIStub(, Virt_AllocationCapabilitiesProvider, _BROKER, - CMNoHook); +CMInstanceMIStub(, PN, _BROKER, libvirt_cim_init()); /* * Local Variables: diff -r bb9245e8f41c -r f6c11dd07703 src/Virt_ComputerSystem.c --- a/src/Virt_ComputerSystem.c Fri Nov 16 10:22:13 2007 -0800 +++ b/src/Virt_ComputerSystem.c Fri Nov 16 12:24:53 2007 -0800 @@ -37,6 +37,8 @@ #include "Virt_ComputerSystem.h" +#define PN Virt_ComputerSystemProvider + const static CMPIBroker *_BROKER; enum CIM_state { @@ -684,11 +686,11 @@ static CMPIStatus state_change(CMPIMetho /* Avoid a warning in the stub macro below */ CMPIInstanceMI * -Virt_ComputerSystemProvider_Create_InstanceMI(const CMPIBroker *, +PN_Create_InstanceMI(const CMPIBroker *, const CMPIContext *, CMPIStatus *rc); -CMInstanceMIStub(, Virt_ComputerSystemProvider, _BROKER, CMNoHook); +CMInstanceMIStub(, PN, _BROKER, libvirt_cim_init()); static struct method_handler RequestStateChange = { .name = "RequestStateChange", @@ -704,11 +706,7 @@ static struct method_handler *my_handler NULL }; -STDIM_MethodMIStub(, - Virt_ComputerSystemProvider, - _BROKER, - CMNoHook, - my_handlers); +STDIM_MethodMIStub(, PN, _BROKER, libvirt_cim_init(), my_handlers); /* * Local Variables: diff -r bb9245e8f41c -r f6c11dd07703 src/Virt_Device.c --- a/src/Virt_Device.c Fri Nov 16 10:22:13 2007 -0800 +++ b/src/Virt_Device.c Fri Nov 16 12:24:53 2007 -0800 @@ -36,6 +36,8 @@ #include "Virt_Device.h" +#define PN Virt_DeviceProvider + #define CIM_NET_UNKNOWN 0 #define CIM_NET_ETHERNET 2 @@ -533,11 +535,11 @@ DEFAULT_INST_CLEANUP(); /* Avoid a warning in the stub macro below */ CMPIInstanceMI * -Virt_DeviceProvider_Create_InstanceMI(const CMPIBroker *, - const CMPIContext *, - CMPIStatus *rc); - -CMInstanceMIStub(, Virt_DeviceProvider, _BROKER, CMNoHook); +PN_Create_InstanceMI(const CMPIBroker *, + const CMPIContext *, + CMPIStatus *rc); + +CMInstanceMIStub(, PN, _BROKER, libvirt_cim_init()); /* * Local Variables: diff -r bb9245e8f41c -r f6c11dd07703 src/Virt_DevicePool.c --- a/src/Virt_DevicePool.c Fri Nov 16 10:22:13 2007 -0800 +++ b/src/Virt_DevicePool.c Fri Nov 16 12:24:53 2007 -0800 @@ -43,6 +43,8 @@ #include "Virt_DevicePool.h" #include "svpc_types.h" +#define PN Virt_DevicePoolProvider + static const CMPIBroker *_BROKER; char *device_pool_names[] = {"ProcessorPool", @@ -720,11 +722,11 @@ DEFAULT_INST_CLEANUP(); /* Avoid a warning in the stub macro below */ CMPIInstanceMI * -Virt_DevicePoolProvider_Create_InstanceMI(const CMPIBroker *, - const CMPIContext *, - CMPIStatus *rc); - -CMInstanceMIStub(, Virt_DevicePoolProvider, _BROKER, CMNoHook); +PN_Create_InstanceMI(const CMPIBroker *, + const CMPIContext *, + CMPIStatus *rc); + +CMInstanceMIStub(, PN, _BROKER, libvirt_cim_init()); /* diff -r bb9245e8f41c -r f6c11dd07703 src/Virt_ElementAllocatedFromPool.c --- a/src/Virt_ElementAllocatedFromPool.c Fri Nov 16 10:22:13 2007 -0800 +++ b/src/Virt_ElementAllocatedFromPool.c Fri Nov 16 12:24:53 2007 -0800 @@ -292,8 +292,8 @@ static struct std_assoc *handlers[] = { NULL }; -STDA_AssocMIStub(, Xen_ElementAllocatedFromPoolProvider, _BROKER, CMNoHook, handlers); -STDA_AssocMIStub(, KVM_ElementAllocatedFromPoolProvider, _BROKER, CMNoHook, handlers); +STDA_AssocMIStub(, Xen_ElementAllocatedFromPoolProvider, _BROKER, libvirt_cim_init(), handlers); +STDA_AssocMIStub(, KVM_ElementAllocatedFromPoolProvider, _BROKER, libvirt_cim_init(), handlers); /* * Local Variables: diff -r bb9245e8f41c -r f6c11dd07703 src/Virt_ElementCapabilities.c --- a/src/Virt_ElementCapabilities.c Fri Nov 16 10:22:13 2007 -0800 +++ b/src/Virt_ElementCapabilities.c Fri Nov 16 12:24:53 2007 -0800 @@ -358,8 +358,8 @@ struct std_assoc *assoc_handlers[] = { }; -STDA_AssocMIStub(, Xen_ElementCapabilitiesProvider, _BROKER, CMNoHook, assoc_handlers); -STDA_AssocMIStub(, KVM_ElementCapabilitiesProvider, _BROKER, CMNoHook, assoc_handlers); +STDA_AssocMIStub(, Xen_ElementCapabilitiesProvider, _BROKER, libvirt_cim_init(), assoc_handlers); +STDA_AssocMIStub(, KVM_ElementCapabilitiesProvider, _BROKER, libvirt_cim_init(), assoc_handlers); /* * Local Variables: * mode: C diff -r bb9245e8f41c -r f6c11dd07703 src/Virt_ElementConformsToProfile.c --- a/src/Virt_ElementConformsToProfile.c Fri Nov 16 10:22:13 2007 -0800 +++ b/src/Virt_ElementConformsToProfile.c Fri Nov 16 12:24:53 2007 -0800 @@ -225,7 +225,7 @@ struct std_assoc *assoc_handlers[] = { }; -STDA_AssocMIStub(, Virt_ElementConformsToProfileProvider, _BROKER, CMNoHook, assoc_handlers); +STDA_AssocMIStub(, Virt_ElementConformsToProfileProvider, _BROKER, libvirt_cim_init(), assoc_handlers); /* * Local Variables: * mode: C diff -r bb9245e8f41c -r f6c11dd07703 src/Virt_ElementSettingData.c --- a/src/Virt_ElementSettingData.c Fri Nov 16 10:22:13 2007 -0800 +++ b/src/Virt_ElementSettingData.c Fri Nov 16 12:24:53 2007 -0800 @@ -147,8 +147,8 @@ static struct std_assoc *handlers[] = { NULL }; -STDA_AssocMIStub(, Xen_ElementSettingDataProvider, _BROKER, CMNoHook, handlers); -STDA_AssocMIStub(, KVM_ElementSettingDataProvider, _BROKER, CMNoHook, handlers); +STDA_AssocMIStub(, Xen_ElementSettingDataProvider, _BROKER, libvirt_cim_init(), handlers); +STDA_AssocMIStub(, KVM_ElementSettingDataProvider, _BROKER, libvirt_cim_init(), handlers); /* * Local Variables: diff -r bb9245e8f41c -r f6c11dd07703 src/Virt_EnabledLogicalElementCapabilities.c --- a/src/Virt_EnabledLogicalElementCapabilities.c Fri Nov 16 10:22:13 2007 -0800 +++ b/src/Virt_EnabledLogicalElementCapabilities.c Fri Nov 16 12:24:53 2007 -0800 @@ -31,6 +31,8 @@ #include "device_parsing.h" #include "Virt_EnabledLogicalElementCapabilities.h" + +#define PN Virt_EnabledLogicalElementCapabilities const static CMPIBroker *_BROKER; @@ -203,12 +205,11 @@ DEFAULT_INST_CLEANUP(); /* Avoid a warning in the stub macro below */ CMPIInstanceMI * -Virt_EnabledLogicalElementCapabilitiesProvider_Create_InstanceMI(const CMPIBroker *, - const CMPIContext *, - CMPIStatus *rc); - -CMInstanceMIStub(, Virt_EnabledLogicalElementCapabilitiesProvider, _BROKER, - CMNoHook); +PN_Create_InstanceMI(const CMPIBroker *, + const CMPIContext *, + CMPIStatus *rc); + +CMInstanceMIStub(, PN, _BROKER, libvirt_cim_init()); /* * Local Variables: diff -r bb9245e8f41c -r f6c11dd07703 src/Virt_HostSystem.c --- a/src/Virt_HostSystem.c Fri Nov 16 10:22:13 2007 -0800 +++ b/src/Virt_HostSystem.c Fri Nov 16 12:24:53 2007 -0800 @@ -31,6 +31,8 @@ #include "misc_util.h" #include "Virt_HostSystem.h" + +#define PN Virt_HostSystem const static CMPIBroker *_BROKER; @@ -157,11 +159,11 @@ DEFAULT_INST_CLEANUP(); /* Avoid a warning in the stub macro below */ CMPIInstanceMI * -Virt_HostSystemProvider_Create_InstanceMI(const CMPIBroker *, - const CMPIContext *, - CMPIStatus *rc); +PN_Create_InstanceMI(const CMPIBroker *, + const CMPIContext *, + CMPIStatus *rc); -CMInstanceMIStub(, Virt_HostSystemProvider, _BROKER, CMNoHook); +CMInstanceMIStub(, PN, _BROKER, libvirt_cim_init()); /* * Local Variables: diff -r bb9245e8f41c -r f6c11dd07703 src/Virt_HostedDependency.c --- a/src/Virt_HostedDependency.c Fri Nov 16 10:22:13 2007 -0800 +++ b/src/Virt_HostedDependency.c Fri Nov 16 12:24:53 2007 -0800 @@ -150,7 +150,7 @@ static struct std_assoc *handlers[] = { NULL }; -STDA_AssocMIStub(, Virt_HostedDependencyProvider, _BROKER, CMNoHook, handlers); +STDA_AssocMIStub(, Virt_HostedDependencyProvider, _BROKER, libvirt_cim_init(), handlers); /* * Local Variables: diff -r bb9245e8f41c -r f6c11dd07703 src/Virt_HostedResourcePool.c --- a/src/Virt_HostedResourcePool.c Fri Nov 16 10:22:13 2007 -0800 +++ b/src/Virt_HostedResourcePool.c Fri Nov 16 12:24:53 2007 -0800 @@ -151,7 +151,7 @@ struct std_assoc *assoc_handlers[] = { }; -STDA_AssocMIStub(, Virt_HostedResourcePoolProvider, _BROKER, CMNoHook, assoc_handlers); +STDA_AssocMIStub(, Virt_HostedResourcePoolProvider, _BROKER, libvirt_cim_init(), assoc_handlers); /* * Local Variables: diff -r bb9245e8f41c -r f6c11dd07703 src/Virt_HostedService.c --- a/src/Virt_HostedService.c Fri Nov 16 10:22:13 2007 -0800 +++ b/src/Virt_HostedService.c Fri Nov 16 12:24:53 2007 -0800 @@ -160,8 +160,8 @@ static struct std_assoc *handlers[] = { NULL }; -STDA_AssocMIStub(, Xen_HostedServiceProvider, _BROKER, CMNoHook, handlers); -STDA_AssocMIStub(, KVM_HostedServiceProvider, _BROKER, CMNoHook, handlers); +STDA_AssocMIStub(, Xen_HostedServiceProvider, _BROKER, libvirt_cim_init(), handlers); +STDA_AssocMIStub(, KVM_HostedServiceProvider, _BROKER, libvirt_cim_init(), handlers); /* * Local Variables: diff -r bb9245e8f41c -r f6c11dd07703 src/Virt_RASD.c --- a/src/Virt_RASD.c Fri Nov 16 10:22:13 2007 -0800 +++ b/src/Virt_RASD.c Fri Nov 16 12:24:53 2007 -0800 @@ -34,6 +34,8 @@ #include "Virt_RASD.h" #include "svpc_types.h" + +#define PN Virt_RASDProvider const static CMPIBroker *_BROKER; @@ -315,11 +317,11 @@ DEFAULT_EQ(); /* Avoid a warning in the stub macro below */ CMPIInstanceMI * -Virt_RASDProvider_Create_InstanceMI(const CMPIBroker *, - const CMPIContext *, - CMPIStatus *rc); - -CMInstanceMIStub(, Virt_RASDProvider, _BROKER, CMNoHook); +PN_Create_InstanceMI(const CMPIBroker *, + const CMPIContext *, + CMPIStatus *rc); + +CMInstanceMIStub(, PN, _BROKER, libvirt_cim_init()); /* * Local Variables: diff -r bb9245e8f41c -r f6c11dd07703 src/Virt_RegisteredProfile.c --- a/src/Virt_RegisteredProfile.c Fri Nov 16 10:22:13 2007 -0800 +++ b/src/Virt_RegisteredProfile.c Fri Nov 16 12:24:53 2007 -0800 @@ -35,6 +35,8 @@ #include "profiles.h" #include "Virt_RegisteredProfile.h" + +#define PN Virt_RegisteredProfileProvider const static CMPIBroker *_BROKER; @@ -188,11 +190,11 @@ DEFAULT_INST_CLEANUP(); /* Avoid a warning in the stub macro below */ CMPIInstanceMI * -Virt_RegisteredProfileProvider_Create_InstanceMI(const CMPIBroker *, - const CMPIContext *, - CMPIStatus *rc); - -CMInstanceMIStub(, Virt_RegisteredProfileProvider, _BROKER, CMNoHook); +PN_Create_InstanceMI(const CMPIBroker *, + const CMPIContext *, + CMPIStatus *rc); + +CMInstanceMIStub(, PN, _BROKER, libvirt_cim_init()); /* * Local Variables: diff -r bb9245e8f41c -r f6c11dd07703 src/Virt_ResourceAllocationFromPool.c --- a/src/Virt_ResourceAllocationFromPool.c Fri Nov 16 10:22:13 2007 -0800 +++ b/src/Virt_ResourceAllocationFromPool.c Fri Nov 16 12:24:53 2007 -0800 @@ -277,8 +277,8 @@ static struct std_assoc *handlers[] = { NULL }; -STDA_AssocMIStub(, Xen_ResourceAllocationFromPoolProvider, _BROKER, CMNoHook, handlers); -STDA_AssocMIStub(, KVM_ResourceAllocationFromPoolProvider, _BROKER, CMNoHook, handlers); +STDA_AssocMIStub(, Xen_ResourceAllocationFromPoolProvider, _BROKER, libvirt_cim_init(), handlers); +STDA_AssocMIStub(, KVM_ResourceAllocationFromPoolProvider, _BROKER, libvirt_cim_init(), handlers); /* * Local Variables: diff -r bb9245e8f41c -r f6c11dd07703 src/Virt_ResourcePoolConfigurationCapabilities.c --- a/src/Virt_ResourcePoolConfigurationCapabilities.c Fri Nov 16 10:22:13 2007 -0800 +++ b/src/Virt_ResourcePoolConfigurationCapabilities.c Fri Nov 16 12:24:53 2007 -0800 @@ -29,6 +29,8 @@ #include "libcmpiutil.h" #include "misc_util.h" +#define PN Virt_ResourcePoolConfigurationCapabilitiesProvider + const static CMPIBroker *_BROKER; enum {CreateResourcePool = 2, @@ -38,6 +40,7 @@ enum {CreateResourcePool = RemoveResourcesFromResourcePool = 6, ChangeParentResourcePool = 7, }; + DEFAULT_CI(); DEFAULT_MI(); @@ -114,12 +117,11 @@ static CMPIStatus GetInstance(CMPIInstan /* Avoid a warning in the stub macro below */ CMPIInstanceMI * -Virt_ResourcePoolConfigurationCapabilitiesProvider_Create_InstanceMI(const CMPIBroker *, - const CMPIContext *, - CMPIStatus *rc); +PN_Create_InstanceMI(const CMPIBroker *, + const CMPIContext *, + CMPIStatus *rc); -CMInstanceMIStub(, Virt_ResourcePoolConfigurationCapabilitiesProvider, _BROKER, - CMNoHook); +CMInstanceMIStub(, PN, _BROKER, libvirt_cim_init()); /* * Local Variables: diff -r bb9245e8f41c -r f6c11dd07703 src/Virt_ResourcePoolConfigurationService.c --- a/src/Virt_ResourcePoolConfigurationService.c Fri Nov 16 10:22:13 2007 -0800 +++ b/src/Virt_ResourcePoolConfigurationService.c Fri Nov 16 12:24:53 2007 -0800 @@ -30,6 +30,8 @@ #include "Virt_HostSystem.h" #include "Virt_ResourcePoolConfigurationService.h" +#define PN Virt_ResourcePoolConfigurationServiceProvider + const static CMPIBroker *_BROKER; static CMPIStatus dummy_handler(CMPIMethodMI *self, @@ -81,8 +83,7 @@ static struct method_handler *my_handler NULL, }; -STDIM_MethodMIStub(, Virt_ResourcePoolConfigurationServiceProvider, - _BROKER, CMNoHook, my_handlers); +STDIM_MethodMIStub(, PN, _BROKER, libvirt_cim_init(), my_handlers); DEFAULT_CI(); DEFAULT_MI(); @@ -204,12 +205,11 @@ static CMPIStatus EnumInstances(CMPIInst CMPIInstanceMI * -Virt_ResourcePoolConfigurationServiceProvider_Create_InstanceMI(const CMPIBroker *, - const CMPIContext *, - CMPIStatus *rc); - -CMInstanceMIStub(, Virt_ResourcePoolConfigurationServiceProvider, - _BROKER, CMNoHook); +PN_Create_InstanceMI(const CMPIBroker *, + const CMPIContext *, + CMPIStatus *rc); + +CMInstanceMIStub(, PN, _BROKER, libvirt_cim_init()); /* diff -r bb9245e8f41c -r f6c11dd07703 src/Virt_SettingsDefineCapabilities.c --- a/src/Virt_SettingsDefineCapabilities.c Fri Nov 16 10:22:13 2007 -0800 +++ b/src/Virt_SettingsDefineCapabilities.c Fri Nov 16 12:24:53 2007 -0800 @@ -872,8 +872,8 @@ struct std_assoc *assoc_handlers[] = { }; -STDA_AssocMIStub(, Xen_SettingsDefineCapabilitiesProvider, _BROKER, CMNoHook, assoc_handlers); -STDA_AssocMIStub(, KVM_SettingsDefineCapabilitiesProvider, _BROKER, CMNoHook, assoc_handlers); +STDA_AssocMIStub(, Xen_SettingsDefineCapabilitiesProvider, _BROKER, libvirt_cim_init(), assoc_handlers); +STDA_AssocMIStub(, KVM_SettingsDefineCapabilitiesProvider, _BROKER, libvirt_cim_init(), assoc_handlers); /* * Local Variables: diff -r bb9245e8f41c -r f6c11dd07703 src/Virt_SettingsDefineState.c --- a/src/Virt_SettingsDefineState.c Fri Nov 16 10:22:13 2007 -0800 +++ b/src/Virt_SettingsDefineState.c Fri Nov 16 12:24:53 2007 -0800 @@ -365,8 +365,8 @@ static struct std_assoc *handlers[] = { NULL }; -STDA_AssocMIStub(, Xen_SettingsDefineStateProvider, _BROKER, CMNoHook, handlers); -STDA_AssocMIStub(, KVM_SettingsDefineStateProvider, _BROKER, CMNoHook, handlers); +STDA_AssocMIStub(, Xen_SettingsDefineStateProvider, _BROKER, libvirt_cim_init(), handlers); +STDA_AssocMIStub(, KVM_SettingsDefineStateProvider, _BROKER, libvirt_cim_init(), handlers); /* * Local Variables: diff -r bb9245e8f41c -r f6c11dd07703 src/Virt_SystemDevice.c --- a/src/Virt_SystemDevice.c Fri Nov 16 10:22:13 2007 -0800 +++ b/src/Virt_SystemDevice.c Fri Nov 16 12:24:53 2007 -0800 @@ -265,8 +265,8 @@ static struct std_assoc *assoc_handlers[ NULL }; -STDA_AssocMIStub(, Xen_SystemDeviceProvider, _BROKER, CMNoHook, assoc_handlers); -STDA_AssocMIStub(, KVM_SystemDeviceProvider, _BROKER, CMNoHook, assoc_handlers); +STDA_AssocMIStub(, Xen_SystemDeviceProvider, _BROKER, libvirt_cim_init(), assoc_handlers); +STDA_AssocMIStub(, KVM_SystemDeviceProvider, _BROKER, libvirt_cim_init(), assoc_handlers); /* * Local Variables: diff -r bb9245e8f41c -r f6c11dd07703 src/Virt_VSSD.c --- a/src/Virt_VSSD.c Fri Nov 16 10:22:13 2007 -0800 +++ b/src/Virt_VSSD.c Fri Nov 16 12:24:53 2007 -0800 @@ -34,6 +34,8 @@ #include "Virt_VSSD.h" +#define PN Virt_VSSDProvider + const static CMPIBroker *_BROKER; static int instance_from_dom(virDomainPtr dom, @@ -262,11 +264,11 @@ DEFAULT_INST_CLEANUP(); /* Avoid a warning in the stub macro below */ CMPIInstanceMI * -Virt_VSSDProvider_Create_InstanceMI(const CMPIBroker *, - const CMPIContext *, - CMPIStatus *rc); - -CMInstanceMIStub(, Virt_VSSDProvider, _BROKER, CMNoHook); +PN_Create_InstanceMI(const CMPIBroker *, + const CMPIContext *, + CMPIStatus *rc); + +CMInstanceMIStub(, PN, _BROKER, libvirt_cim_init()); /* * Local Variables: diff -r bb9245e8f41c -r f6c11dd07703 src/Virt_VSSDComponent.c --- a/src/Virt_VSSDComponent.c Fri Nov 16 10:22:13 2007 -0800 +++ b/src/Virt_VSSDComponent.c Fri Nov 16 12:24:53 2007 -0800 @@ -202,8 +202,8 @@ static struct std_assoc *handlers[] = { NULL }; -STDA_AssocMIStub(, Xen_VSSDComponentProvider, _BROKER, CMNoHook, handlers); -STDA_AssocMIStub(, KVM_VSSDComponentProvider, _BROKER, CMNoHook, handlers); +STDA_AssocMIStub(, Xen_VSSDComponentProvider, _BROKER, libvirt_cim_init(), handlers); +STDA_AssocMIStub(, KVM_VSSDComponentProvider, _BROKER, libvirt_cim_init(), handlers); /* * Local Variables: diff -r bb9245e8f41c -r f6c11dd07703 src/Virt_VirtualSystemManagementCapabilities.c --- a/src/Virt_VirtualSystemManagementCapabilities.c Fri Nov 16 10:22:13 2007 -0800 +++ b/src/Virt_VirtualSystemManagementCapabilities.c Fri Nov 16 12:24:53 2007 -0800 @@ -31,6 +31,8 @@ #include "device_parsing.h" #include "Virt_VirtualSystemManagementCapabilities.h" + +#define PN Virt_VirtualSystemManagementCapabilitiesProvider const static CMPIBroker *_BROKER; @@ -190,12 +192,11 @@ DEFAULT_INST_CLEANUP(); /* Avoid a warning in the stub macro below */ CMPIInstanceMI * -Virt_VirtualSystemManagementCapabilitiesProvider_Create_InstanceMI(const CMPIBroker *, - const CMPIContext *, - CMPIStatus *rc); - -CMInstanceMIStub(, Virt_VirtualSystemManagementCapabilitiesProvider, _BROKER, - CMNoHook); +PN_Create_InstanceMI(const CMPIBroker *, + const CMPIContext *, + CMPIStatus *rc); + +CMInstanceMIStub(, PN, _BROKER, libvirt_cim_init()); /* * Local Variables: diff -r bb9245e8f41c -r f6c11dd07703 src/Virt_VirtualSystemManagementService.c --- a/src/Virt_VirtualSystemManagementService.c Fri Nov 16 10:22:13 2007 -0800 +++ b/src/Virt_VirtualSystemManagementService.c Fri Nov 16 12:24:53 2007 -0800 @@ -48,6 +48,8 @@ #include "Virt_HostSystem.h" #include "svpc_types.h" +#define PN VirtualSystemManagementServiceProvider + const static CMPIBroker *_BROKER; enum ResourceAction { @@ -1019,8 +1021,7 @@ static struct method_handler *my_handler NULL, }; -STDIM_MethodMIStub(, Virt_VirtualSystemManagementService, - _BROKER, CMNoHook, my_handlers); +STDIM_MethodMIStub(, PN, _BROKER, libvirt_cim_init(), my_handlers); CMPIStatus get_vsms(const CMPIObjectPath *reference, CMPIInstance **_inst, @@ -1152,11 +1153,11 @@ DEFAULT_INST_CLEANUP(); /* Avoid a warning in the stub macro below */ CMPIInstanceMI * -Virt_VirtualSystemManagementService_Create_InstanceMI(const CMPIBroker *, - const CMPIContext *, - CMPIStatus *rc); - -CMInstanceMIStub(, Virt_VirtualSystemManagementService, _BROKER, CMNoHook); +PN_Create_InstanceMI(const CMPIBroker *, + const CMPIContext *, + CMPIStatus *rc); + +CMInstanceMIStub(, PN, _BROKER, libvirt_cim_init()); /*

Dan Smith wrote:
This defines a function in the utility librart that does the libvirt initialization, and could be extended to do anything else we need in the future. This replaces CMNoHook in all of the providers with a call to this function.
Great :).
Also in this patch is a change to all non-association providers to use a #define for the provider name to avoid duplication and improve readability. I figured I'd make this cleanup while I was touching every MIStub in the tree.
With sfcb and the #define approach the following error is thrown: *** Inconsistent provider registration for Virt_ComputerSystemProvider (2) This is caused by a non-resolved PN variable. PN is taken as "PN" and not resolved to the string as in the #define. +CMInstanceMIStub(, PN, _BROKER, libvirt_cim_init()); I do not have that many experiences with macros, but the PN approach did not work for me, no matter in how many different ways I tried it. PN was not resolved to the string defined at the beginning of the provider. So I had to switch back to -CMInstanceMIStub(, PN, _BROKER, libvirt_cim_init()); +CMInstanceMIStub(, Virt_ComputerSystemProvider, _BROKER, libvirt_cim_init()); Maybe someone else has some more experiences here and knows a solution ? On the other hand, I sent out a patch to libcmpiutil some minutes ago, which adds a STD_InstanceMIStub macro to libcmpiutil.h . This macro avoids now the warning in the original stub macro, which removes the responsibility from each provider to define it by itself. The patches below show the difference (first one is yours with PN approach, second one is removing the PN approach and using STD_InstanceMIStub macro). Now that you touched each MI stub, this might also be a good point in time to resolve this (now very old ;) ... sorry for my delay) problem.
diff -r bb9245e8f41c -r f6c11dd07703 src/Virt_ComputerSystem.c --- a/src/Virt_ComputerSystem.c Fri Nov 16 10:22:13 2007 -0800 +++ b/src/Virt_ComputerSystem.c Fri Nov 16 12:24:53 2007 -0800 @@ -37,6 +37,8 @@
#include "Virt_ComputerSystem.h"
+#define PN Virt_ComputerSystemProvider + const static CMPIBroker *_BROKER;
enum CIM_state { @@ -684,11 +686,11 @@ static CMPIStatus state_change(CMPIMetho
/* Avoid a warning in the stub macro below */ CMPIInstanceMI * -Virt_ComputerSystemProvider_Create_InstanceMI(const CMPIBroker *, +PN_Create_InstanceMI(const CMPIBroker *, const CMPIContext *, CMPIStatus *rc);
-CMInstanceMIStub(, Virt_ComputerSystemProvider, _BROKER, CMNoHook); +CMInstanceMIStub(, PN, _BROKER, libvirt_cim_init());
static struct method_handler RequestStateChange = { .name = "RequestStateChange", @@ -704,11 +706,7 @@ static struct method_handler *my_handler NULL };
-STDIM_MethodMIStub(, - Virt_ComputerSystemProvider, - _BROKER, - CMNoHook, - my_handlers); +STDIM_MethodMIStub(, PN, _BROKER, libvirt_cim_init(), my_handlers);
/* * Local Variables:
diff -r 599292e408aa src/Virt_ComputerSystem.c --- a/src/Virt_ComputerSystem.c Fri Nov 16 12:24:59 2007 -0800 +++ b/src/Virt_ComputerSystem.c Mon Nov 19 12:41:48 2007 +0100 @@ -37,8 +37,6 @@ #include "Virt_ComputerSystem.h" -#define PN Virt_ComputerSystemProvider - const static CMPIBroker *_BROKER; enum CIM_state { @@ -681,13 +679,7 @@ static CMPIStatus state_change(CMPIMetho return s; } -/* Avoid a warning in the stub macro below */ -CMPIInstanceMI * -PN_Create_InstanceMI(const CMPIBroker *, - const CMPIContext *, - CMPIStatus *rc); - -CMInstanceMIStub(, PN, _BROKER, libvirt_cim_init()); +STD_InstanceMIStub(, Virt_ComputerSystemProvider, _BROKER, libvirt_cim_init()); static struct method_handler RequestStateChange = { .name = "RequestStateChange", @@ -703,7 +695,7 @@ static struct method_handler *my_handler NULL }; -STDIM_MethodMIStub(, PN, _BROKER, libvirt_cim_init(), my_handlers); +STDIM_MethodMIStub(, Virt_ComputerSystemProvider, _BROKER, libvirt_cim_init(), my_handlers); /* * Local Variables: -- Regards Heidi Eckhart Software Engineer Linux Technology Center - Open Hypervisor heidieck@linux.vnet.ibm.com ************************************************** IBM Deutschland Entwicklung GmbH Vorsitzender des Aufsichtsrats: Martin Jetter Geschaeftsfuehrung: Herbert Kircher Sitz der Gesellschaft: Boeblingen Registergericht: Amtsgericht Stuttgart, HRB 243294

HE> This is caused by a non-resolved PN variable. PN is taken as "PN" HE> and not resolved to the string as in the #define. Yes, I just looked at the CPP output and I see that it's not correct. I have tried a bit, but I can't get the existing MIStub macros to behave like I want, since they assume that their "provider name" parameter is not a CPP macro :( ... HE> On the other hand, I sent out a patch to libcmpiutil some minutes HE> ago, which adds a STD_InstanceMIStub macro to libcmpiutil.h . This HE> macro avoids now the warning in the original stub macro, which HE> removes the responsibility from each provider to define it by HE> itself. The patches below show the difference (first one is yours HE> with PN approach, second one is removing the PN approach and using HE> STD_InstanceMIStub macro). Yeah, my goal with this was not to simply merge the name in the prototype and the macro, but rather to unify the name used for provider with multiple MIStub calls. If someone updates these in the future, they could update one and not the other and break things. However, I don't see an easy way around this. HE> Now that you touched each MI stub, this might also be a good point HE> in time to resolve this (now very old ;) ... sorry for my delay) HE> problem. Yeah, I can apply and re-roll this patch with just the required libvirt initialization and changes to use your updated macro. -- 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 1195244698 28800 # Node ID 86766ef3c2479a9a5f6146e1865d94d17768a5a8 # Parent f6c11dd07703ae3f398592143b4fd31fc78f3a5d Changes to misc_utils.c for connect_by_classname() Includes Heidi's change to not return an error on failed connect. I chose to leave the failure in place if a proper URI could not be determined because this really means we were called for a prefix we don't support, which /is/ a problem. If we need to iterate over subclasses later down the road for differing CIMOM behavior, we should do it before we get here. Signed-off-by: Dan Smith <danms@us.ibm.com> diff -r f6c11dd07703 -r 86766ef3c247 libxkutil/misc_util.c --- a/libxkutil/misc_util.c Fri Nov 16 12:24:53 2007 -0800 +++ b/libxkutil/misc_util.c Fri Nov 16 12:24:58 2007 -0800 @@ -56,6 +56,8 @@ virConnectPtr connect_by_classname(const const char *uri; virConnectPtr conn; + CMSetStatus(s, CMPI_RC_OK); + uri = cn_to_uri(classname); if (!uri) { CMSetStatusWithChars(broker, s, @@ -64,11 +66,11 @@ virConnectPtr connect_by_classname(const return NULL; } + CU_DEBUG("Connecting to libvirt with uri `%s'", uri); + conn = virConnectOpen(uri); if (!conn) { - CMSetStatusWithChars(broker, s, - CMPI_RC_ERR_FAILED, - "Unable to connect to hypervisor"); + CU_DEBUG("Unable to connect to `%s'", uri); return NULL; } @@ -334,28 +336,21 @@ bool provider_is_responsible(const CMPIB const CMPIObjectPath *reference, CMPIStatus *status) { - const char *dft_pfx; char *pfx; - bool rc = false; + bool rc = true; CMSetStatus(status, CMPI_RC_OK); pfx = class_prefix_name(CLASSNAME(reference)); - if (STREQC(pfx, "CIM")) + if (STREQC(pfx, "CIM")) { cu_statusf(broker, status, CMPI_RC_ERR_FAILED, "Please exactly specify the class (check CIMOM behavior!): %s", CLASSNAME(reference)); - - dft_pfx = default_prefix(); - if (dft_pfx == NULL) - goto out; - - if (STREQC(pfx, dft_pfx)) - rc = true; - - out: + rc = false; + } + free(pfx); return rc; }

# HG changeset patch # User Dan Smith <danms@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@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)

Dan Smith wrote:
A more formal version of the last set, this time as a proposed change instead of an RFC. Some testing of the first patch would be good to make sure that I didn't change a provider name to be incongruent with what is in the registration files.
_______________________________________________ Libvirt-cim mailing list Libvirt-cim@redhat.com https://www.redhat.com/mailman/listinfo/libvirt-cim
I think this set looks good - using the libvirt_cim_init() call is a nice way to handle this. +1 -- Kaitlin Rupert IBM Linux Technology Center karupert@us.ibm.com
participants (3)
-
Dan Smith
-
Heidi Eckhart
-
Kaitlin Rupert