[PATCH 0 of 2] Add support for the RedirectionService

This patchset add the RedirectionService provider needed to add console support for the guests.

# HG changeset patch # User Kaitlin Rupert <karupert@us.ibm.com> # Date 1221241931 25200 # Node ID 3d2b534d18c893486bc083fe855c807d3112a37f # Parent d839aa7edc3c125946e18019a9e67a4f10dd330b Schema and Makefile changes for the RedirectionService Signed-off-by: Kaitlin Rupert <karupert@us.ibm.com> diff -r d839aa7edc3c -r 3d2b534d18c8 Makefile.am --- a/Makefile.am Fri Sep 12 10:42:39 2008 -0700 +++ b/Makefile.am Fri Sep 12 10:52:11 2008 -0700 @@ -42,7 +42,8 @@ schema/VSMigrationSettingData.mof \ schema/VirtualSystemSnapshotService.mof \ schema/VirtualSystemSnapshotServiceCapabilities.mof \ - schema/ConcreteComponent.mof + schema/ConcreteComponent.mof \ + schema/RedirectionService.mof INTEROP_MOFS = \ schema/ComputerSystem.mof \ @@ -95,7 +96,8 @@ schema/VSMigrationSettingData.registration \ schema/VirtualSystemSnapshotService.registration \ schema/VirtualSystemSnapshotServiceCapabilities.registration \ - schema/ConcreteComponent.registration + schema/ConcreteComponent.registration \ + schema/RedirectionService.registration INTEROP_REGS = \ schema/RegisteredProfile.registration \ diff -r d839aa7edc3c -r 3d2b534d18c8 schema/RedirectionService.mof --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/schema/RedirectionService.mof Fri Sep 12 10:52:11 2008 -0700 @@ -0,0 +1,16 @@ +// Copyright IBM Corp. 2007 + +[Provider("cmpi::Virt_RedirectionService")] +class Xen_RedirectionService : CIM_RedirectionService +{ +}; + +[Provider("cmpi::Virt_RedirectionService")] +class KVM_RedirectionService : CIM_RedirectionService +{ +}; + +[Provider("cmpi::Virt_RedirectionService")] +class LXC_RedirectionService : CIM_RedirectionService +{ +}; diff -r d839aa7edc3c -r 3d2b534d18c8 schema/RedirectionService.registration --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/schema/RedirectionService.registration Fri Sep 12 10:52:11 2008 -0700 @@ -0,0 +1,5 @@ +# Copyright IBM Corp. 2007 +# Classname Namespace ProviderName ProviderModule ProviderTypes +Xen_RedirectionService root/virt Virt_RedirectionService Virt_RedirectionService method instance +KVM_RedirectionService root/virt Virt_RedirectionService Virt_RedirectionService method instance +LXC_RedirectionService root/virt Virt_RedirectionService Virt_RedirectionService method instance diff -r d839aa7edc3c -r 3d2b534d18c8 src/Makefile.am --- a/src/Makefile.am Fri Sep 12 10:42:39 2008 -0700 +++ b/src/Makefile.am Fri Sep 12 10:52:11 2008 -0700 @@ -54,6 +54,7 @@ libVirt_ResourcePoolConfigurationService.la \ libVirt_ResourcePoolConfigurationCapabilities.la \ libVirt_VSMigrationService.la \ + libVirt_RedirectionService.la \ libVirt_SettingsDefineCapabilities.la \ libVirt_HostedDependency.la \ libVirt_ElementConformsToProfile.la \ @@ -191,3 +192,8 @@ libVirt_ConcreteComponent_la_DEPENDENCIES = libVirt_HostSystem.la libVirt_DevicePool.la libVirt_ConcreteComponent_la_SOURCES = Virt_ConcreteComponent.c libVirt_ConcreteComponent_la_LIBADD = -lVirt_HostSystem -lVirt_DevicePool + +libVirt_RedirectionService_la_DEPENDENCIES = libVirt_HostSystem.la +libVirt_RedirectionService_la_SOURCES = Virt_RedirectionService.c +libVirt_RedirectionService_la_LIBADD = -lVirt_HostSystem +

