[PATCH 0 of 5] Adding support for the HostedService association provider.

This patch set adds support for the HostedService association. This include changes needed in the VSMS and RPCS providers so that their internal get instance functions could be called.

# HG changeset patch # User Kaitlin Rupert <karupert@us.ibm.com> # Date 1194555111 28800 # Node ID 6968bc0b3116061f68f467bc827e42ac853e2a7b # Parent 4e195b6654d5fcdbc51252617f64ae7ce7079778 Add new HostedService association provider. This association supports: HostSystem -> RPCS, VSMS. RPCS -> HostSystem VSMS -> HostSystem Signed-off-by: Kaitlin Rupert <karupert@us.ibm.com> diff -r 4e195b6654d5 -r 6968bc0b3116 src/Virt_HostedService.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/Virt_HostedService.c Thu Nov 08 12:51:51 2007 -0800 @@ -0,0 +1,174 @@ +/* + * Copyright IBM Corp. 2007 + * + * Authors: + * Kaitlin Rupert <karupert@us.ibm.com> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + +#include <cmpidt.h> +#include <cmpift.h> +#include <cmpimacs.h> + +#include "libcmpiutil.h" +#include "std_association.h" +#include "misc_util.h" + +#include "Virt_HostSystem.h" +#include "Virt_VirtualSystemManagementService.h" +#include "Virt_ResourcePoolConfigurationService.h" + +const static CMPIBroker *_BROKER; + +static CMPIStatus service_to_host(const CMPIObjectPath *ref, + struct std_assoc_info *info, + struct inst_list *list) +{ + CMPIStatus s; + CMPIInstance *instance; + + s = get_host_cs(_BROKER, ref, &instance); + if (s.rc == CMPI_RC_OK) + inst_list_add(list, instance); + + return s; +} + +static CMPIStatus host_to_service(const CMPIObjectPath *ref, + struct std_assoc_info *info, + struct inst_list *list) +{ + CMPIStatus s = {CMPI_RC_OK, NULL}; + CMPIInstance *inst; + + s = rpcs_instance(ref, &inst, _BROKER); + if (s.rc != CMPI_RC_OK) + return s; + if (!CMIsNullObject(inst)) + inst_list_add(list, inst); + + s = get_vsms(ref, &inst, _BROKER, 0); + if (s.rc != CMPI_RC_OK) + return s; + if (!CMIsNullObject(inst)) + inst_list_add(list, inst); + + return s; +} + +static CMPIInstance *make_ref(const CMPIObjectPath *ref, + const CMPIInstance *inst, + struct std_assoc_info *info, + struct std_assoc *assoc) +{ + CMPIInstance *refinst = NULL; + char *base; + + base = class_base_name(assoc->assoc_class); + if (base == NULL) + goto out; + + refinst = get_typed_instance(_BROKER, + base, + NAMESPACE(ref)); + + if (refinst != NULL) { + CMPIObjectPath *instop; + + instop = CMGetObjectPath(inst, NULL); + + set_reference(assoc, refinst, ref, instop); + } + +out: + return refinst; +} + +static struct std_assoc xen_host_to_service = { + .source_class = "Xen_HostSystem", + .source_prop = "Antecedent", + + .target_class = "CIM_ManagedElement", + .target_prop = "Dependent", + + .assoc_class = "CIM_HostedService", + + .handler = host_to_service, + .make_ref = make_ref +}; + +static struct std_assoc xen_service_to_host = { + .source_class = "CIM_Service", + .source_prop = "Dependent", + + .target_class = "CIM_ManagedElement", + .target_prop = "Antecedent", + + .assoc_class = "CIM_HostedService", + + .handler = service_to_host, + .make_ref = make_ref +}; + +static struct std_assoc kvm_host_to_service = { + .source_class = "KVM_HostSystem", + .source_prop = "Antecedent", + + .target_class = "CIM_Service", + .target_prop = "Dependent", + + .assoc_class = "CIM_HostedService", + + .handler = host_to_service, + .make_ref = make_ref +}; + +static struct std_assoc kvm_service_to_host = { + .source_class = "CIM_Service", + .source_prop = "Dependent", + + .target_class = "KVM_ComputerSystem", + .target_prop = "Antecedent", + + .assoc_class = "CIM_HostedService", + + .handler = service_to_host, + .make_ref = make_ref +}; + +static struct std_assoc *handlers[] = { + &xen_host_to_service, + &xen_service_to_host, + &kvm_host_to_service, + &kvm_service_to_host, + NULL +}; + +STDA_AssocMIStub(, Xen_HostedServiceProvider, _BROKER, CMNoHook, handlers); +STDA_AssocMIStub(, KVM_HostedServiceProvider, _BROKER, CMNoHook, handlers); + +/* + * Local Variables: + * mode: C + * c-set-style: "K&R" + * tab-width: 8 + * c-basic-offset: 8 + * indent-tabs-mode: nil + * End: + */

