
# HG changeset patch # User Kaitlin Rupert <karupert@us.ibm.com> # Date 1227634876 28800 # Node ID 145a9c11532328a4dccaa1f42cd91e8bfbda9446 # Parent db393eb037a0782d2e8328d2e2fd0582e185f08b Add input support to xmlgen, add get_input_type_bus_from_cap() to Virt_Device Signed-off-by: Kaitlin Rupert <karupert@us.ibm.com> diff -r db393eb037a0 -r 145a9c115323 libxkutil/xmlgen.c --- a/libxkutil/xmlgen.c Mon Nov 24 10:27:55 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 db393eb037a0 -r 145a9c115323 src/Virt_Device.c --- a/src/Virt_Device.c Mon Nov 24 10:27:55 2008 -0800 +++ b/src/Virt_Device.c Tue Nov 25 09:41:16 2008 -0800 @@ -254,6 +254,42 @@ } return 1; +} + +int get_input_type_bus_from_cap(const char *cap, + char **type, + char **bus, + char **virt_type) +{ + if (sscanf(cap, "%a[^ ] %a[^ ] %as", virt_type, bus, type) != 3) { + if (sscanf(cap, "%a[^ ] %as", bus, type) != 2) + goto out; + else { + free(*virt_type); + *virt_type = NULL; + } + } + + if (STREQC(*type, "Mouse")) + *type = strdup("mouse"); + else if (STREQC(*type, "Tablet")) + *type = strdup("tablet"); + else + goto out; + + if (STREQC(*bus, "USB")) + *bus = strdup("usb"); + else if (STREQC(*bus, "PS2")) + *bus = strdup("ps2"); + else if (STREQC(*bus, "Xen")) + *bus = strdup("xen"); + else + goto out; + + return 1; + + out: + return 0; } static int input_set_attr(CMPIInstance *instance, diff -r db393eb037a0 -r 145a9c115323 src/Virt_Device.h --- a/src/Virt_Device.h Mon Nov 24 10:27:55 2008 -0800 +++ b/src/Virt_Device.h Tue Nov 25 09:41:16 2008 -0800 @@ -75,6 +75,11 @@ const char *bus, char **cap); +int get_input_type_bus_from_cap(const char *cap, + char **type, + char **bus, + char **virt_type); + #endif /*