[PATCH 0 of 3] Add input support to VSMS

# HG changeset patch # User Kaitlin Rupert <karupert@us.ibm.com> # Date 1227634876 28800 # Node ID a68ad94610cd4681a93803f065be88f728c88d9d # Parent f21e9ebf0ad0573bf55be7c16a9d32a07d9ac899 (#2) Add input support to xmlgen, add BusType attribute to InputRASD Updates from 1 to 2: -Instead of pulling the bus type from the RASD caption, add a BusType attribute to the InputRASD mof. Signed-off-by: Kaitlin Rupert <karupert@us.ibm.com> diff -r f21e9ebf0ad0 -r a68ad94610cd libxkutil/xmlgen.c --- a/libxkutil/xmlgen.c Mon Nov 24 13:06:18 2008 -0800 +++ b/libxkutil/xmlgen.c Tue Nov 25 09:41:16 2008 -0800 @@ -383,6 +383,26 @@ return true; } +static bool input_to_xml(char **xml, struct virt_device *dev) +{ + int ret; + char *_xml; + struct input_device *input = &dev->dev.input; + + ret = asprintf(&_xml, + "<input type='%s' bus='%s'/>\n", + input->type != NULL ? input->type: "mouse", + input->bus != NULL ? input->bus : "ps2"); + if (ret == -1) + return false; + else + astrcat(xml, _xml); + + free(_xml); + + return true; +} + static bool concat_devxml(char **xml, struct virt_device *list, int count, @@ -430,6 +450,9 @@ break; case CIM_RES_TYPE_GRAPHICS: func = graphics_to_xml; + break; + case CIM_RES_TYPE_INPUT: + func = input_to_xml; break; default: return NULL; @@ -706,6 +729,12 @@ dominfo->dev_graphics_ct, graphics_to_xml); + if (dominfo->dev_input) + concat_devxml(&devxml, + dominfo->dev_input, + dominfo->dev_input_ct, + input_to_xml); + console_xml(dominfo, &devxml); concat_devxml(&sysdevxml, diff -r f21e9ebf0ad0 -r a68ad94610cd schema/ResourceAllocationSettingData.mof --- a/schema/ResourceAllocationSettingData.mof Mon Nov 24 13:06:18 2008 -0800 +++ b/schema/ResourceAllocationSettingData.mof Tue Nov 25 09:41:16 2008 -0800 @@ -144,6 +144,7 @@ ] class Xen_InputResourceAllocationSettingData : Xen_ResourceAllocationSettingData { + string BusType; }; [Description ("KVM virtual input device"), @@ -151,6 +152,7 @@ ] class KVM_InputResourceAllocationSettingData : KVM_ResourceAllocationSettingData { + string BusType; }; [Description ("LXC virtual input device"), @@ -158,5 +160,6 @@ ] class LXC_InputResourceAllocationSettingData : LXC_ResourceAllocationSettingData { + string BusType; }; diff -r f21e9ebf0ad0 -r a68ad94610cd src/Virt_RASD.c --- a/src/Virt_RASD.c Mon Nov 24 13:06:18 2008 -0800 +++ b/src/Virt_RASD.c Tue Nov 25 09:41:16 2008 -0800 @@ -314,6 +314,9 @@ CMSetProperty(inst, "ResourceSubType", (CMPIValue *)dev->dev.input.type, CMPI_chars); + + CMSetProperty(inst, "BusType", + (CMPIValue *)dev->dev.input.bus, CMPI_chars); CMSetProperty(inst, "Caption", (CMPIValue *)cap, CMPI_chars); diff -r f21e9ebf0ad0 -r a68ad94610cd src/Virt_SettingsDefineCapabilities.c --- a/src/Virt_SettingsDefineCapabilities.c Mon Nov 24 13:06:18 2008 -0800 +++ b/src/Virt_SettingsDefineCapabilities.c Tue Nov 25 09:41:16 2008 -0800 @@ -793,6 +793,8 @@ CMSetProperty(inst, "ResourceSubType", (CMPIValue *)type, CMPI_chars); + CMSetProperty(inst, "BusType", (CMPIValue *)bus, CMPI_chars); + CMSetProperty(inst, "Caption", (CMPIValue *)cap, CMPI_chars); inst_list_add(list, inst);

