static int xenParseXMInputDevs(virConfPtr conf, virDomainDefPtr def) { const char *str; if (def->os.type == VIR_DOMAIN_OSTYPE_HVM) { if (xenConfigGetString(conf, "usbdevice", &str, NULL) < 0) return -1; if (str && (STREQ(str, "tablet") || STREQ(str, "mouse") || STREQ(str, "keyboard"))) { virDomainInputDefPtr input; if (VIR_ALLOC(input) < 0) return -1; input->bus = VIR_DOMAIN_INPUT_BUS_USB; if (STREQ(str, "mouse")) input->type = VIR_DOMAIN_INPUT_TYPE_MOUSE; else if (STREQ(str, "tablet")) input->type = VIR_DOMAIN_INPUT_TYPE_TABLET; else if (STREQ(str, "keyboard")) input->type = VIR_DOMAIN_INPUT_TYPE_KBD; if (VIR_APPEND_ELEMENT(def->inputs, def->ninputs, input) < 0) { virDomainInputDefFree(input); return -1; } } } return 0; }
static int xenParseXLInputDevs(virConfPtr conf, virDomainDefPtr def) { const char *str; virConfValuePtr val; if (def->os.type == VIR_DOMAIN_OSTYPE_HVM) { val = virConfGetValue(conf, "usbdevice"); /* usbdevice can be defined as either a single string or a list */ if (val && val->type == VIR_CONF_LIST) { #ifdef LIBXL_HAVE_BUILDINFO_USBDEVICE_LIST val = val->list; #else virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", _("multiple USB devices not supported")); return -1; #endif } /* otherwise val->next is NULL, so can be handled by the same code */ while (val) { if (val->type != VIR_CONF_STRING) { virReportError(VIR_ERR_INTERNAL_ERROR, _("config value %s was malformed"), "usbdevice"); return -1; } str = val->str; if (str && (STREQ(str, "tablet") || STREQ(str, "mouse") || STREQ(str, "keyboard"))) { virDomainInputDefPtr input; if (VIR_ALLOC(input) < 0) return -1; input->bus = VIR_DOMAIN_INPUT_BUS_USB; if (STREQ(str, "mouse")) input->type = VIR_DOMAIN_INPUT_TYPE_MOUSE; else if (STREQ(str, "tablet")) input->type = VIR_DOMAIN_INPUT_TYPE_TABLET; else if (STREQ(str, "keyboard")) input->type = VIR_DOMAIN_INPUT_TYPE_KBD; if (VIR_APPEND_ELEMENT(def->inputs, def->ninputs, input) < 0) { virDomainInputDefFree(input); return -1; } } val = val->next; } } return 0; }