[libvirt] [PATCH v3 0/6] Support keyboard device

From: Li Zhang <zhlcindy@linux.vnet.ibm.com> This patchset is to add keyboard input device. For PPC64, it doesn't support a default keyboard device when the graphic is enabled. Libvirt supports QEMU command line as "-device VGA" which won't create any keyboard device for it. So it requires libvirt to add a default USB keyboard device for it. This patchset is to add keyboard input device and a default USB keyboard for PPC64. The related discussion in QEMU community: http://lists.nongnu.org/archive/html/qemu-devel/2013-11/msg01734.html Li Zhang (6): conf: Add a keyboard input device type conf: Add one interface to add input devices. Remove PS2 mouse device for non-X86 platforms qemu_cap: Add USB keyboard capability qemu: parse qemu command line for USB keyboard. Add a default USB keyboard for PPC64 v3 -> v2: * Handle the KBD device type in xen and QEMU driver. (Daniel.P.Berrange) * Remove PS2 mouse device for non-X86 platforms. * Move virDomainDefMaybeAddInput to a new patch. (Jan Tomko) * Replace VIR_REALLOC_N with VIR_APPEND_ELEMENT. (Jan Tomoko) * Fix several typos. (Jan Tomoko) * Add a virReportError when QEMU_CAPS_DEVICE_USB_KBD can't be gotten. (Jan Tomoko) v2 -> v1: * change ifs to switch clause. * reconstruct the patches docs/schemas/domaincommon.rng | 1 + src/conf/domain_conf.c | 91 ++++++++++++---------- src/conf/domain_conf.h | 5 ++ src/libvirt_private.syms | 1 + src/qemu/qemu_capabilities.c | 2 + src/qemu/qemu_capabilities.h | 1 + src/qemu/qemu_command.c | 41 +++++++--- src/qemu/qemu_domain.c | 29 ++++++- src/util/virarch.h | 2 + src/xenxs/xen_sxpr.c | 27 +++++-- src/xenxs/xen_xm.c | 30 +++++-- tests/qemucapabilitiesdata/caps_1.2.2-1.caps | 1 + tests/qemucapabilitiesdata/caps_1.3.1-1.caps | 1 + tests/qemucapabilitiesdata/caps_1.4.2-1.caps | 1 + tests/qemucapabilitiesdata/caps_1.5.3-1.caps | 1 + tests/qemucapabilitiesdata/caps_1.6.0-1.caps | 2 + tests/qemucapabilitiesdata/caps_1.6.50-1.caps | 1 + tests/qemuhelptest.c | 8 ++ .../qemuxml2argvdata/qemuxml2argv-pseries-disk.xml | 3 +- .../qemuxml2argv-pseries-usb-kbd.args | 9 +++ .../qemuxml2argv-pseries-usb-kbd.xml | 19 +++++ tests/qemuxml2argvtest.c | 3 + 22 files changed, 211 insertions(+), 68 deletions(-) create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-pseries-usb-kbd.args create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-pseries-usb-kbd.xml -- 1.8.2.1

From: Li Zhang <zhlcindy@linux.vnet.ibm.com> There is no keyboard for non-x86 platforms when graphics are enabled. It's preferred to add one USB keyboard. This patch is to add keyboard input device type. Signed-off-by: Li Zhang <zhlcindy@linux.vnet.ibm.com> --- docs/schemas/domaincommon.rng | 1 + src/conf/domain_conf.c | 3 ++- src/conf/domain_conf.h | 1 + 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng index 38c6801..964350d 100644 --- a/docs/schemas/domaincommon.rng +++ b/docs/schemas/domaincommon.rng @@ -3167,6 +3167,7 @@ <choice> <value>tablet</value> <value>mouse</value> + <value>kbd</value> </choice> </attribute> <optional> diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index b76cf26..f8b9639 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -504,7 +504,8 @@ VIR_ENUM_IMPL(virDomainVideo, VIR_DOMAIN_VIDEO_TYPE_LAST, VIR_ENUM_IMPL(virDomainInput, VIR_DOMAIN_INPUT_TYPE_LAST, "mouse", - "tablet") + "tablet", + "kbd") VIR_ENUM_IMPL(virDomainInputBus, VIR_DOMAIN_INPUT_BUS_LAST, "ps2", diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index 4934911..8aa5f50 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -1223,6 +1223,7 @@ struct _virDomainTPMDef { enum virDomainInputType { VIR_DOMAIN_INPUT_TYPE_MOUSE, VIR_DOMAIN_INPUT_TYPE_TABLET, + VIR_DOMAIN_INPUT_TYPE_KBD, VIR_DOMAIN_INPUT_TYPE_LAST }; -- 1.8.2.1