KR> +static CMPIStatus host_to_service(const CMPIObjectPath *ref, KR> + struct std_assoc_info *info, KR> + struct inst_list *list) KR> +{ KR> + CMPIStatus s = {CMPI_RC_OK, NULL}; KR> + CMPIInstance *inst; KR> + KR> + s = rpcs_instance(ref, &inst, _BROKER); KR> + if (s.rc != CMPI_RC_OK) KR> + return s; KR> + if (!CMIsNullObject(inst)) KR> + inst_list_add(list, inst); KR> + KR> + s = get_vsms(ref, &inst, _BROKER, 0); Hmm, I didn't notice in the earlier patch (since it was just a unstaticification of an existing function) but the fourth parameter to get_vsms() isn't used for anything, so we should remove it. Looks good other than that. I'll apply and cook up a patch to remove the extraneous parameter. Thanks! -- Dan Smith IBM Linux Technology Center Open Hypervisor Team email: danms@us.ibm.com

# HG changeset patch # User Kaitlin Rupert <karupert@us.ibm.com> # Date 1194555199 28800 # Node ID e47094a1620c4215427afaa46faedee97bcd123a # Parent 6968bc0b3116061f68f467bc827e42ac853e2a7b Adding support to build and install Virt_HostedService provider. Also fixed the missing \ after schema/ResourceAllocationFromPool.registration in Makefile.am. Signed-off-by: Kaitlin Rupert <karupert@us.ibm.com> diff -r 6968bc0b3116 -r e47094a1620c Makefile.am --- a/Makefile.am Thu Nov 08 12:51:51 2007 -0800 +++ b/Makefile.am Thu Nov 08 12:53:19 2007 -0800 @@ -29,8 +29,9 @@ MOFS = \ schema/VSSDComponent.mof \ schema/SettingsDefineState.mof \ schema/NetPool.mof \ - schema/ResourceAllocationFromPool.mof - schema/ElementAllocatedFromPool.mof + schema/ResourceAllocationFromPool.mof \ + schema/ElementAllocatedFromPool.mof \ + schema/HostedService.mof INTEROP_MOFS = \ schema/RegisteredProfile.mof \ @@ -65,7 +66,8 @@ REGS = \ schema/SettingsDefineState.registration \ schema/NetPool.registration \ schema/ResourceAllocationFromPool.registration \ - schema/ElementAllocatedFromPool.registration + schema/ElementAllocatedFromPool.registration \ + schema/HostedService.registration INTEROP_REGS = \ schema/RegisteredProfile.registration \ diff -r 6968bc0b3116 -r e47094a1620c src/Makefile.am --- a/src/Makefile.am Thu Nov 08 12:51:51 2007 -0800 +++ b/src/Makefile.am Thu Nov 08 12:53:19 2007 -0800 @@ -11,8 +11,10 @@ noinst_HEADERS = profiles.h svpc_types.h Virt_HostSystem.h \ Virt_RASD.h \ Virt_RegisteredProfile.h \ + Virt_ResourcePoolConfigurationService.h \ Virt_SettingsDefineCapabilities.h \ Virt_VirtualSystemManagementCapabilities.h \ + Virt_VirtualSystemManagementService.h \ Virt_VSSD.h XKUADD = $(top_builddir)/libxkutil/libxkutil.la @@ -46,7 +48,8 @@ provider_LTLIBRARIES = libVirt_ComputerS libVirt_VSSDComponent.la \ libVirt_SettingsDefineState.la \ libVirt_ResourceAllocationFromPool.la \ - libVirt_ElementAllocatedFromPool.la + libVirt_ElementAllocatedFromPool.la \ + libVirt_HostedService.la libVirt_ComputerSystem_la_SOURCES = Virt_ComputerSystem.c libVirt_Device_la_SOURCES = Virt_Device.c @@ -110,3 +113,6 @@ libVirt_ResourceAllocationFromPool_la_LI libVirt_ElementAllocatedFromPool_la_SOURCES = Virt_ElementAllocatedFromPool.c libVirt_ElementAllocatedFromPool_la_LIBADD = -lVirt_DevicePool -lVirt_Device + +libVirt_HostedService_la_SOURCES = Virt_HostedService.c +libVirt_HostedService_la_LIBADD = -lVirt_VirtualSystemManagementService -lVirt_ResourcePoolConfigurationService

KR> # HG changeset patch KR> # User Kaitlin Rupert <karupert@us.ibm.com> KR> # Date 1194555199 28800 KR> # Node ID e47094a1620c4215427afaa46faedee97bcd123a KR> # Parent 6968bc0b3116061f68f467bc827e42ac853e2a7b KR> Adding support to build and install Virt_HostedService provider. Applied. KR> Also fixed the missing \ after KR> schema/ResourceAllocationFromPool.registration in Makefile.am. Excellent, thanks! I'm surprised that hasn't broken anything by now... -- Dan Smith IBM Linux Technology Center Open Hypervisor Team email: danms@us.ibm.com

# HG changeset patch # User Kaitlin Rupert <karupert@us.ibm.com> # Date 1194555339 28800 # Node ID 151bc006918bfcce761944dbe2397191a535a2dc # Parent e47094a1620c4215427afaa46faedee97bcd123a Add a new mof and registration file for the HostedService provider. Signed-off-by: Kaitlin Rupert <karupert@us.ibm.com> diff -r e47094a1620c -r 151bc006918b schema/HostedService.mof --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/schema/HostedService.mof Thu Nov 08 12:55:39 2007 -0800 @@ -0,0 +1,6 @@ +// Copyright IBM Corp. 2007 +class Xen_HostedService : CIM_HostedService { +}; + +class KVM_HostedService : CIM_HostedService { +}; diff -r e47094a1620c -r 151bc006918b schema/HostedService.registration --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/schema/HostedService.registration Thu Nov 08 12:55:39 2007 -0800 @@ -0,0 +1,4 @@ +# Copyright IBM Corp. 2007 +# Classname Namespace ProviderName ProviderModule ProviderTypes ... +Xen_HostedService root/ibmsd Xen_HostedServiceProvider Virt_HostedService association +KVM_HostedService root/ibmsd KVM_HostedServiceProvider Virt_HostedService association

KR> # HG changeset patch KR> # User Kaitlin Rupert <karupert@us.ibm.com> KR> # Date 1194555339 28800 KR> # Node ID 151bc006918bfcce761944dbe2397191a535a2dc KR> # Parent e47094a1620c4215427afaa46faedee97bcd123a KR> Add a new mof and registration file for the HostedService provider. Applied. I'll need to make sure I add this to my namespace change patch :) -- Dan Smith IBM Linux Technology Center Open Hypervisor Team email: danms@us.ibm.com

Dan Smith wrote:
KR> # HG changeset patch KR> # User Kaitlin Rupert <karupert@us.ibm.com> KR> # Date 1194555339 28800 KR> # Node ID 151bc006918bfcce761944dbe2397191a535a2dc KR> # Parent e47094a1620c4215427afaa46faedee97bcd123a KR> Add a new mof and registration file for the HostedService provider.
Applied. I'll need to make sure I add this to my namespace change patch :)
Yep! I had the patch all done before I saw your namespace patch. -- Kaitlin Rupert IBM Linux Technology Center karupert@us.ibm.com

# HG changeset patch # User Kaitlin Rupert <karupert@us.ibm.com> # Date 1194558008 28800 # Node ID 34e8e0d331e42f42545342dd765d35ee66aabd56 # Parent 151bc006918bfcce761944dbe2397191a535a2dc Fix rpcs_instance() call so other providers can call it. Remove static from rpcs_instance(), add support for a broker from another provider, and add the function declartion to a header file. This will allow other providers to call this function as needed. Signed-off-by: Kaitlin Rupert <karupert@us.ibm.com> diff -r 151bc006918b -r 34e8e0d331e4 src/Virt_ResourcePoolConfigurationService.c --- a/src/Virt_ResourcePoolConfigurationService.c Thu Nov 08 12:55:39 2007 -0800 +++ b/src/Virt_ResourcePoolConfigurationService.c Thu Nov 08 13:40:08 2007 -0800 @@ -28,6 +28,7 @@ #include "misc_util.h" #include "Virt_HostSystem.h" +#include "Virt_ResourcePoolConfigurationService.h" const static CMPIBroker *_BROKER; @@ -89,23 +90,24 @@ DEFAULT_EQ(); DEFAULT_EQ(); DEFAULT_INST_CLEANUP(); -static CMPIStatus rpcs_instance(const CMPIObjectPath *reference, - CMPIInstance **_inst) +CMPIStatus rpcs_instance(const CMPIObjectPath *reference, + CMPIInstance **_inst, + const CMPIBroker *broker) { CMPIInstance *inst; CMPIInstance *host; CMPIStatus s; CMPIData prop; - s = get_host_cs(_BROKER, reference, &host); + s = get_host_cs(broker, reference, &host); if (s.rc != CMPI_RC_OK) goto out; - inst = get_typed_instance(_BROKER, + inst = get_typed_instance(broker, "ResourcePoolConfigurationService", NAMESPACE(reference)); if (inst == NULL) { - cu_statusf(_BROKER, &s, + cu_statusf(broker, &s, CMPI_RC_ERR_FAILED, "Unable to get " "ResourcePoolConfigurationService instance"); @@ -117,7 +119,7 @@ static CMPIStatus rpcs_instance(const CM prop = CMGetProperty(host, "CreationClassName", &s); if (s.rc != CMPI_RC_OK) { - cu_statusf(_BROKER, &s, + cu_statusf(broker, &s, CMPI_RC_ERR_FAILED, "Unable to get CreationClassName from HostSystem"); goto out; @@ -128,7 +130,7 @@ static CMPIStatus rpcs_instance(const CM prop = CMGetProperty(host, "Name", NULL); if (s.rc != CMPI_RC_OK) { - cu_statusf(_BROKER, &s, + cu_statusf(broker, &s, CMPI_RC_ERR_FAILED, "Unable to get Name from HostSystem"); goto out; @@ -152,7 +154,7 @@ static CMPIStatus GetInstance(CMPIInstan CMPIStatus s; const char *prop = NULL; - s = rpcs_instance(reference, &inst); + s = rpcs_instance(reference, &inst, _BROKER); if (s.rc != CMPI_RC_OK) return s; @@ -176,7 +178,7 @@ static CMPIStatus EnumInstanceNames(CMPI CMPIInstance *inst; CMPIStatus s; - s = rpcs_instance(reference, &inst); + s = rpcs_instance(reference, &inst, _BROKER); if (s.rc == CMPI_RC_OK) cu_return_instance_name(results, inst); @@ -193,7 +195,7 @@ static CMPIStatus EnumInstances(CMPIInst CMPIInstance *inst; CMPIStatus s; - s = rpcs_instance(reference, &inst); + s = rpcs_instance(reference, &inst, _BROKER); if (s.rc == CMPI_RC_OK) CMReturnInstance(results, inst); diff -r 151bc006918b -r 34e8e0d331e4 src/Virt_ResourcePoolConfigurationService.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/Virt_ResourcePoolConfigurationService.h Thu Nov 08 13:40:08 2007 -0800 @@ -0,0 +1,24 @@ +/* + * Copyright IBM Corp. 2007 + * + * Authors: + * Kaitlin Rupert <karupert@us.ibm.com> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +CMPIStatus rpcs_instance(const CMPIObjectPath *reference, + CMPIInstance **_inst, + const CMPIBroker *broker);

KR> # HG changeset patch KR> # User Kaitlin Rupert <karupert@us.ibm.com> KR> # Date 1194558008 28800 KR> # Node ID 34e8e0d331e42f42545342dd765d35ee66aabd56 KR> # Parent 151bc006918bfcce761944dbe2397191a535a2dc KR> Fix rpcs_instance() call so other providers can call it. Applied, thanks! -- Dan Smith IBM Linux Technology Center Open Hypervisor Team email: danms@us.ibm.com

# HG changeset patch # User Kaitlin Rupert <karupert@us.ibm.com> # Date 1194558013 28800 # Node ID 1fc24e24237efa5ea495b48c2beb8bb10afc2270 # Parent 34e8e0d331e42f42545342dd765d35ee66aabd56 Fix _get_vsms() call so other providers can call it. Remove static from _get_vsms(), rename function, add support for a broker from another provider, and add the function declartion to a header file. This will allow other providers to call this function as needed. Signed-off-by: Kaitlin Rupert <karupert@us.ibm.com> diff -r 34e8e0d331e4 -r 1fc24e24237e src/Virt_VirtualSystemManagementService.c --- a/src/Virt_VirtualSystemManagementService.c Thu Nov 08 13:40:08 2007 -0800 +++ b/src/Virt_VirtualSystemManagementService.c Thu Nov 08 13:40:13 2007 -0800 @@ -41,6 +41,7 @@ #include "std_indication.h" #include "misc_util.h" +#include "Virt_VirtualSystemManagementService.h" #include "Virt_ComputerSystem.h" #include "Virt_ComputerSystemIndication.h" #include "Virt_RASD.h" @@ -992,25 +993,26 @@ STDIM_MethodMIStub(, Virt_VirtualSystemM STDIM_MethodMIStub(, Virt_VirtualSystemManagementService, _BROKER, CMNoHook, my_handlers); -static CMPIStatus _get_vsms(const CMPIObjectPath *reference, - CMPIInstance **_inst, - int name_only) +CMPIStatus get_vsms(const CMPIObjectPath *reference, + CMPIInstance **_inst, + const CMPIBroker *broker, + int name_only) { CMPIStatus s; CMPIInstance *inst; CMPIInstance *host; char *val = NULL; - s = get_host_cs(_BROKER, reference, &host); + s = get_host_cs(broker, reference, &host); if (s.rc != CMPI_RC_OK) goto out; - inst = get_typed_instance(_BROKER, + inst = get_typed_instance(broker, "VirtualSystemManagementService", NAMESPACE(reference)); if (inst == NULL) { CU_DEBUG("Failed to get typed instance"); - cu_statusf(_BROKER, &s, + cu_statusf(broker, &s, CMPI_RC_ERR_FAILED, "Failed to create instance"); goto out; @@ -1020,7 +1022,7 @@ static CMPIStatus _get_vsms(const CMPIOb (CMPIValue *)"Management Service", CMPI_chars); if (cu_get_str_prop(host, "Name", &val) != CMPI_RC_OK) { - cu_statusf(_BROKER, &s, + cu_statusf(broker, &s, CMPI_RC_ERR_FAILED, "Unable to get name of System"); goto out; @@ -1031,7 +1033,7 @@ static CMPIStatus _get_vsms(const CMPIOb free(val); if (cu_get_str_prop(host, "CreationClassName", &val) != CMPI_RC_OK) { - cu_statusf(_BROKER, &s, + cu_statusf(broker, &s, CMPI_RC_ERR_FAILED, "Unable to get creation class of system"); goto out; @@ -1055,7 +1057,7 @@ static CMPIStatus return_vsms(const CMPI CMPIInstance *inst; CMPIStatus s; - s = _get_vsms(reference, &inst, name_only); + s = get_vsms(reference, &inst, _BROKER, name_only); if (s.rc != CMPI_RC_OK) goto out; @@ -1097,7 +1099,7 @@ static CMPIStatus GetInstance(CMPIInstan CMPIStatus s; const char *prop; - s = _get_vsms(ref, &inst, 0); + s = get_vsms(ref, &inst, _BROKER, 0); if (s.rc != CMPI_RC_OK) return s; diff -r 34e8e0d331e4 -r 1fc24e24237e src/Virt_VirtualSystemManagementService.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/Virt_VirtualSystemManagementService.h Thu Nov 08 13:40:13 2007 -0800 @@ -0,0 +1,25 @@ +/* + * Copyright IBM Corp. 2007 + * + * Authors: + * Kaitlin Rupert <karupert@us.ibm.com> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +CMPIStatus get_vsms(const CMPIObjectPath *reference, + CMPIInstance **_inst, + const CMPIBroker *broker, + int name_only);

KR> # HG changeset patch KR> # User Kaitlin Rupert <karupert@us.ibm.com> KR> # Date 1194558013 28800 KR> # Node ID 1fc24e24237efa5ea495b48c2beb8bb10afc2270 KR> # Parent 34e8e0d331e42f42545342dd765d35ee66aabd56 KR> Fix _get_vsms() call so other providers can call it. Looks good, applied. -- Dan Smith IBM Linux Technology Center Open Hypervisor Team email: danms@us.ibm.com
participants (2)
-
Dan Smith
-
Kaitlin Rupert