KR> +[Provider("cmpi::Virt_RedirectionService")] KR> +class Xen_RedirectionService : CIM_RedirectionService KR> +{ KR> +}; KR> + KR> +[Provider("cmpi::Virt_RedirectionService")] KR> +class KVM_RedirectionService : CIM_RedirectionService KR> +{ KR> +}; KR> + KR> +[Provider("cmpi::Virt_RedirectionService")] KR> +class LXC_RedirectionService : CIM_RedirectionService KR> +{ KR> +}; Should this be Xen_ConsoleRedirectionService? I don't know much about the KVM model so maybe this is silly, but it seems like maybe any other redirection service we implemented would be sufficiently distinct from this that it wouldn't make much sense to have them in the same provider. If you think that this isn't a concern, then I'll take your word for it :) -- Dan Smith IBM Linux Technology Center Open Hypervisor Team email: danms@us.ibm.com

Dan Smith wrote:
KR> +[Provider("cmpi::Virt_RedirectionService")] KR> +class Xen_RedirectionService : CIM_RedirectionService KR> +{ KR> +}; KR> + KR> +[Provider("cmpi::Virt_RedirectionService")] KR> +class KVM_RedirectionService : CIM_RedirectionService KR> +{ KR> +}; KR> + KR> +[Provider("cmpi::Virt_RedirectionService")] KR> +class LXC_RedirectionService : CIM_RedirectionService KR> +{ KR> +};
Should this be Xen_ConsoleRedirectionService? I don't know much about the KVM model so maybe this is silly, but it seems like maybe any other redirection service we implemented would be sufficiently distinct from this that it wouldn't make much sense to have them in the same provider. If you think that this isn't a concern, then I'll take your word for it :)
In CIM schema version 2.16, there's only RedirectionService and TextRedirectionService. And I don't think TextRedirectionService is what we're looking for. It's unfortunate, because it does make the service very generic. I saw a USB service was added in 2.18 - so maybe in the future, a more descriptive service will be added. -- Kaitlin Rupert IBM Linux Technology Center kaitlin@linux.vnet.ibm.com

KR> In CIM schema version 2.16, there's only RedirectionService and KR> TextRedirectionService. And I don't think TextRedirectionService is KR> what we're looking for. My point is, CIM_RedirectionService can refer to console redirection or even IP port forwarding. Since we could potentially expose a USB redirection service (as you mention), a network traffic redirection service, etc, in the future, I think we should name this more appropriately. Just as we expose a CIM_ResourcePool as Xen_MemoryPool or Xen_DiskPool, I think we should be calling this a Xen_ConsoleRedirectionService. No? -- Dan Smith IBM Linux Technology Center Open Hypervisor Team email: danms@us.ibm.com

Dan Smith wrote:
KR> In CIM schema version 2.16, there's only RedirectionService and KR> TextRedirectionService. And I don't think TextRedirectionService is KR> what we're looking for.
My point is, CIM_RedirectionService can refer to console redirection or even IP port forwarding. Since we could potentially expose a USB redirection service (as you mention), a network traffic redirection service, etc, in the future, I think we should name this more appropriately.
Just as we expose a CIM_ResourcePool as Xen_MemoryPool or Xen_DiskPool, I think we should be calling this a Xen_ConsoleRedirectionService. No?
Ah, I see. I thought you meant that CIM_RedirectionService was the wrong super class. The change you're suggesting sounds reasonable to me. -- Kaitlin Rupert IBM Linux Technology Center kaitlin@linux.vnet.ibm.com