From: Li Zhang <zhlcindy@linux.vnet.ibm.com> This patch is to add one new interface to add input devices. Signed-off-by: Li Zhang <zhlcindy@linux.vnet.ibm.com> --- src/conf/domain_conf.c | 29 +++++++++++++++++++++++++++++ src/conf/domain_conf.h | 4 ++++ src/libvirt_private.syms | 1 + 3 files changed, 34 insertions(+) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index f8b9639..82339ea 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -10822,6 +10822,35 @@ virDomainDefMaybeAddController(virDomainDefPtr def, return 0; } +int +virDomainDefMaybeAddInput(virDomainDefPtr def, + int type, + int bus) +{ + size_t i; + virDomainInputDefPtr input; + + for (i = 0; i < def->ninputs; i++) { + if (def->inputs[i]->type == type && + def->inputs[i]->bus == bus) + return 0; + } + + if (VIR_ALLOC(input) < 0) + return -1; + + input->type = type; + input->bus = bus; + + if (VIR_APPEND_ELEMENT(def->inputs, def->ninputs, input) < 0) { + VIR_FREE(input); + return -1; + } + + return 0; +} + + /* Parse a memory element located at XPATH within CTXT, and store the * result into MEM. If REQUIRED, then the value must exist; diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index 8aa5f50..8616066 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -2764,6 +2764,10 @@ virDomainDefMaybeAddController(virDomainDefPtr def, int type, int idx, int model); +int +virDomainDefMaybeAddInput(virDomainDefPtr def, + int type, + int bus); char *virDomainDefGetDefaultEmulator(virDomainDefPtr def, virCapsPtr caps); diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index b2c7a8e..e37931c 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -165,6 +165,7 @@ virDomainDefGenSecurityLabelDef; virDomainDefGetDefaultEmulator; virDomainDefGetSecurityLabelDef; virDomainDefMaybeAddController; +virDomainDefMaybeAddInput; virDomainDefNew; virDomainDefParseFile; virDomainDefParseNode; -- 1.8.2.1

From: Li Zhang <zhlcindy@linux.vnet.ibm.com> PS2 device only works for X86 platform, other platforms may need USB mouse. Athough it doesn't influence the QEMU command line, but It's not right to add one PS2 mouse for non-X86 platform. This patch is to remove PS2 device definition from other platforms. Add one default USB mouse for PPC64. It can be also added for other platforms if necessary. Signed-off-by: Li Zhang <zhlcindy@linux.vnet.ibm.com> --- src/conf/domain_conf.c | 59 ++++++++-------------- src/qemu/qemu_domain.c | 20 +++++++- src/util/virarch.h | 2 + .../qemuxml2argvdata/qemuxml2argv-pseries-disk.xml | 2 +- 4 files changed, 42 insertions(+), 41 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 82339ea..e53a786 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -7567,7 +7567,7 @@ error: /* Parse the XML definition for an input device */ static virDomainInputDefPtr -virDomainInputDefParseXML(const char *ostype, +virDomainInputDefParseXML(const virDomainDef *dom, xmlNodePtr node, unsigned int flags) { @@ -7600,7 +7600,7 @@ virDomainInputDefParseXML(const char *ostype, goto error; } - if (STREQ(ostype, "hvm")) { + if (STREQ(dom->os.type, "hvm")) { if (def->bus == VIR_DOMAIN_INPUT_BUS_PS2 && /* Only allow mouse for ps2 */ def->type != VIR_DOMAIN_INPUT_TYPE_MOUSE) { virReportError(VIR_ERR_INTERNAL_ERROR, @@ -7628,8 +7628,9 @@ virDomainInputDefParseXML(const char *ostype, } } } else { - if (STREQ(ostype, "hvm")) { - if (def->type == VIR_DOMAIN_INPUT_TYPE_MOUSE) + if (STREQ(dom->os.type, "hvm")) { + if (def->type == VIR_DOMAIN_INPUT_TYPE_MOUSE && + ARCH_IS_X86(dom->os.arch)) def->bus = VIR_DOMAIN_INPUT_BUS_PS2; else def->bus = VIR_DOMAIN_INPUT_BUS_USB; @@ -9631,7 +9632,7 @@ virDomainDeviceDefParse(const char *xmlStr, goto error; break; case VIR_DOMAIN_DEVICE_INPUT: - if (!(dev->data.input = virDomainInputDefParseXML(def->os.type, + if (!(dev->data.input = virDomainInputDefParseXML(def, node, flags))) goto error; break; @@ -12211,7 +12212,7 @@ virDomainDefParseXML(xmlDocPtr xml, goto error; for (i = 0; i < n; i++) { - virDomainInputDefPtr input = virDomainInputDefParseXML(def->os.type, + virDomainInputDefPtr input = virDomainInputDefParseXML(def, nodes[i], flags); if (!input) @@ -12230,9 +12231,11 @@ virDomainDefParseXML(xmlDocPtr xml, * with graphics, so don't store it. * XXX will this be true for other virt types ? */ if ((STREQ(def->os.type, "hvm") && + ARCH_IS_X86(def->os.arch) && input->bus == VIR_DOMAIN_INPUT_BUS_PS2 && input->type == VIR_DOMAIN_INPUT_TYPE_MOUSE) || (STRNEQ(def->os.type, "hvm") && + ARCH_IS_X86(def->os.arch) && input->bus == VIR_DOMAIN_INPUT_BUS_XEN && input->type == VIR_DOMAIN_INPUT_TYPE_MOUSE)) { virDomainInputDefFree(input); @@ -12260,30 +12263,6 @@ virDomainDefParseXML(xmlDocPtr xml, } VIR_FREE(nodes); - /* If graphics are enabled, there's an implicit PS2 mouse */ - if (def->ngraphics > 0) { - virDomainInputDefPtr input; - - if (VIR_ALLOC(input) < 0) { - goto error; - } - if (STREQ(def->os.type, "hvm")) { - input->type = VIR_DOMAIN_INPUT_TYPE_MOUSE; - input->bus = VIR_DOMAIN_INPUT_BUS_PS2; - } else { - input->type = VIR_DOMAIN_INPUT_TYPE_MOUSE; - input->bus = VIR_DOMAIN_INPUT_BUS_XEN; - } - - if (VIR_REALLOC_N(def->inputs, def->ninputs + 1) < 0) { - virDomainInputDefFree(input); - goto error; - } - def->inputs[def->ninputs] = input; - def->ninputs++; - } - - /* analysis of the sound devices */ if ((n = virXPathNodeSet("./devices/sound", ctxt, &nodes)) < 0) { goto error; @@ -17201,15 +17180,17 @@ virDomainDefFormatInternal(virDomainDefPtr def, if (def->ngraphics > 0) { /* If graphics is enabled, add the implicit mouse */ - virDomainInputDef autoInput = { - VIR_DOMAIN_INPUT_TYPE_MOUSE, - STREQ(def->os.type, "hvm") ? - VIR_DOMAIN_INPUT_BUS_PS2 : VIR_DOMAIN_INPUT_BUS_XEN, - { .alias = NULL }, - }; - - if (virDomainInputDefFormat(buf, &autoInput, flags) < 0) - goto error; + if (ARCH_IS_X86(def->os.arch)) { + virDomainInputDef autoInput = { + VIR_DOMAIN_INPUT_TYPE_MOUSE, + STREQ(def->os.type, "hvm") ? + VIR_DOMAIN_INPUT_BUS_PS2 : VIR_DOMAIN_INPUT_BUS_XEN, + { .alias = NULL }, + }; + if (virDomainInputDefFormat(buf, &autoInput, flags) < 0) + goto error; + } + for (n = 0; n < def->ngraphics; n++) if (virDomainGraphicsDefFormat(buf, def->graphics[n], flags) < 0) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 346fec3..75e615a 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -691,6 +691,8 @@ qemuDomainDefPostParse(virDomainDefPtr def, bool addPCIRoot = false; bool addPCIeRoot = false; bool addDefaultMemballoon = true; + bool addDefaultMouse = false; + int mouse_bus = VIR_DOMAIN_INPUT_BUS_XEN; /* check for emulator and create a default one if needed */ if (!def->emulator && @@ -721,6 +723,9 @@ qemuDomainDefPostParse(virDomainDefPtr def, !STRPREFIX(def->os.machine, "rhel")) break; addPCIRoot = true; + addDefaultMouse = true; + if (STREQ(def->os.type, "hvm")) + mouse_bus = VIR_DOMAIN_INPUT_BUS_PS2; break; case VIR_ARCH_ARMV7L: @@ -728,9 +733,15 @@ qemuDomainDefPostParse(virDomainDefPtr def, addDefaultMemballoon = false; break; + case VIR_ARCH_PPC64: + addPCIRoot = true; + addDefaultMouse = true; + if (STREQ(def->os.type, "hvm")) + mouse_bus = VIR_DOMAIN_INPUT_BUS_USB; + break; + case VIR_ARCH_ALPHA: case VIR_ARCH_PPC: - case VIR_ARCH_PPC64: case VIR_ARCH_PPCEMB: case VIR_ARCH_SH4: case VIR_ARCH_SH4EB: @@ -783,6 +794,13 @@ qemuDomainDefPostParse(virDomainDefPtr def, def->memballoon = memballoon; } + if (def->ngraphics > 0 && addDefaultMouse) { + if (virDomainDefMaybeAddInput(def, + VIR_DOMAIN_INPUT_TYPE_MOUSE, + mouse_bus) < 0) + return -1; + } + return 0; } diff --git a/src/util/virarch.h b/src/util/virarch.h index b180400..9b66e43 100644 --- a/src/util/virarch.h +++ b/src/util/virarch.h @@ -70,6 +70,8 @@ typedef enum { VIR_ARCH_LAST, } virArch; +#define ARCH_IS_X86(arch) ((arch) == VIR_ARCH_X86_64 ||\ + (arch) == VIR_ARCH_I686) typedef enum { VIR_ARCH_LITTLE_ENDIAN, diff --git a/tests/qemuxml2argvdata/qemuxml2argv-pseries-disk.xml b/tests/qemuxml2argvdata/qemuxml2argv-pseries-disk.xml index dbbd6aa..117213d 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-pseries-disk.xml +++ b/tests/qemuxml2argvdata/qemuxml2argv-pseries-disk.xml @@ -30,7 +30,7 @@ <controller type='usb' index='0'/> <controller type='scsi' index='0'/> <controller type='pci' index='0' model='pci-root'/> - <input type='mouse' bus='ps2'/> + <input type='mouse' bus='usb'/> <graphics type='sdl'/> <video> <model type='cirrus' vram='9216' heads='1'/> -- 1.8.2.1

On 12/10/2013 07:02 AM, Li Zhang wrote:
From: Li Zhang <zhlcindy@linux.vnet.ibm.com>
PS2 device only works for X86 platform, other platforms may need USB mouse. Athough it doesn't influence the QEMU command line, but It's not right to add one PS2 mouse for non-X86 platform.
This patch is to remove PS2 device definition from other platforms. Add one default USB mouse for PPC64. It can be also added for other platforms if necessary.
Signed-off-by: Li Zhang <zhlcindy@linux.vnet.ibm.com> --- src/conf/domain_conf.c | 59 ++++++++-------------- src/qemu/qemu_domain.c | 20 +++++++- src/util/virarch.h | 2 + .../qemuxml2argvdata/qemuxml2argv-pseries-disk.xml | 2 +- 4 files changed, 42 insertions(+), 41 deletions(-)
@@ -12260,30 +12263,6 @@ virDomainDefParseXML(xmlDocPtr xml, } VIR_FREE(nodes);
- /* If graphics are enabled, there's an implicit PS2 mouse */ - if (def->ngraphics > 0) { - virDomainInputDefPtr input; - - if (VIR_ALLOC(input) < 0) { - goto error; - } - if (STREQ(def->os.type, "hvm")) { - input->type = VIR_DOMAIN_INPUT_TYPE_MOUSE; - input->bus = VIR_DOMAIN_INPUT_BUS_PS2; - } else { - input->type = VIR_DOMAIN_INPUT_TYPE_MOUSE; - input->bus = VIR_DOMAIN_INPUT_BUS_XEN; - } - - if (VIR_REALLOC_N(def->inputs, def->ninputs + 1) < 0) { - virDomainInputDefFree(input); - goto error; - } - def->inputs[def->ninputs] = input; - def->ninputs++; - } - -
Here you remove auto-adding of the mouse for all drivers, but only re-add it to the QEMU driver, leading to failures in sexpr2xmltest.
/* analysis of the sound devices */ if ((n = virXPathNodeSet("./devices/sound", ctxt, &nodes)) < 0) { goto error; @@ -17201,15 +17180,17 @@ virDomainDefFormatInternal(virDomainDefPtr def,
if (def->ngraphics > 0) { /* If graphics is enabled, add the implicit mouse */ - virDomainInputDef autoInput = { - VIR_DOMAIN_INPUT_TYPE_MOUSE, - STREQ(def->os.type, "hvm") ? - VIR_DOMAIN_INPUT_BUS_PS2 : VIR_DOMAIN_INPUT_BUS_XEN, - { .alias = NULL }, - }; - - if (virDomainInputDefFormat(buf, &autoInput, flags) < 0) - goto error; + if (ARCH_IS_X86(def->os.arch)) { + virDomainInputDef autoInput = { + VIR_DOMAIN_INPUT_TYPE_MOUSE, + STREQ(def->os.type, "hvm") ? + VIR_DOMAIN_INPUT_BUS_PS2 : VIR_DOMAIN_INPUT_BUS_XEN, + { .alias = NULL }, + }; + if (virDomainInputDefFormat(buf, &autoInput, flags) < 0) + goto error; + } +
for (n = 0; n < def->ngraphics; n++) if (virDomainGraphicsDefFormat(buf, def->graphics[n], flags) < 0)
Hmm, if non-USB input devices get skipped when generating the command line and when formatting the XML, I wonder why are we adding it there in the first place.
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 346fec3..75e615a 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -691,6 +691,8 @@ qemuDomainDefPostParse(virDomainDefPtr def, bool addPCIRoot = false; bool addPCIeRoot = false; bool addDefaultMemballoon = true; + bool addDefaultMouse = false; + int mouse_bus = VIR_DOMAIN_INPUT_BUS_XEN;
/* check for emulator and create a default one if needed */ if (!def->emulator && @@ -721,6 +723,9 @@ qemuDomainDefPostParse(virDomainDefPtr def, !STRPREFIX(def->os.machine, "rhel")) break; addPCIRoot = true; + addDefaultMouse = true; + if (STREQ(def->os.type, "hvm")) + mouse_bus = VIR_DOMAIN_INPUT_BUS_PS2;
os.type has to be "hvm" in the qemu driver.
break;
case VIR_ARCH_ARMV7L:
Jan

On 2013年12月11日 00:17, Ján Tomko wrote:
On 12/10/2013 07:02 AM, Li Zhang wrote:
From: Li Zhang <zhlcindy@linux.vnet.ibm.com>
PS2 device only works for X86 platform, other platforms may need USB mouse. Athough it doesn't influence the QEMU command line, but It's not right to add one PS2 mouse for non-X86 platform.
This patch is to remove PS2 device definition from other platforms. Add one default USB mouse for PPC64. It can be also added for other platforms if necessary.
Signed-off-by: Li Zhang <zhlcindy@linux.vnet.ibm.com> --- src/conf/domain_conf.c | 59 ++++++++-------------- src/qemu/qemu_domain.c | 20 +++++++- src/util/virarch.h | 2 + .../qemuxml2argvdata/qemuxml2argv-pseries-disk.xml | 2 +- 4 files changed, 42 insertions(+), 41 deletions(-) @@ -12260,30 +12263,6 @@ virDomainDefParseXML(xmlDocPtr xml, } VIR_FREE(nodes);
- /* If graphics are enabled, there's an implicit PS2 mouse */ - if (def->ngraphics > 0) { - virDomainInputDefPtr input; - - if (VIR_ALLOC(input) < 0) { - goto error; - } - if (STREQ(def->os.type, "hvm")) { - input->type = VIR_DOMAIN_INPUT_TYPE_MOUSE; - input->bus = VIR_DOMAIN_INPUT_BUS_PS2; - } else { - input->type = VIR_DOMAIN_INPUT_TYPE_MOUSE; - input->bus = VIR_DOMAIN_INPUT_BUS_XEN; - } - - if (VIR_REALLOC_N(def->inputs, def->ninputs + 1) < 0) { - virDomainInputDefFree(input); - goto error; - } - def->inputs[def->ninputs] = input; - def->ninputs++; - } - - Here you remove auto-adding of the mouse for all drivers, but only re-add it to the QEMU driver, leading to failures in sexpr2xmltest. Sorry, I made some mistakes. Let me correct it.
/* analysis of the sound devices */ if ((n = virXPathNodeSet("./devices/sound", ctxt, &nodes)) < 0) { goto error; @@ -17201,15 +17180,17 @@ virDomainDefFormatInternal(virDomainDefPtr def,
if (def->ngraphics > 0) { /* If graphics is enabled, add the implicit mouse */ - virDomainInputDef autoInput = { - VIR_DOMAIN_INPUT_TYPE_MOUSE, - STREQ(def->os.type, "hvm") ? - VIR_DOMAIN_INPUT_BUS_PS2 : VIR_DOMAIN_INPUT_BUS_XEN, - { .alias = NULL }, - }; - - if (virDomainInputDefFormat(buf, &autoInput, flags) < 0) - goto error; + if (ARCH_IS_X86(def->os.arch)) { + virDomainInputDef autoInput = { + VIR_DOMAIN_INPUT_TYPE_MOUSE, + STREQ(def->os.type, "hvm") ? + VIR_DOMAIN_INPUT_BUS_PS2 : VIR_DOMAIN_INPUT_BUS_XEN, + { .alias = NULL }, + }; + if (virDomainInputDefFormat(buf, &autoInput, flags) < 0) + goto error; + } +
for (n = 0; n < def->ngraphics; n++) if (virDomainGraphicsDefFormat(buf, def->graphics[n], flags) < 0)
Hmm, if non-USB input devices get skipped when generating the command line and when formatting the XML, I wonder why are we adding it there in the first place.
I also have some confusion about it. For PS2 mouse, what I have seen is that it doesn't create QEMU command line. But it is configured in XML file. This device is added by QEMU if XEN is not enabled (hw/pc_piix.c). I am not sure whether how this device is added on other kind of virtualization. This may be not necessary to add this device in libvirt, it is not configurable. Thanks. -Li
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 346fec3..75e615a 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -691,6 +691,8 @@ qemuDomainDefPostParse(virDomainDefPtr def, bool addPCIRoot = false; bool addPCIeRoot = false; bool addDefaultMemballoon = true; + bool addDefaultMouse = false; + int mouse_bus = VIR_DOMAIN_INPUT_BUS_XEN;
/* check for emulator and create a default one if needed */ if (!def->emulator && @@ -721,6 +723,9 @@ qemuDomainDefPostParse(virDomainDefPtr def, !STRPREFIX(def->os.machine, "rhel")) break; addPCIRoot = true; + addDefaultMouse = true; + if (STREQ(def->os.type, "hvm")) + mouse_bus = VIR_DOMAIN_INPUT_BUS_PS2; os.type has to be "hvm" in the qemu driver.
OK, I will remove this check.
break;
case VIR_ARCH_ARMV7L:
Jan

From: Li Zhang <zhlcindy@linux.vnet.ibm.com> QEMU can support USB keyboard but libvirt haven't supportted it yet. This patch is to add USB keyboard capabilities and test cases. Signed-off-by: Li Zhang <zhlcindy@linux.vnet.ibm.com> --- src/qemu/qemu_capabilities.c | 2 ++ src/qemu/qemu_capabilities.h | 1 + tests/qemucapabilitiesdata/caps_1.2.2-1.caps | 1 + tests/qemucapabilitiesdata/caps_1.3.1-1.caps | 1 + tests/qemucapabilitiesdata/caps_1.4.2-1.caps | 1 + tests/qemucapabilitiesdata/caps_1.5.3-1.caps | 1 + tests/qemucapabilitiesdata/caps_1.6.0-1.caps | 2 ++ tests/qemucapabilitiesdata/caps_1.6.50-1.caps | 1 + tests/qemuhelptest.c | 8 ++++++++ 9 files changed, 18 insertions(+) diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index a68e555..580d598 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -245,6 +245,7 @@ VIR_ENUM_IMPL(virQEMUCaps, QEMU_CAPS_LAST, "kvm-pit-lost-tick-policy", "boot-strict", /* 160 */ + "usb-kbd", ); struct _virQEMUCaps { @@ -1396,6 +1397,7 @@ struct virQEMUCapsStringFlags virQEMUCapsObjectTypes[] = { { "usb-storage", QEMU_CAPS_DEVICE_USB_STORAGE }, { "virtio-mmio", QEMU_CAPS_DEVICE_VIRTIO_MMIO }, { "ich9-intel-hda", QEMU_CAPS_DEVICE_ICH9_INTEL_HDA }, + { "usb-kbd", QEMU_CAPS_DEVICE_USB_KBD }, }; static struct virQEMUCapsStringFlags virQEMUCapsObjectPropsVirtioBlk[] = { diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h index aea64ea..05837b2 100644 --- a/src/qemu/qemu_capabilities.h +++ b/src/qemu/qemu_capabilities.h @@ -199,6 +199,7 @@ enum virQEMUCapsFlags { QEMU_CAPS_DEVICE_ICH9_INTEL_HDA = 158, /* -device ich9-intel-hda */ QEMU_CAPS_KVM_PIT_TICK_POLICY = 159, /* kvm-pit.lost_tick_policy */ QEMU_CAPS_BOOT_STRICT = 160, /* -boot strict */ + QEMU_CAPS_DEVICE_USB_KBD = 161, /*-device usb-kbd*/ QEMU_CAPS_LAST, /* this must always be the last item */ }; diff --git a/tests/qemucapabilitiesdata/caps_1.2.2-1.caps b/tests/qemucapabilitiesdata/caps_1.2.2-1.caps index 73a561d..b620341 100644 --- a/tests/qemucapabilitiesdata/caps_1.2.2-1.caps +++ b/tests/qemucapabilitiesdata/caps_1.2.2-1.caps @@ -112,4 +112,5 @@ <flag name='usb-storage'/> <flag name='usb-storage.removable'/> <flag name='kvm-pit-lost-tick-policy'/> + <flag name='usb-kbd'/> </qemuCaps> diff --git a/tests/qemucapabilitiesdata/caps_1.3.1-1.caps b/tests/qemucapabilitiesdata/caps_1.3.1-1.caps index da15d8b..6b4a8f0 100644 --- a/tests/qemucapabilitiesdata/caps_1.3.1-1.caps +++ b/tests/qemucapabilitiesdata/caps_1.3.1-1.caps @@ -126,4 +126,5 @@ <flag name='usb-storage'/> <flag name='usb-storage.removable'/> <flag name='kvm-pit-lost-tick-policy'/> + <flag name='usb-kbd'/> </qemuCaps> diff --git a/tests/qemucapabilitiesdata/caps_1.4.2-1.caps b/tests/qemucapabilitiesdata/caps_1.4.2-1.caps index c419068..e3d0047 100644 --- a/tests/qemucapabilitiesdata/caps_1.4.2-1.caps +++ b/tests/qemucapabilitiesdata/caps_1.4.2-1.caps @@ -127,4 +127,5 @@ <flag name='usb-storage.removable'/> <flag name='ich9-intel-hda'/> <flag name='kvm-pit-lost-tick-policy'/> + <flag name='usb-kbd'/> </qemuCaps> diff --git a/tests/qemucapabilitiesdata/caps_1.5.3-1.caps b/tests/qemucapabilitiesdata/caps_1.5.3-1.caps index 2b00449..b29ea60 100644 --- a/tests/qemucapabilitiesdata/caps_1.5.3-1.caps +++ b/tests/qemucapabilitiesdata/caps_1.5.3-1.caps @@ -132,4 +132,5 @@ <flag name='ich9-intel-hda'/> <flag name='kvm-pit-lost-tick-policy'/> <flag name='boot-strict'/> + <flag name='usb-kbd'/> </qemuCaps> diff --git a/tests/qemucapabilitiesdata/caps_1.6.0-1.caps b/tests/qemucapabilitiesdata/caps_1.6.0-1.caps index 7bce4aa..2fa7d20 100644 --- a/tests/qemucapabilitiesdata/caps_1.6.0-1.caps +++ b/tests/qemucapabilitiesdata/caps_1.6.0-1.caps @@ -136,4 +136,6 @@ <flag name='ich9-intel-hda'/> <flag name='kvm-pit-lost-tick-policy'/> <flag name='boot-strict'/> + <flag name='usb-kbd'/> + </qemuCaps> diff --git a/tests/qemucapabilitiesdata/caps_1.6.50-1.caps b/tests/qemucapabilitiesdata/caps_1.6.50-1.caps index bfaab9d..0151cde 100644 --- a/tests/qemucapabilitiesdata/caps_1.6.50-1.caps +++ b/tests/qemucapabilitiesdata/caps_1.6.50-1.caps @@ -135,4 +135,5 @@ <flag name='ich9-intel-hda'/> <flag name='kvm-pit-lost-tick-policy'/> <flag name='boot-strict'/> + <flag name='usb-kbd'/> </qemuCaps> diff --git a/tests/qemuhelptest.c b/tests/qemuhelptest.c index 3628fbe..6e0a5f8 100644 --- a/tests/qemuhelptest.c +++ b/tests/qemuhelptest.c @@ -403,6 +403,7 @@ mymain(void) QEMU_CAPS_DEVICE_VMWARE_SVGA, QEMU_CAPS_DEVICE_USB_SERIAL, QEMU_CAPS_DEVICE_USB_NET, + QEMU_CAPS_DEVICE_USB_KBD, QEMU_CAPS_DEVICE_PCI_BRIDGE); DO_TEST("qemu-kvm-0.12.3", 12003, 1, 0, QEMU_CAPS_VNC_COLON, @@ -515,6 +516,7 @@ mymain(void) QEMU_CAPS_DEVICE_USB_NET, QEMU_CAPS_DEVICE_PCI_BRIDGE, QEMU_CAPS_DEVICE_SCSI_GENERIC, + QEMU_CAPS_DEVICE_USB_KBD, QEMU_CAPS_DEVICE_USB_STORAGE); DO_TEST("qemu-kvm-0.12.1.2-rhel61", 12001, 1, 0, QEMU_CAPS_VNC_COLON, @@ -581,6 +583,7 @@ mymain(void) QEMU_CAPS_DEVICE_VMWARE_SVGA, QEMU_CAPS_DEVICE_USB_SERIAL, QEMU_CAPS_DEVICE_USB_NET, + QEMU_CAPS_DEVICE_USB_KBD, QEMU_CAPS_DEVICE_PCI_BRIDGE); DO_TEST("qemu-kvm-0.12.1.2-rhel62-beta", 12001, 1, 0, QEMU_CAPS_VNC_COLON, @@ -655,6 +658,7 @@ mymain(void) QEMU_CAPS_DEVICE_VGA, QEMU_CAPS_DEVICE_CIRRUS_VGA, QEMU_CAPS_DEVICE_PCI_BRIDGE, + QEMU_CAPS_DEVICE_USB_KBD, QEMU_CAPS_DEVICE_USB_STORAGE); DO_TEST("qemu-1.0", 1000000, 0, 0, QEMU_CAPS_VNC_COLON, @@ -739,6 +743,7 @@ mymain(void) QEMU_CAPS_DEVICE_USB_NET, QEMU_CAPS_DEVICE_SCSI_GENERIC, QEMU_CAPS_DEVICE_SCSI_GENERIC_BOOTINDEX, + QEMU_CAPS_DEVICE_USB_KBD, QEMU_CAPS_DEVICE_USB_STORAGE); DO_TEST("qemu-1.1.0", 1001000, 0, 0, QEMU_CAPS_VNC_COLON, @@ -835,6 +840,7 @@ mymain(void) QEMU_CAPS_DEVICE_SCSI_GENERIC, QEMU_CAPS_DEVICE_SCSI_GENERIC_BOOTINDEX, QEMU_CAPS_VNC_SHARE_POLICY, + QEMU_CAPS_DEVICE_USB_KBD, QEMU_CAPS_DEVICE_USB_STORAGE); DO_TEST("qemu-1.2.0", 1002000, 0, 0, QEMU_CAPS_VNC_COLON, @@ -943,6 +949,7 @@ mymain(void) QEMU_CAPS_DEVICE_SCSI_GENERIC_BOOTINDEX, QEMU_CAPS_VNC_SHARE_POLICY, QEMU_CAPS_DEVICE_USB_STORAGE, + QEMU_CAPS_DEVICE_USB_KBD, QEMU_CAPS_USB_STORAGE_REMOVABLE); DO_TEST("qemu-kvm-1.2.0", 1002000, 1, 0, QEMU_CAPS_VNC_COLON, @@ -1056,6 +1063,7 @@ mymain(void) QEMU_CAPS_DEVICE_SCSI_GENERIC_BOOTINDEX, QEMU_CAPS_VNC_SHARE_POLICY, QEMU_CAPS_DEVICE_USB_STORAGE, + QEMU_CAPS_DEVICE_USB_KBD, QEMU_CAPS_USB_STORAGE_REMOVABLE); return ret == 0 ? EXIT_SUCCESS : EXIT_FAILURE; -- 1.8.2.1

From: Li Zhang <zhlcindy@linux.vnet.ibm.com> This patch is to format qemu command line and xen driver for USB keyboard and add test cases for it. Signed-off-by: Li Zhang <zhlcindy@linux.vnet.ibm.com> --- src/qemu/qemu_command.c | 44 +++++++++++++++++----- src/xenxs/xen_sxpr.c | 27 +++++++++---- src/xenxs/xen_xm.c | 30 +++++++++++---- .../qemuxml2argv-pseries-usb-kbd.args | 9 +++++ .../qemuxml2argv-pseries-usb-kbd.xml | 19 ++++++++++ tests/qemuxml2argvtest.c | 3 ++ 6 files changed, 106 insertions(+), 26 deletions(-) create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-pseries-usb-kbd.args create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-pseries-usb-kbd.xml diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 9539be7..ceba848 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -5307,9 +5307,22 @@ qemuBuildUSBInputDevStr(virDomainDefPtr def, { virBuffer buf = VIR_BUFFER_INITIALIZER; - virBufferAsprintf(&buf, "%s,id=%s", - dev->type == VIR_DOMAIN_INPUT_TYPE_MOUSE ? - "usb-mouse" : "usb-tablet", dev->info.alias); + switch (dev->type) { + case VIR_DOMAIN_INPUT_TYPE_MOUSE: + virBufferAsprintf(&buf, "usb-mouse,id=%s", dev->info.alias); + break; + case VIR_DOMAIN_INPUT_TYPE_TABLET: + virBufferAsprintf(&buf, "usb-tablet,id=%s", dev->info.alias); + break; + case VIR_DOMAIN_INPUT_TYPE_KBD: + if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_USB_KBD)) { + virReportError(VIR_ERR_INTERNAL_ERROR, + "%s", _("Can't get QEMU_CAPS_DEVICE_USB_KBD capability")); + goto error; + } + virBufferAsprintf(&buf, "usb-kbd,id=%s", dev->info.alias); + break; + } if (qemuBuildDeviceAddressStr(&buf, def, &dev->info, qemuCaps) < 0) goto error; @@ -8996,9 +9009,17 @@ qemuBuildCommandLine(virConnectPtr conn, virCommandAddArg(cmd, optstr); VIR_FREE(optstr); } else { - virCommandAddArgList(cmd, "-usbdevice", - input->type == VIR_DOMAIN_INPUT_TYPE_MOUSE - ? "mouse" : "tablet", NULL); + switch (input->type) { + case VIR_DOMAIN_INPUT_TYPE_MOUSE: + virCommandAddArgList(cmd, "-usbdevice", "mouse", NULL); + break; + case VIR_DOMAIN_INPUT_TYPE_TABLET: + virCommandAddArgList(cmd, "-usbdevice", "tablet", NULL); + break; + case VIR_DOMAIN_INPUT_TYPE_KBD: + virCommandAddArgList(cmd, "-usbdevice", "kbd", NULL); + break; + } } } } @@ -11668,20 +11689,23 @@ qemuParseCommandLine(virCapsPtr qemuCaps, } else if (STREQ(arg, "-usbdevice")) { WANT_VALUE(); if (STREQ(val, "tablet") || - STREQ(val, "mouse")) { + STREQ(val, "mouse") || + STREQ(val, "kbd")) { virDomainInputDefPtr input; if (VIR_ALLOC(input) < 0) goto error; input->bus = VIR_DOMAIN_INPUT_BUS_USB; if (STREQ(val, "tablet")) input->type = VIR_DOMAIN_INPUT_TYPE_TABLET; - else + else if (STREQ(val, "mouse")) input->type = VIR_DOMAIN_INPUT_TYPE_MOUSE; - if (VIR_REALLOC_N(def->inputs, def->ninputs+1) < 0) { + else + input->type = VIR_DOMAIN_INPUT_TYPE_KBD; + + if (VIR_APPEND_ELEMENT(def->inputs, def->ninputs, input) < 0) { virDomainInputDefFree(input); goto error; } - def->inputs[def->ninputs++] = input; } else if (STRPREFIX(val, "disk:")) { if (VIR_ALLOC(disk) < 0) goto error; diff --git a/src/xenxs/xen_sxpr.c b/src/xenxs/xen_sxpr.c index d514725..a02f999 100644 --- a/src/xenxs/xen_sxpr.c +++ b/src/xenxs/xen_sxpr.c @@ -724,21 +724,23 @@ xenParseSxprUSB(virDomainDefPtr def, tmp = sexpr_node(node, "usbdevice"); if (tmp && *tmp) { if (STREQ(tmp, "tablet") || - STREQ(tmp, "mouse")) { + STREQ(tmp, "mouse") || + STREQ(tmp, "kbd")) { virDomainInputDefPtr input; if (VIR_ALLOC(input) < 0) goto error; input->bus = VIR_DOMAIN_INPUT_BUS_USB; if (STREQ(tmp, "tablet")) input->type = VIR_DOMAIN_INPUT_TYPE_TABLET; - else + else if (STREQ(tmp, "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); goto error; } - def->inputs[def->ninputs++] = input; } else { /* XXX Handle other non-input USB devices later */ } @@ -2144,15 +2146,24 @@ xenFormatSxprInput(virDomainInputDefPtr input, return 0; 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, _("unexpected input type %d"), input->type); return -1; } - virBufferAsprintf(buf, "(usbdevice %s)", - input->type == VIR_DOMAIN_INPUT_TYPE_MOUSE ? - "mouse" : "tablet"); + switch (input->type) { + case VIR_DOMAIN_INPUT_TYPE_MOUSE: + 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)","kbd") + break; + } return 0; } diff --git a/src/xenxs/xen_xm.c b/src/xenxs/xen_xm.c index 5e89876..9e19bb7 100644 --- a/src/xenxs/xen_xm.c +++ b/src/xenxs/xen_xm.c @@ -886,14 +886,18 @@ xenParseXM(virConfPtr conf, int xendConfigVersion, goto cleanup; if (str && (STREQ(str, "tablet") || - STREQ(str, "mouse"))) { + STREQ(str, "mouse") || + STREQ(str, "kbd"))) { virDomainInputDefPtr input; if (VIR_ALLOC(input) < 0) goto cleanup; input->bus = VIR_DOMAIN_INPUT_BUS_USB; - input->type = STREQ(str, "tablet") ? - VIR_DOMAIN_INPUT_TYPE_TABLET : - VIR_DOMAIN_INPUT_TYPE_MOUSE; + if (STREQ(str, "mouse")) + input->type = VIR_DOMAIN_INPUT_TYPE_MOUSE; + else if (STREQ(str, "tablet")) + input->type = VIR_DOMAIN_INPUT_TYPE_TABLET; + else (STREQ(str, "kbd")) + input->type = VIR_DOMAIN_INPUT_TYPE_KBD; if (VIR_ALLOC_N(def->inputs, 1) < 0) { virDomainInputDefFree(input); goto cleanup; @@ -1746,10 +1750,20 @@ virConfPtr xenFormatXM(virConnectPtr conn, if (def->inputs[i]->bus == VIR_DOMAIN_INPUT_BUS_USB) { if (xenXMConfigSetInt(conf, "usb", 1) < 0) goto cleanup; - if (xenXMConfigSetString(conf, "usbdevice", - def->inputs[i]->type == VIR_DOMAIN_INPUT_TYPE_MOUSE ? - "mouse" : "tablet") < 0) - goto cleanup; + switch (def->inputs[i]->type) { + case VIR_DOMAIN_INPUT_TYPE_MOUSE: + if (xenXMConfigSetString(conf, "usbdevice", "mouse") < 0) + 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", "kbd") < 0) + goto cleanup; + break; + } break; } } diff --git a/tests/qemuxml2argvdata/qemuxml2argv-pseries-usb-kbd.args b/tests/qemuxml2argvdata/qemuxml2argv-pseries-usb-kbd.args new file mode 100644 index 0000000..373c72a --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-pseries-usb-kbd.args @@ -0,0 +1,9 @@ +LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test QEMU_AUDIO_DRV=none \ +/usr/bin/qemu-system-ppc64 -S -M pseries -m 512 -smp 1 \ +-nographic -nodefconfig -nodefaults \ +-chardev socket,id=charmonitor,path=/tmp/test-monitor,server,nowait \ +-mon chardev=charmonitor,id=monitor,mode=readline -no-acpi -boot c \ +-device pci-ohci,id=usb,bus=pci,addr=0x1 \ +-chardev pty,id=charserial0 \ +-device spapr-vty,chardev=charserial0,reg=0x30000000 \ +-device usb-kbd,id=input0 diff --git a/tests/qemuxml2argvdata/qemuxml2argv-pseries-usb-kbd.xml b/tests/qemuxml2argvdata/qemuxml2argv-pseries-usb-kbd.xml new file mode 100644 index 0000000..c512584 --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-pseries-usb-kbd.xml @@ -0,0 +1,19 @@ +<domain type='qemu'> + <name>QEMUGuest1</name> + <uuid>1ccfd97d-5eb4-478a-bbe6-88d254c16db7</uuid> + <memory unit='KiB'>524288</memory> + <vcpu placement='static'>1</vcpu> + <os> + <type arch='ppc64' machine='pseries'>hvm</type> + </os> + <clock offset='utc'/> + <devices> + <emulator>/usr/bin/qemu-system-ppc64</emulator> + <console type='pty'> + <address type="spapr-vio"/> + </console> + <memballoon model="none"/> + <controller type='usb' index='0' model='pci-ohci'/> + <input type='kbd' bus='usb'/> + </devices> +</domain> diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index f9abf1b..47f3988 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -1176,6 +1176,9 @@ mymain(void) DO_TEST_ERROR("pseries-vio-address-clash", QEMU_CAPS_DRIVE, QEMU_CAPS_CHARDEV, QEMU_CAPS_DEVICE, QEMU_CAPS_NODEFCONFIG); DO_TEST("pseries-nvram", QEMU_CAPS_DEVICE_NVRAM); + DO_TEST("pseries-usb-kbd", QEMU_CAPS_PCI_OHCI, + QEMU_CAPS_DEVICE_USB_KBD, QEMU_CAPS_CHARDEV, + QEMU_CAPS_DEVICE, QEMU_CAPS_NODEFCONFIG); DO_TEST_FAILURE("pseries-cpu-exact", QEMU_CAPS_CHARDEV, QEMU_CAPS_DEVICE, QEMU_CAPS_NODEFCONFIG); DO_TEST("disk-ide-drive-split", QEMU_CAPS_DRIVE, QEMU_CAPS_DEVICE, QEMU_CAPS_NODEFCONFIG, -- 1.8.2.1

From: Li Zhang <zhlcindy@linux.vnet.ibm.com> There is no keyboard working on PPC64 when graphics are enabled. It needs to add a USB keyboard for it. This patch is to add a USB keyboard when graphics are enabled. Signed-off-by: Li Zhang <zhlcindy@linux.vnet.ibm.com> --- src/qemu/qemu_domain.c | 9 +++++++++ tests/qemuxml2argvdata/qemuxml2argv-pseries-disk.xml | 1 + 2 files changed, 10 insertions(+) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 75e615a..68d9e0c 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -691,6 +691,7 @@ qemuDomainDefPostParse(virDomainDefPtr def, bool addPCIRoot = false; bool addPCIeRoot = false; bool addDefaultMemballoon = true; + bool addDefaultUSBKBD = false; bool addDefaultMouse = false; int mouse_bus = VIR_DOMAIN_INPUT_BUS_XEN; @@ -735,6 +736,7 @@ qemuDomainDefPostParse(virDomainDefPtr def, case VIR_ARCH_PPC64: addPCIRoot = true; + addDefaultUSBKBD = true; addDefaultMouse = true; if (STREQ(def->os.type, "hvm")) mouse_bus = VIR_DOMAIN_INPUT_BUS_USB; @@ -801,6 +803,13 @@ qemuDomainDefPostParse(virDomainDefPtr def, return -1; } + if (addDefaultUSBKBD && + def->ngraphics > 0 && + virDomainDefMaybeAddInput(def, + VIR_DOMAIN_INPUT_TYPE_KBD, + VIR_DOMAIN_INPUT_BUS_USB) < 0) + return -1; + return 0; } diff --git a/tests/qemuxml2argvdata/qemuxml2argv-pseries-disk.xml b/tests/qemuxml2argvdata/qemuxml2argv-pseries-disk.xml index 117213d..8c87998 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-pseries-disk.xml +++ b/tests/qemuxml2argvdata/qemuxml2argv-pseries-disk.xml @@ -31,6 +31,7 @@ <controller type='scsi' index='0'/> <controller type='pci' index='0' model='pci-root'/> <input type='mouse' bus='usb'/> + <input type='kbd' bus='usb'/> <graphics type='sdl'/> <video> <model type='cirrus' vram='9216' heads='1'/> -- 1.8.2.1
participants (2)
-
Ján Tomko
-
Li Zhang