mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-23 06:05:27 +00:00
xen: format xen config for USB keyboard
Signed-off-by: Li Zhang <zhlcindy@linux.vnet.ibm.com> Signed-off-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
parent
78730478aa
commit
2a81430c85
@ -724,21 +724,23 @@ xenParseSxprUSB(virDomainDefPtr def,
|
|||||||
tmp = sexpr_node(node, "usbdevice");
|
tmp = sexpr_node(node, "usbdevice");
|
||||||
if (tmp && *tmp) {
|
if (tmp && *tmp) {
|
||||||
if (STREQ(tmp, "tablet") ||
|
if (STREQ(tmp, "tablet") ||
|
||||||
STREQ(tmp, "mouse")) {
|
STREQ(tmp, "mouse") ||
|
||||||
|
STREQ(tmp, "keyboard")) {
|
||||||
virDomainInputDefPtr input;
|
virDomainInputDefPtr input;
|
||||||
if (VIR_ALLOC(input) < 0)
|
if (VIR_ALLOC(input) < 0)
|
||||||
goto error;
|
goto error;
|
||||||
input->bus = VIR_DOMAIN_INPUT_BUS_USB;
|
input->bus = VIR_DOMAIN_INPUT_BUS_USB;
|
||||||
if (STREQ(tmp, "tablet"))
|
if (STREQ(tmp, "tablet"))
|
||||||
input->type = VIR_DOMAIN_INPUT_TYPE_TABLET;
|
input->type = VIR_DOMAIN_INPUT_TYPE_TABLET;
|
||||||
else
|
else if (STREQ(tmp, "mouse"))
|
||||||
input->type = VIR_DOMAIN_INPUT_TYPE_MOUSE;
|
input->type = VIR_DOMAIN_INPUT_TYPE_MOUSE;
|
||||||
|
else
|
||||||
|
input->type = VIR_DOMAIN_INPUT_TYPE_KBD;
|
||||||
|
|
||||||
if (VIR_REALLOC_N(def->inputs, def->ninputs+1) < 0) {
|
if (VIR_APPEND_ELEMENT(def->inputs, def->ninputs, input) < 0) {
|
||||||
VIR_FREE(input);
|
VIR_FREE(input);
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
def->inputs[def->ninputs++] = input;
|
|
||||||
} else {
|
} else {
|
||||||
/* XXX Handle other non-input USB devices later */
|
/* XXX Handle other non-input USB devices later */
|
||||||
}
|
}
|
||||||
@ -2144,15 +2146,24 @@ xenFormatSxprInput(virDomainInputDefPtr input,
|
|||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if (input->type != VIR_DOMAIN_INPUT_TYPE_MOUSE &&
|
if (input->type != VIR_DOMAIN_INPUT_TYPE_MOUSE &&
|
||||||
input->type != VIR_DOMAIN_INPUT_TYPE_TABLET) {
|
input->type != VIR_DOMAIN_INPUT_TYPE_TABLET &&
|
||||||
|
input->type != VIR_DOMAIN_INPUT_TYPE_KBD) {
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
_("unexpected input type %d"), input->type);
|
_("unexpected input type %d"), input->type);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
virBufferAsprintf(buf, "(usbdevice %s)",
|
switch (input->type) {
|
||||||
input->type == VIR_DOMAIN_INPUT_TYPE_MOUSE ?
|
case VIR_DOMAIN_INPUT_TYPE_MOUSE:
|
||||||
"mouse" : "tablet");
|
virBufferAsprintf(buf, "(usbdevice %s)", "mouse");
|
||||||
|
break;
|
||||||
|
case VIR_DOMAIN_INPUT_TYPE_TABLET:
|
||||||
|
virBufferAsprintf(buf, "(usbdevice %s)", "tablet");
|
||||||
|
break;
|
||||||
|
case VIR_DOMAIN_INPUT_TYPE_KBD:
|
||||||
|
virBufferAsprintf(buf, "(usbdevice %s)", "keyboard");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -886,14 +886,18 @@ xenParseXM(virConfPtr conf, int xendConfigVersion,
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
if (str &&
|
if (str &&
|
||||||
(STREQ(str, "tablet") ||
|
(STREQ(str, "tablet") ||
|
||||||
STREQ(str, "mouse"))) {
|
STREQ(str, "mouse") ||
|
||||||
|
STREQ(str, "keyboard"))) {
|
||||||
virDomainInputDefPtr input;
|
virDomainInputDefPtr input;
|
||||||
if (VIR_ALLOC(input) < 0)
|
if (VIR_ALLOC(input) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
input->bus = VIR_DOMAIN_INPUT_BUS_USB;
|
input->bus = VIR_DOMAIN_INPUT_BUS_USB;
|
||||||
input->type = STREQ(str, "tablet") ?
|
if (STREQ(str, "mouse"))
|
||||||
VIR_DOMAIN_INPUT_TYPE_TABLET :
|
input->type = VIR_DOMAIN_INPUT_TYPE_MOUSE;
|
||||||
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_ALLOC_N(def->inputs, 1) < 0) {
|
if (VIR_ALLOC_N(def->inputs, 1) < 0) {
|
||||||
virDomainInputDefFree(input);
|
virDomainInputDefFree(input);
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
@ -1746,10 +1750,20 @@ virConfPtr xenFormatXM(virConnectPtr conn,
|
|||||||
if (def->inputs[i]->bus == VIR_DOMAIN_INPUT_BUS_USB) {
|
if (def->inputs[i]->bus == VIR_DOMAIN_INPUT_BUS_USB) {
|
||||||
if (xenXMConfigSetInt(conf, "usb", 1) < 0)
|
if (xenXMConfigSetInt(conf, "usb", 1) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
if (xenXMConfigSetString(conf, "usbdevice",
|
switch (def->inputs[i]->type) {
|
||||||
def->inputs[i]->type == VIR_DOMAIN_INPUT_TYPE_MOUSE ?
|
case VIR_DOMAIN_INPUT_TYPE_MOUSE:
|
||||||
"mouse" : "tablet") < 0)
|
if (xenXMConfigSetString(conf, "usbdevice", "mouse") < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
break;
|
||||||
|
case VIR_DOMAIN_INPUT_TYPE_TABLET:
|
||||||
|
if (xenXMConfigSetString(conf, "usbdevice", "tablet") < 0)
|
||||||
|
goto cleanup;
|
||||||
|
break;
|
||||||
|
case VIR_DOMAIN_INPUT_TYPE_KBD:
|
||||||
|
if (xenXMConfigSetString(conf, "usbdevice", "keyboard") < 0)
|
||||||
|
goto cleanup;
|
||||||
|
break;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user