
# HG changeset patch # User Kaitlin Rupert <karupert@us.ibm.com> # Date 1227634876 28800 # Node ID 8a1f369f8f70a23eea6771ed09cd06ce74992be2 # Parent 145a9c11532328a4dccaa1f42cd91e8bfbda9446 Add input support to DefneSystem() Signed-off-by: Kaitlin Rupert <karupert@us.ibm.com> diff -r 145a9c115323 -r 8a1f369f8f70 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,39 @@ return true; } +static bool default_input_device(struct domain *domain) +{ + 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_LXC) { + domain->dev_input->dev.input.bus = strdup("usb"); + } else 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 +626,50 @@ return msg; } +static const char *input_rasd_to_vdev(CMPIInstance *inst, + struct virt_device *dev) +{ + CMPIObjectPath *op = NULL; + const char *val; + const char *msg; + char *type = NULL; + char *bus = NULL; + char *vtype = NULL; + + 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); + + op = CMGetObjectPath(inst, NULL); + if (op == NULL) { + CU_DEBUG("Unable to determine class of InputRASD"); + return NULL; + } + + if ((cu_get_str_prop(inst, "Caption", &val) != CMPI_RC_OK) || + (get_input_type_bus_from_cap(val, &type, &bus, &vtype) != 1)) { + 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(bus); + + out: + free(type); + free(bus); + free(vtype); + + return NULL; +} + static const char *_sysvirt_rasd_to_vdev(CMPIInstance *inst, struct virt_device *dev, uint16_t type, @@ -612,6 +685,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 +707,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 +815,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 +883,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)