# HG changeset patch # User Kaitlin Rupert <karupert@us.ibm.com> # Date 1227634876 28800 # Node ID fe6053054641c236a51fe3ebe861f7ddeb7aaaa2 # Parent a68ad94610cd4681a93803f065be88f728c88d9d (#2) Add input support to DefneSystem() Updates from 1 to 2: -Remove LXC default input device -Get the bus type from the BusType attribute Signed-off-by: Kaitlin Rupert <karupert@us.ibm.com> diff -r a68ad94610cd -r fe6053054641 src/Virt_VirtualSystemManagementService.c --- a/src/Virt_VirtualSystemManagementService.c Tue Nov 25 09:41:16 2008 -0800 +++ b/src/Virt_VirtualSystemManagementService.c Tue Nov 25 09:41:16 2008 -0800 @@ -229,10 +229,40 @@ return true; } +static bool default_input_device(struct domain *domain) +{ + if (domain->type == DOMAIN_LXC) + return true; + + free(domain->dev_input); + domain->dev_input = calloc(1, sizeof(*domain->dev_input)); + if (domain->dev_input == NULL) { + CU_DEBUG("Failed to allocate default input device"); + return false; + } + + domain->dev_input->dev.input.type = strdup("mouse"); + + if (domain->type == DOMAIN_XENPV) { + domain->dev_input->dev.input.bus = strdup("xen"); + } else { + domain->dev_input->dev.input.bus = strdup("ps2"); + } + + domain->dev_input_ct = 1; + + return true; +} + static bool add_default_devs(struct domain *domain) { if (domain->dev_graphics_ct != 1) { if (!default_graphics_device(domain)) + return false; + } + + if (domain->dev_input_ct < 1) { + if (!default_input_device(domain)) return false; } @@ -597,6 +627,35 @@ return msg; } +static const char *input_rasd_to_vdev(CMPIInstance *inst, + struct virt_device *dev) +{ + const char *val; + const char *msg; + + if (cu_get_str_prop(inst, "ResourceSubType", &val) != CMPI_RC_OK) { + msg = "InputRASD ResourceSubType field not valid"; + goto out; + } + dev->dev.input.type = strdup(val); + + if (cu_get_str_prop(inst, "BusType", &val) != CMPI_RC_OK) { + if (STREQC(dev->dev.input.type, "mouse")) + dev->dev.input.bus = strdup("ps2"); + else if (STREQC(dev->dev.input.type, "tablet")) + dev->dev.input.bus = strdup("usb"); + else { + msg = "Invalid value for ResourceSubType in InputRASD"; + goto out; + } + } else + dev->dev.input.bus = strdup(val); + + out: + + return NULL; +} + static const char *_sysvirt_rasd_to_vdev(CMPIInstance *inst, struct virt_device *dev, uint16_t type, @@ -612,6 +671,8 @@ return proc_rasd_to_vdev(inst, dev); } else if (type == CIM_RES_TYPE_GRAPHICS) { return graphics_rasd_to_vdev(inst, dev); + } else if (type == CIM_RES_TYPE_INPUT) { + return input_rasd_to_vdev(inst, dev); } return "Resource type not supported on this platform"; @@ -632,6 +693,8 @@ return lxc_proc_rasd_to_vdev(inst, dev); } else if (type == CIM_RES_TYPE_GRAPHICS) { return graphics_rasd_to_vdev(inst, dev); + } else if (type == CIM_RES_TYPE_INPUT) { + return input_rasd_to_vdev(inst, dev); } return "Resource type not supported on this platform"; @@ -738,6 +801,9 @@ if (!make_space(&domain->dev_graphics, domain->dev_graphics_ct, count)) return "Failed to alloc graphics list"; + if (!make_space(&domain->dev_input, domain->dev_input_ct, count)) + return "Failed to alloc input list"; + for (i = 0; i < count; i++) { CMPIObjectPath *op; CMPIData item; @@ -803,6 +869,12 @@ msg = rasd_to_vdev(inst, domain, &domain->dev_graphics[0], + ns); + } else if (type == CIM_RES_TYPE_INPUT) { + domain->dev_input_ct = 1; + msg = rasd_to_vdev(inst, + domain, + &domain->dev_input[0], ns); } if (msg != NULL)