# HG changeset patch # User Kaitlin Rupert <karupert@us.ibm.com> # Date 1221241361 25200 # Node ID 5dcc5fba620ae6d965feaf8dfce222e1eda9f2d1 # Parent 3d2b534d18c893486bc083fe855c807d3112a37f Add new provider: RedirectionService. Signed-off-by: Kaitlin Rupert <karupert@us.ibm.com> diff -r 3d2b534d18c8 -r 5dcc5fba620a src/Virt_RedirectionService.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/Virt_RedirectionService.c Fri Sep 12 10:42:41 2008 -0700 @@ -0,0 +1,221 @@ +/* + * 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 <string.h> +#include <stdlib.h> +#include <stdbool.h> +#include <inttypes.h> + +#include "cmpidt.h" +#include "cmpift.h" +#include "cmpimacs.h" + +#include "misc_util.h" + +#include <libcmpiutil/libcmpiutil.h> +#include <libcmpiutil/std_invokemethod.h> +#include <libcmpiutil/std_instance.h> + +#include "Virt_HostSystem.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 s = {CMPI_RC_OK, NULL}; + virConnectPtr conn = NULL; + CMPIInstance *inst = NULL; + CMPIArray *array; + const char *name = NULL; + const char *ccname = NULL; + uint16_t prop_val; + + *_inst = NULL; + conn = connect_by_classname(broker, CLASSNAME(reference), &s); + if (conn == NULL) { + if (is_get_inst) + cu_statusf(broker, &s, + CMPI_RC_ERR_NOT_FOUND, + "No such instance"); + + return s; + } + + inst = get_typed_instance(broker, + pfx_from_conn(conn), + "RedirectionService", + NAMESPACE(reference)); + + if (inst == NULL) { + CU_DEBUG("Failed to get typed instance"); + cu_statusf(broker, &s, + CMPI_RC_ERR_FAILED, + "Failed to create instance"); + goto out; + } + + s = get_host_system_properties(&name, + &ccname, + reference, + broker, + context); + if (s.rc != CMPI_RC_OK) { + cu_statusf(broker, &s, + CMPI_RC_ERR_FAILED, + "Unable to get host attributes"); + goto out; + } + + CMSetProperty(inst, "Name", + (CMPIValue *)"Redirection Service", CMPI_chars); + + CMSetProperty(inst, "SystemName", + (CMPIValue *)name, CMPI_chars); + + CMSetProperty(inst, "SystemCreationClassName", + (CMPIValue *)ccname, CMPI_chars); + + CMSetProperty(inst, "ElementName", + (CMPIValue *)"Redirection Service", CMPI_chars); + + array = CMNewArray(broker, 1, CMPI_uint16, &s); + if ((s.rc != CMPI_RC_OK) || CMIsNullObject(array)) + goto out; + + prop_val = (uint16_t)SERVICE_TYPE; + CMSetArrayElementAt(array, 0, &prop_val, CMPI_uint16); + + CMSetProperty(inst, "RedirectionServiceType", + (CMPIValue *)&array, CMPI_uint16A); + + prop_val = (uint16_t) virConnectNumOfDomains(conn) + + (uint16_t) virConnectNumOfDefinedDomains(conn); + + CMSetProperty(inst, "MaxConcurrentEnabledSAPs", + (CMPIValue *)&prop_val, CMPI_uint16); + + prop_val = (uint16_t)SHARING_MODE; + CMSetProperty(inst, "SharingMode", + (CMPIValue *)&prop_val, CMPI_uint16); + + prop_val = (uint16_t)ENABLED_STATE; + CMSetProperty(inst, "EnabledState", + (CMPIValue *)&prop_val, CMPI_uint16); + + prop_val = (uint16_t)REQUESTED_STATE; + CMSetProperty(inst, "RequestedState", + (CMPIValue *)&prop_val, CMPI_uint16); + + if (is_get_inst) { + s = cu_validate_ref(broker, reference, inst); + if (s.rc != CMPI_RC_OK) + goto out; + } + + cu_statusf(broker, &s, + CMPI_RC_OK, + ""); + out: + virConnectClose(conn); + *_inst = inst; + + return s; +} + +static CMPIStatus return_rs(const CMPIContext *context, + const CMPIObjectPath *reference, + const CMPIResult *results, + bool name_only, + bool is_get_inst) +{ + CMPIStatus s = {CMPI_RC_OK, NULL}; + CMPIInstance *inst; + + s = get_rs(reference, &inst, _BROKER, context, is_get_inst); + if (s.rc != CMPI_RC_OK || inst == NULL) + goto out; + + if (name_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(context, reference, results, true, false); +} + +static CMPIStatus EnumInstances(CMPIInstanceMI *self, + const CMPIContext *context, + const CMPIResult *results, + const CMPIObjectPath *reference, + const char **properties) +{ + + return return_rs(context, reference, results, false, false); +} + +static CMPIStatus GetInstance(CMPIInstanceMI *self, + const CMPIContext *context, + const CMPIResult *results, + const CMPIObjectPath *ref, + const char **properties) +{ + return return_rs(context, ref, results, false, true); +} + +DEFAULT_CI(); +DEFAULT_MI(); +DEFAULT_DI(); +DEFAULT_EQ(); +DEFAULT_INST_CLEANUP(); + +STD_InstanceMIStub(, + Virt_RedirectionService, + _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> +#define SERVICE_TYPE 3 KR> +#define SHARING_MODE 3 KR> + KR> +#define ENABLED_STATE 2 KR> +#define REQUESTED_STATE 12 Should these be prefixed by SVPC_ and put in svpc_types.h? KR> +static CMPIStatus get_rs(const CMPIObjectPath *reference, KR> + CMPIInstance **_inst, KR> + const CMPIBroker *broker, KR> + const CMPIContext *context, KR> + bool is_get_inst) KR> +{ KR> + CMPIStatus s = {CMPI_RC_OK, NULL}; KR> + virConnectPtr conn = NULL; KR> + CMPIInstance *inst = NULL; KR> + CMPIArray *array; KR> + const char *name = NULL; KR> + const char *ccname = NULL; KR> + uint16_t prop_val; KR> + KR> + *_inst = NULL; KR> + conn = connect_by_classname(broker, CLASSNAME(reference), &s); KR> + if (conn == NULL) { KR> + if (is_get_inst) KR> + cu_statusf(broker, &s, KR> + CMPI_RC_ERR_NOT_FOUND, KR> + "No such instance"); KR> + KR> + return s; KR> + } KR> + KR> + inst = get_typed_instance(broker, KR> + pfx_from_conn(conn), KR> + "RedirectionService", KR> + NAMESPACE(reference)); KR> + KR> + if (inst == NULL) { KR> + CU_DEBUG("Failed to get typed instance"); KR> + cu_statusf(broker, &s, KR> + CMPI_RC_ERR_FAILED, KR> + "Failed to create instance"); KR> + goto out; KR> + } KR> + KR> + s = get_host_system_properties(&name, KR> + &ccname, KR> + reference, KR> + broker, KR> + context); KR> + if (s.rc != CMPI_RC_OK) { KR> + cu_statusf(broker, &s, KR> + CMPI_RC_ERR_FAILED, KR> + "Unable to get host attributes"); KR> + goto out; KR> + } KR> + KR> + CMSetProperty(inst, "Name", KR> + (CMPIValue *)"Redirection Service", CMPI_chars); KR> + KR> + CMSetProperty(inst, "SystemName", KR> + (CMPIValue *)name, CMPI_chars); KR> + KR> + CMSetProperty(inst, "SystemCreationClassName", KR> + (CMPIValue *)ccname, CMPI_chars); KR> + KR> + CMSetProperty(inst, "ElementName", KR> + (CMPIValue *)"Redirection Service", CMPI_chars); KR> + This function already has a lot packed into it. Should we break out the high-level pieces a bit? KR> + array = CMNewArray(broker, 1, CMPI_uint16, &s); KR> + if ((s.rc != CMPI_RC_OK) || CMIsNullObject(array)) KR> + goto out; KR> + KR> + prop_val = (uint16_t)SERVICE_TYPE; KR> + CMSetArrayElementAt(array, 0, &prop_val, CMPI_uint16); KR> + KR> + CMSetProperty(inst, "RedirectionServiceType", KR> + (CMPIValue *)&array, CMPI_uint16A); KR> + KR> + prop_val = (uint16_t) virConnectNumOfDomains(conn) + KR> + (uint16_t) virConnectNumOfDefinedDomains(conn); If one or more of these fail, you'll get an incorrect count, and potentially a negative value. Since your prop_val is unsigned, this could result in exposing 65535 (or so) "MaxCurrentEnabledSAPs", which isn't quite right. -- Dan Smith IBM Linux Technology Center Open Hypervisor Team email: danms@us.ibm.com
participants (2)
-
Dan Smith
-
Kaitlin Rupert