[PATCH 0 of 2] (#2) Add RedirectionServiceCapabilities provider

The KVM Redirection Profile (DSP1076) indicates that implementing a provider for this class is option. It's implemented here for consistency with other classes.

# HG changeset patch # User Kaitlin Rupert <karupert@us.ibm.com> # Date 1221498293 25200 # Node ID f5078be18a2225b913ea3cf792840b0fa58985e9 # Parent bdae3c6d498f2e85c531e6fbd4b3b0974ef7ccdb Add schema changes needed for RedirectionServiceCapabilities Signed-off-by: Kaitlin Rupert <karupert@us.ibm.com> diff -r bdae3c6d498f -r f5078be18a22 Makefile.am --- a/Makefile.am Fri Sep 12 10:42:41 2008 -0700 +++ b/Makefile.am Mon Sep 15 10:04:53 2008 -0700 @@ -43,7 +43,8 @@ schema/VirtualSystemSnapshotService.mof \ schema/VirtualSystemSnapshotServiceCapabilities.mof \ schema/ConcreteComponent.mof \ - schema/RedirectionService.mof + schema/RedirectionService.mof \ + schema/RedirectionServiceCapabilities.mof INTEROP_MOFS = \ schema/ComputerSystem.mof \ @@ -92,7 +93,8 @@ schema/VirtualSystemSnapshotService.registration \ schema/VirtualSystemSnapshotServiceCapabilities.registration \ schema/ConcreteComponent.registration \ - schema/RedirectionService.registration + schema/RedirectionService.registration \ + schema/RedirectionServiceCapabilities.registration INTEROP_REGS = \ schema/RegisteredProfile.registration \ diff -r bdae3c6d498f -r f5078be18a22 src/Makefile.am --- a/src/Makefile.am Fri Sep 12 10:42:41 2008 -0700 +++ b/src/Makefile.am Mon Sep 15 10:04:53 2008 -0700 @@ -55,6 +55,7 @@ libVirt_ResourcePoolConfigurationCapabilities.la \ libVirt_VSMigrationService.la \ libVirt_RedirectionService.la \ + libVirt_RedirectionServiceCapabilities.la \ libVirt_SettingsDefineCapabilities.la \ libVirt_HostedDependency.la \ libVirt_ElementConformsToProfile.la \ @@ -197,3 +198,5 @@ libVirt_RedirectionService_la_SOURCES = Virt_RedirectionService.c libVirt_RedirectionService_la_LIBADD = -lVirt_HostSystem +libVirt_RedirectionServiceCapabilities_la_SOURCES = Virt_RedirectionServiceCapabilities.c +

# HG changeset patch # User Kaitlin Rupert <karupert@us.ibm.com> # Date 1221511150 25200 # Node ID 8f75fc91697b91ec1b633f69f5d0e8bc6f81c60a # Parent f5078be18a2225b913ea3cf792840b0fa58985e9 (#2) Add RedirectionServiceCapabilites. Put SHARING_MODE value and get_rs() in a header file. get_rs() will be needed for the console related assocations. Updates: -Remove static from get_rs() in RedirectionService.c Signed-off-by: Kaitlin Rupert <karupert@us.ibm.com> diff -r f5078be18a22 -r 8f75fc91697b src/Makefile.am --- a/src/Makefile.am Mon Sep 15 10:04:53 2008 -0700 +++ b/src/Makefile.am Mon Sep 15 13:39:10 2008 -0700 @@ -20,7 +20,8 @@ Virt_AllocationCapabilities.h \ Virt_VirtualSystemSnapshotService.h \ Virt_VirtualSystemSnapshotServiceCapabilities.h \ - Virt_VSMigrationSettingData.h + Virt_VSMigrationSettingData.h \ + Virt_RedirectionService.h XKUADD = $(top_builddir)/libxkutil/libxkutil.la diff -r f5078be18a22 -r 8f75fc91697b src/Virt_RedirectionService.c --- a/src/Virt_RedirectionService.c Mon Sep 15 10:04:53 2008 -0700 +++ b/src/Virt_RedirectionService.c Mon Sep 15 13:39:10 2008 -0700 @@ -35,20 +35,20 @@ #include <libcmpiutil/std_instance.h> #include "Virt_HostSystem.h" +#include "Virt_RedirectionService.h" #define SERVICE_TYPE 3 -#define SHARING_MODE 3 #define ENABLED_STATE 2 #define REQUESTED_STATE 12 const static CMPIBroker *_BROKER; -static CMPIStatus get_rs(const CMPIObjectPath *reference, - CMPIInstance **_inst, - const CMPIBroker *broker, - const CMPIContext *context, - bool is_get_inst) +CMPIStatus get_rs(const CMPIObjectPath *reference, + CMPIInstance **_inst, + const CMPIBroker *broker, + const CMPIContext *context, + bool is_get_inst) { CMPIStatus s = {CMPI_RC_OK, NULL}; virConnectPtr conn = NULL; diff -r f5078be18a22 -r 8f75fc91697b src/Virt_RedirectionService.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/Virt_RedirectionService.h Mon Sep 15 13:39:10 2008 -0700 @@ -0,0 +1,39 @@ +/* + * 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 + */ + +#define SHARING_MODE 3 + +CMPIStatus get_rs(const CMPIObjectPath *reference, + CMPIInstance **_inst, + const CMPIBroker *broker, + const CMPIContext *context, + bool is_get_inst); + +/* + * Local Variables: + * mode: C + * c-set-style: "K&R" + * tab-width: 8 + * c-basic-offset: 8 + * indent-tabs-mode: nil + * End: + */ + diff -r f5078be18a22 -r 8f75fc91697b src/Virt_RedirectionServiceCapabilities.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/Virt_RedirectionServiceCapabilities.c Mon Sep 15 13:39:10 2008 -0700 @@ -0,0 +1,180 @@ +/* + * 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 <stdlib.h> +#include <unistd.h> + +#include <cmpidt.h> +#include <cmpift.h> +#include <cmpimacs.h> + +#include <libcmpiutil/libcmpiutil.h> +#include <libcmpiutil/std_instance.h> + +#include "misc_util.h" + +#include "Virt_RedirectionService.h" + +const static CMPIBroker *_BROKER; + +static CMPIStatus set_inst_properties(const CMPIBroker *broker, + const CMPIObjectPath *ref, + CMPIInstance *inst) +{ + CMPIStatus s = {CMPI_RC_OK, NULL}; + CMPIBoolean element_edit = false; + CMPIArray *array; + uint16_t prop_val; + + CMSetProperty(inst, "InstanceID", + (CMPIValue *)"RedirectionCapabilities", CMPI_chars); + + CMSetProperty(inst, "ElementName", + (CMPIValue *)"RedirectionCapabilities", CMPI_chars); + + CMSetProperty(inst, "ElementNameEditSupported", + (CMPIValue *)&element_edit, CMPI_boolean); + + array = CMNewArray(broker, 1, CMPI_uint16, &s); + if ((s.rc != CMPI_RC_OK) || CMIsNullObject(array)) + goto out; + + prop_val = (uint16_t)SHARING_MODE; + CMSetArrayElementAt(array, 0, &prop_val, CMPI_uint16); + + CMSetProperty(inst, "SharingModeSupported", + (CMPIValue *)&array, CMPI_uint16A); + + out: + return s; +} + +static CMPIStatus get_rs_cap(const CMPIBroker *broker, + const CMPIObjectPath *ref, + CMPIInstance **_inst, + bool is_get_inst) +{ + CMPIStatus s = {CMPI_RC_OK, NULL}; + CMPIInstance *inst = NULL; + virConnectPtr conn = NULL; + + conn = connect_by_classname(broker, CLASSNAME(ref), &s); + if (conn == NULL) { + if (is_get_inst) + cu_statusf(broker, &s, + CMPI_RC_ERR_NOT_FOUND, + "No such instance"); + goto out; + } + + inst = get_typed_instance(broker, + pfx_from_conn(conn), + "RedirectionServiceCapabilities", + NAMESPACE(ref)); + if (inst == NULL) { + cu_statusf(broker, &s, + CMPI_RC_ERR_FAILED, + "Can't create instance for %s", CLASSNAME(ref)); + goto out; + } + + s = set_inst_properties(broker, ref, inst); + + if (is_get_inst) { + s = cu_validate_ref(broker, ref, inst); + if (s.rc != CMPI_RC_OK) + goto out; + } + + *_inst = inst; + + out: + virConnectClose(conn); + + return s; +} + +static CMPIStatus return_rs_cap(const CMPIObjectPath *ref, + const CMPIResult *results, + bool names_only, + bool is_get_inst) +{ + CMPIStatus s = {CMPI_RC_OK, NULL}; + CMPIInstance *inst = NULL; + + s = get_rs_cap(_BROKER, ref, &inst, is_get_inst); + if ((s.rc != CMPI_RC_OK) || (inst == NULL)) + goto out; + + if (names_only) + cu_return_instance_name(results, inst); + else + CMReturnInstance(results, inst); + out: + return s; +} + +static CMPIStatus EnumInstanceNames(CMPIInstanceMI *self, + const CMPIContext *context, + const CMPIResult *results, + const CMPIObjectPath *reference) +{ + return return_rs_cap(reference, results, true, false); +} + +static CMPIStatus EnumInstances(CMPIInstanceMI *self, + const CMPIContext *context, + const CMPIResult *results, + const CMPIObjectPath *reference, + const char **properties) +{ + + return return_rs_cap(reference, results, false, false); +} + +static CMPIStatus GetInstance(CMPIInstanceMI *self, + const CMPIContext *context, + const CMPIResult *results, + const CMPIObjectPath *reference, + const char **properties) +{ + return return_rs_cap(reference, results, false, true); +} + +DEFAULT_CI(); +DEFAULT_MI(); +DEFAULT_DI(); +DEFAULT_EQ(); +DEFAULT_INST_CLEANUP(); + +STD_InstanceMIStub(, + Virt_RedirectionServiceCapabilities, + _BROKER, + libvirt_cim_init()); + +/* + * Local Variables: + * mode: C + * c-set-style: "K&R" + * tab-width: 8 + * c-basic-offset: 8 + * indent-tabs-mode: nil + * End: + */

KR> The KVM Redirection Profile (DSP1076) indicates that implementing a KR> provider for this class is option. It's implemented here for KR> consistency with other classes. I'm fine with this set, so I'll apply this when the previous set is re-posted. -- Dan Smith IBM Linux Technology Center Open Hypervisor Team email: danms@us.ibm.com
participants (2)
-
Dan Smith
-
Kaitlin Rupert