# HG changeset patch # User Kaitlin Rupert <karupert@us.ibm.com> # Date 1228154445 28800 # Node ID 674c576418932981ae96a810c7083753cd7786bc # Parent fe6053054641c236a51fe3ebe861f7ddeb7aaaa2 Add input support to Mod/Del/Add methods. Signed-off-by: Kaitlin Rupert <karupert@us.ibm.com> diff -r fe6053054641 -r 674c57641893 src/Makefile.am --- a/src/Makefile.am Tue Nov 25 09:41:16 2008 -0800 +++ b/src/Makefile.am Mon Dec 01 10:00:45 2008 -0800 @@ -87,9 +87,9 @@ libVirt_ComputerSystemMigrationIndication_la_SOURCES = Virt_ComputerSystemMigrationIndication.c libVirt_ComputerSystemMigrationIndication_la_LIBADD = -lVirt_ComputerSystem -libVirt_VirtualSystemManagementService_la_DEPENDENCIES = libVirt_ComputerSystem.la libVirt_ComputerSystemIndication.la libVirt_RASD.la libVirt_HostSystem.la libVirt_DevicePool.la +libVirt_VirtualSystemManagementService_la_DEPENDENCIES = libVirt_ComputerSystem.la libVirt_ComputerSystemIndication.la libVirt_RASD.la libVirt_HostSystem.la libVirt_DevicePool.la libVirt_Device.la libVirt_VirtualSystemManagementService_la_SOURCES = Virt_VirtualSystemManagementService.c -libVirt_VirtualSystemManagementService_la_LIBADD = -lVirt_ComputerSystem -lVirt_ComputerSystemIndication -lVirt_RASD -lVirt_HostSystem -lVirt_DevicePool +libVirt_VirtualSystemManagementService_la_LIBADD = -lVirt_ComputerSystem -lVirt_ComputerSystemIndication -lVirt_RASD -lVirt_HostSystem -lVirt_DevicePool -lVirt_Device libVirt_VirtualSystemManagementCapabilities_la_DEPENDENCIES = libVirt_HostSystem.la libVirt_VirtualSystemManagementCapabilities_la_SOURCES = Virt_VirtualSystemManagementCapabilities.c diff -r fe6053054641 -r 674c57641893 src/Virt_VirtualSystemManagementService.c --- a/src/Virt_VirtualSystemManagementService.c Tue Nov 25 09:41:16 2008 -0800 +++ b/src/Virt_VirtualSystemManagementService.c Mon Dec 01 10:00:45 2008 -0800 @@ -50,6 +50,7 @@ #include "Virt_RASD.h" #include "Virt_HostSystem.h" #include "Virt_DevicePool.h" +#include "Virt_Device.h" #include "svpc_types.h" #include "config.h" @@ -1404,6 +1405,9 @@ } else if (type == CIM_RES_TYPE_GRAPHICS) { list = &dominfo->dev_graphics; *count = &dominfo->dev_graphics_ct; + } else if (type == CIM_RES_TYPE_INPUT) { + list = &dominfo->dev_input; + *count = &dominfo->dev_input_ct; } return list; @@ -1522,7 +1526,8 @@ if (STREQ(dev->id, devid)) { dev->type = CIM_RES_TYPE_UNKNOWN; - if (type == CIM_RES_TYPE_GRAPHICS) + if ((type == CIM_RES_TYPE_GRAPHICS) || + (type == CIM_RES_TYPE_INPUT)) cu_statusf(_BROKER, &s, CMPI_RC_OK, ""); else { s = _resource_dynamic(dominfo, @@ -1598,7 +1603,7 @@ dev->type = type; rasd_to_vdev(rasd, dominfo, dev, ns); - if (type == CIM_RES_TYPE_GRAPHICS) { + if ((type == CIM_RES_TYPE_GRAPHICS) || (type == CIM_RES_TYPE_INPUT)) { (*count)++; cu_statusf(_BROKER, &s, CMPI_RC_OK, ""); goto out; @@ -1661,7 +1666,8 @@ if (STREQ(dev->id, devid)) { rasd_to_vdev(rasd, dominfo, dev, ns); - if (type == CIM_RES_TYPE_GRAPHICS) + if ((type == CIM_RES_TYPE_GRAPHICS) || + (type == CIM_RES_TYPE_INPUT)) cu_statusf(_BROKER, &s, CMPI_RC_OK, ""); else { s = _resource_dynamic(dominfo,
participants (1)
-
Kaitlin Rupert