[libvirt] [PATCH v5 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 default input devices. conf: 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 and USB mouse for PPC64 v5 -> v4: * Add PS/2 KBD definition in XML file. (Daniel.P.Berrange) * Allow PS/2 KBD devices and set KBD default bus as PS2 for X86, USB for non-x86. (Daniel.P.Berrange) * Add an implicit PS/2 KBD as PS/2 mouse. (Danniel.P.Berrange) v4 -> v3: * Don't remove PS2 mouse device for other virtualization drivers (Jan Tomko). 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 | 92 ++++++++++++++-------- 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 | 23 +++++- 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, 212 insertions(+), 62 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 | 18 ++++++++++++------ src/conf/domain_conf.h | 1 + 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng index be32c6b..df6253c 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 0079234..9c30a78 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -505,7 +505,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", @@ -7659,7 +7660,8 @@ virDomainInputDefParseXML(const char *ostype, if (STREQ(ostype, "hvm")) { if (def->bus == VIR_DOMAIN_INPUT_BUS_PS2 && /* Only allow mouse for ps2 */ - def->type != VIR_DOMAIN_INPUT_TYPE_MOUSE) { + !(def->type == VIR_DOMAIN_INPUT_TYPE_MOUSE || + def->type == VIR_DOMAIN_INPUT_TYPE_KBD)) { virReportError(VIR_ERR_INTERNAL_ERROR, _("ps2 bus does not support %s input device"), type); @@ -7677,7 +7679,8 @@ virDomainInputDefParseXML(const char *ostype, _("unsupported input bus %s"), bus); } - if (def->type != VIR_DOMAIN_INPUT_TYPE_MOUSE) { + if (def->type != VIR_DOMAIN_INPUT_TYPE_MOUSE && + def->type != VIR_DOMAIN_INPUT_TYPE_KBD) { virReportError(VIR_ERR_INTERNAL_ERROR, _("xen bus does not support %s input device"), type); @@ -7686,7 +7689,8 @@ virDomainInputDefParseXML(const char *ostype, } } else { if (STREQ(ostype, "hvm")) { - if (def->type == VIR_DOMAIN_INPUT_TYPE_MOUSE) + if (def->type == VIR_DOMAIN_INPUT_TYPE_MOUSE || + def->type == VIR_DOMAIN_INPUT_TYPE_KBD) def->bus = VIR_DOMAIN_INPUT_BUS_PS2; else def->bus = VIR_DOMAIN_INPUT_BUS_USB; @@ -12275,10 +12279,12 @@ virDomainDefParseXML(xmlDocPtr xml, * XXX will this be true for other virt types ? */ if ((STREQ(def->os.type, "hvm") && input->bus == VIR_DOMAIN_INPUT_BUS_PS2 && - input->type == VIR_DOMAIN_INPUT_TYPE_MOUSE) || + (input->type == VIR_DOMAIN_INPUT_TYPE_MOUSE || + input->type == VIR_DOMAIN_INPUT_TYPE_KBD)) || (STRNEQ(def->os.type, "hvm") && input->bus == VIR_DOMAIN_INPUT_BUS_XEN && - input->type == VIR_DOMAIN_INPUT_TYPE_MOUSE)) { + (input->type == VIR_DOMAIN_INPUT_TYPE_MOUSE || + input->type == VIR_DOMAIN_INPUT_TYPE_KBD))) { virDomainInputDefFree(input); continue; } diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index 647d115..23b2b9b 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -1235,6 +1235,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

On 12/19/2013 08:50 AM, Li Zhang wrote:
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 | 18 ++++++++++++------ src/conf/domain_conf.h | 1 + 3 files changed, 14 insertions(+), 6 deletions(-)
diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng index be32c6b..df6253c 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 0079234..9c30a78 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -505,7 +505,8 @@ VIR_ENUM_IMPL(virDomainVideo, VIR_DOMAIN_VIDEO_TYPE_LAST,
VIR_ENUM_IMPL(virDomainInput, VIR_DOMAIN_INPUT_TYPE_LAST, "mouse", - "tablet") + "tablet", + "kbd")
Maybe "keyboard" would sound nicer?
VIR_ENUM_IMPL(virDomainInputBus, VIR_DOMAIN_INPUT_BUS_LAST, "ps2", @@ -7659,7 +7660,8 @@ virDomainInputDefParseXML(const char *ostype,
if (STREQ(ostype, "hvm")) { if (def->bus == VIR_DOMAIN_INPUT_BUS_PS2 && /* Only allow mouse for ps2 */
The comment is no longer true.
- def->type != VIR_DOMAIN_INPUT_TYPE_MOUSE) { + !(def->type == VIR_DOMAIN_INPUT_TYPE_MOUSE || + def->type == VIR_DOMAIN_INPUT_TYPE_KBD)) { virReportError(VIR_ERR_INTERNAL_ERROR, _("ps2 bus does not support %s input device"), type);
Jan

On 2014年02月03日 23:09, Ján Tomko wrote:
On 12/19/2013 08:50 AM, Li Zhang wrote:
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 | 18 ++++++++++++------ src/conf/domain_conf.h | 1 + 3 files changed, 14 insertions(+), 6 deletions(-)
diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng index be32c6b..df6253c 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 0079234..9c30a78 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -505,7 +505,8 @@ VIR_ENUM_IMPL(virDomainVideo, VIR_DOMAIN_VIDEO_TYPE_LAST,
VIR_ENUM_IMPL(virDomainInput, VIR_DOMAIN_INPUT_TYPE_LAST, "mouse", - "tablet") + "tablet", + "kbd") Maybe "keyboard" would sound nicer?
Thanks for your review. ok, I can change it name.
VIR_ENUM_IMPL(virDomainInputBus, VIR_DOMAIN_INPUT_BUS_LAST, "ps2", @@ -7659,7 +7660,8 @@ virDomainInputDefParseXML(const char *ostype,
if (STREQ(ostype, "hvm")) { if (def->bus == VIR_DOMAIN_INPUT_BUS_PS2 && /* Only allow mouse for ps2 */
The comment is no longer true.
I will remove it in next version.
- def->type != VIR_DOMAIN_INPUT_TYPE_MOUSE) { + !(def->type == VIR_DOMAIN_INPUT_TYPE_MOUSE || + def->type == VIR_DOMAIN_INPUT_TYPE_KBD)) { virReportError(VIR_ERR_INTERNAL_ERROR, _("ps2 bus does not support %s input device"), type); Jan

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 9c30a78..1a1ac54 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -10899,6 +10899,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 23b2b9b..9efb588 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -2783,6 +2783,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 2dbb8f8..14d7086 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 | 71 +++++++++++----------- src/util/virarch.h | 2 + ...qemuhotplug-console-compat-2+console-virtio.xml | 1 + .../qemuxml2argv-console-compat-2.xml | 1 + .../qemuxml2argv-graphics-listen-network.xml | 1 + .../qemuxml2argv-graphics-listen-network2.xml | 1 + .../qemuxml2argv-graphics-sdl-fullscreen.xml | 1 + .../qemuxml2argvdata/qemuxml2argv-graphics-sdl.xml | 1 + .../qemuxml2argv-graphics-spice-compression.xml | 1 + .../qemuxml2argv-graphics-spice-qxl-vga.xml | 1 + .../qemuxml2argv-graphics-spice-timeout.xml | 2 + .../qemuxml2argv-graphics-spice.xml | 1 + .../qemuxml2argv-graphics-vnc-policy.xml | 1 + .../qemuxml2argv-graphics-vnc-sasl.xml | 1 + .../qemuxml2argv-graphics-vnc-socket.xml | 1 + .../qemuxml2argv-graphics-vnc-tls.xml | 1 + .../qemuxml2argv-graphics-vnc-websocket.xml | 1 + .../qemuxml2argvdata/qemuxml2argv-graphics-vnc.xml | 1 + tests/qemuxml2argvdata/qemuxml2argv-input-xen.xml | 1 + .../qemuxml2argv-net-bandwidth.xml | 1 + tests/qemuxml2argvdata/qemuxml2argv-pci-bridge.xml | 1 + .../qemuxml2argvdata/qemuxml2argv-pseries-disk.xml | 1 - .../qemuxml2xmlout-graphics-listen-network2.xml | 1 + .../qemuxml2xmlout-graphics-spice-timeout.xml | 1 + tests/vmx2xmldata/vmx2xml-graphics-vnc.xml | 1 + 25 files changed, 61 insertions(+), 36 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 1a1ac54..e495884 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -7625,7 +7625,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) { @@ -7658,7 +7658,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 || def->type == VIR_DOMAIN_INPUT_TYPE_KBD)) { @@ -7688,9 +7688,10 @@ virDomainInputDefParseXML(const char *ostype, } } } else { - if (STREQ(ostype, "hvm")) { - if (def->type == VIR_DOMAIN_INPUT_TYPE_MOUSE || - def->type == VIR_DOMAIN_INPUT_TYPE_KBD) + if (STREQ(dom->os.type, "hvm")) { + if ((def->type == VIR_DOMAIN_INPUT_TYPE_MOUSE || + def->type == VIR_DOMAIN_INPUT_TYPE_KBD) && + ARCH_IS_X86(dom->os.arch)) def->bus = VIR_DOMAIN_INPUT_BUS_PS2; else def->bus = VIR_DOMAIN_INPUT_BUS_USB; @@ -9692,7 +9693,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; @@ -12288,7 +12289,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) @@ -12339,30 +12340,25 @@ virDomainDefParseXML(xmlDocPtr xml, } VIR_FREE(nodes); - /* If graphics are enabled, there's an implicit PS2 mouse */ - if (def->ngraphics > 0) { - virDomainInputDefPtr input; + /* If graphics are enabled, there's an implicit PS2 mouse and PS2 keyboard */ + if (def->ngraphics > 0 && + ARCH_IS_X86(def->os.arch)) { + int input_bus = VIR_DOMAIN_INPUT_BUS_XEN; + + if (STREQ(def->os.type, "hvm")) + input_bus = VIR_DOMAIN_INPUT_BUS_PS2; - if (VIR_ALLOC(input) < 0) { + if (virDomainDefMaybeAddInput(def, + VIR_DOMAIN_INPUT_TYPE_MOUSE, + input_bus) < 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); + if (virDomainDefMaybeAddInput(def, + VIR_DOMAIN_INPUT_TYPE_KBD, + input_bus) < 0) goto error; - } - def->inputs[def->ninputs] = input; - def->ninputs++; } - /* analysis of the sound devices */ if ((n = virXPathNodeSet("./devices/sound", ctxt, &nodes)) < 0) { goto error; @@ -17338,16 +17334,21 @@ 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 graphics is enabled, add the implicit mouse/keyboard */ + 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; + + autoInput.type = VIR_DOMAIN_INPUT_TYPE_KBD; + 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/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/qemuhotplugtestdata/qemuhotplug-console-compat-2+console-virtio.xml b/tests/qemuhotplugtestdata/qemuhotplug-console-compat-2+console-virtio.xml index d75af19..3617a5b 100644 --- a/tests/qemuhotplugtestdata/qemuhotplug-console-compat-2+console-virtio.xml +++ b/tests/qemuhotplugtestdata/qemuhotplug-console-compat-2+console-virtio.xml @@ -104,6 +104,7 @@ <alias name='input0'/> </input> <input type='mouse' bus='ps2'/> + <input type='kbd' bus='ps2'/> <graphics type='vnc' port='5900' autoport='yes' listen='0.0.0.0'> <listen type='address' address='0.0.0.0'/> </graphics> diff --git a/tests/qemuxml2argvdata/qemuxml2argv-console-compat-2.xml b/tests/qemuxml2argvdata/qemuxml2argv-console-compat-2.xml index 37e8e00..8c8a584 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-console-compat-2.xml +++ b/tests/qemuxml2argvdata/qemuxml2argv-console-compat-2.xml @@ -99,6 +99,7 @@ <alias name='input0'/> </input> <input type='mouse' bus='ps2'/> + <input type='kbd' bus='ps2'/> <graphics type='vnc' port='5900' autoport='yes' listen='0.0.0.0'> <listen type='address' address='0.0.0.0'/> </graphics> diff --git a/tests/qemuxml2argvdata/qemuxml2argv-graphics-listen-network.xml b/tests/qemuxml2argvdata/qemuxml2argv-graphics-listen-network.xml index b005440..6bdaf08 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-graphics-listen-network.xml +++ b/tests/qemuxml2argvdata/qemuxml2argv-graphics-listen-network.xml @@ -23,6 +23,7 @@ <controller type='ide' index='0'/> <controller type='pci' index='0' model='pci-root'/> <input type='mouse' bus='ps2'/> + <input type='kbd' bus='ps2'/> <graphics type='vnc' port='5903' autoport='no'> <listen type='network' network='Bobsnetwork'/> </graphics> diff --git a/tests/qemuxml2argvdata/qemuxml2argv-graphics-listen-network2.xml b/tests/qemuxml2argvdata/qemuxml2argv-graphics-listen-network2.xml index 870ef55..20e2b31 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-graphics-listen-network2.xml +++ b/tests/qemuxml2argvdata/qemuxml2argv-graphics-listen-network2.xml @@ -22,6 +22,7 @@ <controller type='usb' index='0'/> <controller type='ide' index='0'/> <input type='mouse' bus='ps2'/> + <input type='kbd' bus='ps2'/> <graphics type='vnc' listen='1.2.3.4' autoport='yes'> <listen type='address' address='1.2.3.4'/> <listen type='network' network='Bobsnetwork'/> diff --git a/tests/qemuxml2argvdata/qemuxml2argv-graphics-sdl-fullscreen.xml b/tests/qemuxml2argvdata/qemuxml2argv-graphics-sdl-fullscreen.xml index 7793161..4cd0d54 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-graphics-sdl-fullscreen.xml +++ b/tests/qemuxml2argvdata/qemuxml2argv-graphics-sdl-fullscreen.xml @@ -24,6 +24,7 @@ <controller type='ide' index='0'/> <controller type='pci' index='0' model='pci-root'/> <input type='mouse' bus='ps2'/> + <input type='kbd' bus='ps2'/> <graphics type='sdl' display=':0.1' xauth='/root/.Xauthority' fullscreen='yes'/> <video> <model type='cirrus' vram='9216' heads='1'/> diff --git a/tests/qemuxml2argvdata/qemuxml2argv-graphics-sdl.xml b/tests/qemuxml2argvdata/qemuxml2argv-graphics-sdl.xml index 26fe28b..3513307 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-graphics-sdl.xml +++ b/tests/qemuxml2argvdata/qemuxml2argv-graphics-sdl.xml @@ -24,6 +24,7 @@ <controller type='ide' index='0'/> <controller type='pci' index='0' model='pci-root'/> <input type='mouse' bus='ps2'/> + <input type='kbd' bus='ps2'/> <graphics type='sdl' display=':0.1' xauth='/root/.Xauthority'/> <video> <model type='vga' vram='9216' heads='1'/> diff --git a/tests/qemuxml2argvdata/qemuxml2argv-graphics-spice-compression.xml b/tests/qemuxml2argvdata/qemuxml2argv-graphics-spice-compression.xml index 5da94c2..6dbb1bb 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-graphics-spice-compression.xml +++ b/tests/qemuxml2argvdata/qemuxml2argv-graphics-spice-compression.xml @@ -23,6 +23,7 @@ <controller type='ide' index='0'/> <controller type='pci' index='0' model='pci-root'/> <input type='mouse' bus='ps2'/> + <input type='kbd' bus='ps2'/> <graphics type='spice' port='5903' tlsPort='5904' autoport='no' listen='127.0.0.1'> <listen type='address' address='127.0.0.1'/> <image compression='auto_glz'/> diff --git a/tests/qemuxml2argvdata/qemuxml2argv-graphics-spice-qxl-vga.xml b/tests/qemuxml2argvdata/qemuxml2argv-graphics-spice-qxl-vga.xml index 99d2996..a798b40 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-graphics-spice-qxl-vga.xml +++ b/tests/qemuxml2argvdata/qemuxml2argv-graphics-spice-qxl-vga.xml @@ -23,6 +23,7 @@ <controller type='ide' index='0'/> <controller type='pci' index='0' model='pci-root'/> <input type='mouse' bus='ps2'/> + <input type='kbd' bus='ps2'/> <graphics type='spice' port='5903' tlsPort='5904' autoport='no' listen='127.0.0.1'> <listen type='address' address='127.0.0.1'/> <channel name='main' mode='secure'/> diff --git a/tests/qemuxml2argvdata/qemuxml2argv-graphics-spice-timeout.xml b/tests/qemuxml2argvdata/qemuxml2argv-graphics-spice-timeout.xml index f9fdf37..1bdc7cb 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-graphics-spice-timeout.xml +++ b/tests/qemuxml2argvdata/qemuxml2argv-graphics-spice-timeout.xml @@ -71,7 +71,9 @@ </console> <input type='tablet' bus='usb'/> <input type='mouse' bus='ps2'/> + <input type='kbd' bus='ps2'/> <graphics type='spice' port='5900' autoport='no' passwd='sercet' passwdValidTo='2011-05-31T16:11:22' connected='disconnect'/> + <input type='kbd' bus='ps2'/> <sound model='ac97'> <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/> </sound> diff --git a/tests/qemuxml2argvdata/qemuxml2argv-graphics-spice.xml b/tests/qemuxml2argvdata/qemuxml2argv-graphics-spice.xml index b22fbcc..29e0396 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-graphics-spice.xml +++ b/tests/qemuxml2argvdata/qemuxml2argv-graphics-spice.xml @@ -23,6 +23,7 @@ <controller type='ide' index='0'/> <controller type='pci' index='0' model='pci-root'/> <input type='mouse' bus='ps2'/> + <input type='kbd' bus='ps2'/> <graphics type='spice' port='5903' tlsPort='5904' autoport='no' listen='127.0.0.1' defaultMode='secure'> <listen type='address' address='127.0.0.1'/> <channel name='main' mode='secure'/> diff --git a/tests/qemuxml2argvdata/qemuxml2argv-graphics-vnc-policy.xml b/tests/qemuxml2argvdata/qemuxml2argv-graphics-vnc-policy.xml index 6c95c8a..2e92ff9 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-graphics-vnc-policy.xml +++ b/tests/qemuxml2argvdata/qemuxml2argv-graphics-vnc-policy.xml @@ -24,6 +24,7 @@ <controller type='ide' index='0'/> <controller type='pci' index='0' model='pci-root'/> <input type='mouse' bus='ps2'/> + <input type='kbd' bus='ps2'/> <graphics type='vnc' port='5900' autoport='no' listen='127.0.0.1' sharePolicy='allow-exclusive'> <listen type='address' address='127.0.0.1'/> </graphics> diff --git a/tests/qemuxml2argvdata/qemuxml2argv-graphics-vnc-sasl.xml b/tests/qemuxml2argvdata/qemuxml2argv-graphics-vnc-sasl.xml index 75563df..61978e8 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-graphics-vnc-sasl.xml +++ b/tests/qemuxml2argvdata/qemuxml2argv-graphics-vnc-sasl.xml @@ -24,6 +24,7 @@ <controller type='ide' index='0'/> <controller type='pci' index='0' model='pci-root'/> <input type='mouse' bus='ps2'/> + <input type='kbd' bus='ps2'/> <graphics type='vnc' port='5903' autoport='no' listen='127.0.0.1'> <listen type='address' address='127.0.0.1'/> </graphics> diff --git a/tests/qemuxml2argvdata/qemuxml2argv-graphics-vnc-socket.xml b/tests/qemuxml2argvdata/qemuxml2argv-graphics-vnc-socket.xml index 24c7eed..226e5d8 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-graphics-vnc-socket.xml +++ b/tests/qemuxml2argvdata/qemuxml2argv-graphics-vnc-socket.xml @@ -24,6 +24,7 @@ <controller type='ide' index='0'/> <controller type='pci' index='0' model='pci-root'/> <input type='mouse' bus='ps2'/> + <input type='kbd' bus='ps2'/> <graphics type='vnc' socket='/tmp/foo.socket'/> <video> <model type='cirrus' vram='9216' heads='1'/> diff --git a/tests/qemuxml2argvdata/qemuxml2argv-graphics-vnc-tls.xml b/tests/qemuxml2argvdata/qemuxml2argv-graphics-vnc-tls.xml index 75563df..61978e8 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-graphics-vnc-tls.xml +++ b/tests/qemuxml2argvdata/qemuxml2argv-graphics-vnc-tls.xml @@ -24,6 +24,7 @@ <controller type='ide' index='0'/> <controller type='pci' index='0' model='pci-root'/> <input type='mouse' bus='ps2'/> + <input type='kbd' bus='ps2'/> <graphics type='vnc' port='5903' autoport='no' listen='127.0.0.1'> <listen type='address' address='127.0.0.1'/> </graphics> diff --git a/tests/qemuxml2argvdata/qemuxml2argv-graphics-vnc-websocket.xml b/tests/qemuxml2argvdata/qemuxml2argv-graphics-vnc-websocket.xml index dd0bb57..e880db2 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-graphics-vnc-websocket.xml +++ b/tests/qemuxml2argvdata/qemuxml2argv-graphics-vnc-websocket.xml @@ -17,6 +17,7 @@ <controller type='usb' index='0'/> <controller type='pci' index='0' model='pci-root'/> <input type='mouse' bus='ps2'/> + <input type='kbd' bus='ps2'/> <graphics type='vnc' port='5900' autoport='no' websocket='5700' listen='127.0.0.1'> <listen type='address' address='127.0.0.1'/> </graphics> diff --git a/tests/qemuxml2argvdata/qemuxml2argv-graphics-vnc.xml b/tests/qemuxml2argvdata/qemuxml2argv-graphics-vnc.xml index 6dcd076..85e5d86 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-graphics-vnc.xml +++ b/tests/qemuxml2argvdata/qemuxml2argv-graphics-vnc.xml @@ -24,6 +24,7 @@ <controller type='ide' index='0'/> <controller type='pci' index='0' model='pci-root'/> <input type='mouse' bus='ps2'/> + <input type='kbd' bus='ps2'/> <graphics type='vnc' port='5903' autoport='no' listen='2001:1:2:3:4:5:1234:1234'> <listen type='address' address='2001:1:2:3:4:5:1234:1234'/> </graphics> diff --git a/tests/qemuxml2argvdata/qemuxml2argv-input-xen.xml b/tests/qemuxml2argvdata/qemuxml2argv-input-xen.xml index 0df46c6..b04069d 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-input-xen.xml +++ b/tests/qemuxml2argvdata/qemuxml2argv-input-xen.xml @@ -22,6 +22,7 @@ <controller type='usb' index='0'/> <controller type='ide' index='0'/> <input type='mouse' bus='xen'/> + <input type='kbd' bus='xen'/> <graphics type='vnc' port='5903' autoport='no' listen='127.0.0.1'> <listen type='address' address='127.0.0.1'/> </graphics> diff --git a/tests/qemuxml2argvdata/qemuxml2argv-net-bandwidth.xml b/tests/qemuxml2argvdata/qemuxml2argv-net-bandwidth.xml index 4b8646d..0765ec1 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-net-bandwidth.xml +++ b/tests/qemuxml2argvdata/qemuxml2argv-net-bandwidth.xml @@ -60,6 +60,7 @@ </console> <input type='tablet' bus='usb'/> <input type='mouse' bus='ps2'/> + <input type='kbd' bus='ps2'/> <graphics type='vnc' port='-1' autoport='yes'/> <sound model='ac97'> <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/> diff --git a/tests/qemuxml2argvdata/qemuxml2argv-pci-bridge.xml b/tests/qemuxml2argvdata/qemuxml2argv-pci-bridge.xml index eb20328..9022122 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-pci-bridge.xml +++ b/tests/qemuxml2argvdata/qemuxml2argv-pci-bridge.xml @@ -196,6 +196,7 @@ <model type='e1000'/> </interface> <input type='mouse' bus='ps2'/> + <input type='kbd' bus='ps2'/> <graphics type='vnc' port='-1' autoport='yes' listen='127.0.0.1' keymap='en-us'> <listen type='address' address='127.0.0.1'/> </graphics> diff --git a/tests/qemuxml2argvdata/qemuxml2argv-pseries-disk.xml b/tests/qemuxml2argvdata/qemuxml2argv-pseries-disk.xml index dbbd6aa..8dde776 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-pseries-disk.xml +++ b/tests/qemuxml2argvdata/qemuxml2argv-pseries-disk.xml @@ -30,7 +30,6 @@ <controller type='usb' index='0'/> <controller type='scsi' index='0'/> <controller type='pci' index='0' model='pci-root'/> - <input type='mouse' bus='ps2'/> <graphics type='sdl'/> <video> <model type='cirrus' vram='9216' heads='1'/> diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-graphics-listen-network2.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-graphics-listen-network2.xml index 3f7c383..430b2a6 100644 --- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-graphics-listen-network2.xml +++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-graphics-listen-network2.xml @@ -23,6 +23,7 @@ <controller type='ide' index='0'/> <controller type='pci' index='0' model='pci-root'/> <input type='mouse' bus='ps2'/> + <input type='kbd' bus='ps2'/> <graphics type='vnc' port='-1' autoport='yes' listen='1.2.3.4'> <listen type='address' address='1.2.3.4'/> <listen type='network' network='Bobsnetwork'/> diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-graphics-spice-timeout.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-graphics-spice-timeout.xml index f793f62..2ff42a3 100644 --- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-graphics-spice-timeout.xml +++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-graphics-spice-timeout.xml @@ -74,6 +74,7 @@ </console> <input type='tablet' bus='usb'/> <input type='mouse' bus='ps2'/> + <input type='kbd' bus='ps2'/> <graphics type='spice' port='5900' autoport='no' passwd='sercet' passwdValidTo='2011-05-31T16:11:22' connected='disconnect'/> <sound model='ac97'> <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/> diff --git a/tests/vmx2xmldata/vmx2xml-graphics-vnc.xml b/tests/vmx2xmldata/vmx2xml-graphics-vnc.xml index 28af543..2579df8 100644 --- a/tests/vmx2xmldata/vmx2xml-graphics-vnc.xml +++ b/tests/vmx2xmldata/vmx2xml-graphics-vnc.xml @@ -12,6 +12,7 @@ <on_crash>destroy</on_crash> <devices> <input type='mouse' bus='ps2'/> + <input type='kbd' bus='ps2'/> <graphics type='vnc' port='5903' autoport='no' keymap='de' passwd='password'/> <video> <model type='vmvga' vram='4096'/> -- 1.8.2.1

On 12/19/2013 08:50 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 | 71 +++++++++++----------- src/util/virarch.h | 2 + ...qemuhotplug-console-compat-2+console-virtio.xml | 1 + .../qemuxml2argv-console-compat-2.xml | 1 + .../qemuxml2argv-graphics-listen-network.xml | 1 + .../qemuxml2argv-graphics-listen-network2.xml | 1 + .../qemuxml2argv-graphics-sdl-fullscreen.xml | 1 + .../qemuxml2argvdata/qemuxml2argv-graphics-sdl.xml | 1 + .../qemuxml2argv-graphics-spice-compression.xml | 1 + .../qemuxml2argv-graphics-spice-qxl-vga.xml | 1 + .../qemuxml2argv-graphics-spice-timeout.xml | 2 + .../qemuxml2argv-graphics-spice.xml | 1 + .../qemuxml2argv-graphics-vnc-policy.xml | 1 + .../qemuxml2argv-graphics-vnc-sasl.xml | 1 + .../qemuxml2argv-graphics-vnc-socket.xml | 1 + .../qemuxml2argv-graphics-vnc-tls.xml | 1 + .../qemuxml2argv-graphics-vnc-websocket.xml | 1 + .../qemuxml2argvdata/qemuxml2argv-graphics-vnc.xml | 1 + tests/qemuxml2argvdata/qemuxml2argv-input-xen.xml | 1 + .../qemuxml2argv-net-bandwidth.xml | 1 + tests/qemuxml2argvdata/qemuxml2argv-pci-bridge.xml | 1 + .../qemuxml2argvdata/qemuxml2argv-pseries-disk.xml | 1 - .../qemuxml2xmlout-graphics-listen-network2.xml | 1 + .../qemuxml2xmlout-graphics-spice-timeout.xml | 1 + tests/vmx2xmldata/vmx2xml-graphics-vnc.xml | 1 + 25 files changed, 61 insertions(+), 36 deletions(-)
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 1a1ac54..e495884 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -12339,30 +12340,25 @@ virDomainDefParseXML(xmlDocPtr xml, } VIR_FREE(nodes);
- /* If graphics are enabled, there's an implicit PS2 mouse */ - if (def->ngraphics > 0) { - virDomainInputDefPtr input; + /* If graphics are enabled, there's an implicit PS2 mouse and PS2 keyboard */ + if (def->ngraphics > 0 && + ARCH_IS_X86(def->os.arch)) { + int input_bus = VIR_DOMAIN_INPUT_BUS_XEN; + + if (STREQ(def->os.type, "hvm")) + input_bus = VIR_DOMAIN_INPUT_BUS_PS2;
- if (VIR_ALLOC(input) < 0) { + if (virDomainDefMaybeAddInput(def, + VIR_DOMAIN_INPUT_TYPE_MOUSE, + input_bus) < 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); + if (virDomainDefMaybeAddInput(def, + VIR_DOMAIN_INPUT_TYPE_KBD, + input_bus) < 0)
This patch also adds an implicit keyboard, without mentioning it in the commit message.
goto error; - } - def->inputs[def->ninputs] = input; - def->ninputs++; }
- /* analysis of the sound devices */ if ((n = virXPathNodeSet("./devices/sound", ctxt, &nodes)) < 0) { goto error; @@ -17338,16 +17334,21 @@ 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 graphics is enabled, add the implicit mouse/keyboard */ + 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; +
+ autoInput.type = VIR_DOMAIN_INPUT_TYPE_KBD; + if (virDomainInputDefFormat(buf, &autoInput, flags) < 0) + goto error;
We can't output the implicit PS/2 keyboard, that would make the XML unreadable by older libvirtd that didn't know the keyboard input type.
+ }
for (n = 0; n < def->ngraphics; n++) if (virDomainGraphicsDefFormat(buf, def->graphics[n], flags) < 0)
Jan

On 2014年02月03日 23:09, Ján Tomko wrote:
On 12/19/2013 08:50 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 | 71 +++++++++++----------- src/util/virarch.h | 2 + ...qemuhotplug-console-compat-2+console-virtio.xml | 1 + .../qemuxml2argv-console-compat-2.xml | 1 + .../qemuxml2argv-graphics-listen-network.xml | 1 + .../qemuxml2argv-graphics-listen-network2.xml | 1 + .../qemuxml2argv-graphics-sdl-fullscreen.xml | 1 + .../qemuxml2argvdata/qemuxml2argv-graphics-sdl.xml | 1 + .../qemuxml2argv-graphics-spice-compression.xml | 1 + .../qemuxml2argv-graphics-spice-qxl-vga.xml | 1 + .../qemuxml2argv-graphics-spice-timeout.xml | 2 + .../qemuxml2argv-graphics-spice.xml | 1 + .../qemuxml2argv-graphics-vnc-policy.xml | 1 + .../qemuxml2argv-graphics-vnc-sasl.xml | 1 + .../qemuxml2argv-graphics-vnc-socket.xml | 1 + .../qemuxml2argv-graphics-vnc-tls.xml | 1 + .../qemuxml2argv-graphics-vnc-websocket.xml | 1 + .../qemuxml2argvdata/qemuxml2argv-graphics-vnc.xml | 1 + tests/qemuxml2argvdata/qemuxml2argv-input-xen.xml | 1 + .../qemuxml2argv-net-bandwidth.xml | 1 + tests/qemuxml2argvdata/qemuxml2argv-pci-bridge.xml | 1 + .../qemuxml2argvdata/qemuxml2argv-pseries-disk.xml | 1 - .../qemuxml2xmlout-graphics-listen-network2.xml | 1 + .../qemuxml2xmlout-graphics-spice-timeout.xml | 1 + tests/vmx2xmldata/vmx2xml-graphics-vnc.xml | 1 + 25 files changed, 61 insertions(+), 36 deletions(-)
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 1a1ac54..e495884 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -12339,30 +12340,25 @@ virDomainDefParseXML(xmlDocPtr xml, } VIR_FREE(nodes);
- /* If graphics are enabled, there's an implicit PS2 mouse */ - if (def->ngraphics > 0) { - virDomainInputDefPtr input; + /* If graphics are enabled, there's an implicit PS2 mouse and PS2 keyboard */ + if (def->ngraphics > 0 && + ARCH_IS_X86(def->os.arch)) { + int input_bus = VIR_DOMAIN_INPUT_BUS_XEN; + + if (STREQ(def->os.type, "hvm")) + input_bus = VIR_DOMAIN_INPUT_BUS_PS2;
- if (VIR_ALLOC(input) < 0) { + if (virDomainDefMaybeAddInput(def, + VIR_DOMAIN_INPUT_TYPE_MOUSE, + input_bus) < 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); + if (virDomainDefMaybeAddInput(def, + VIR_DOMAIN_INPUT_TYPE_KBD, + input_bus) < 0) This patch also adds an implicit keyboard, without mentioning it in the commit message.
I will add it in next version.
goto error; - } - def->inputs[def->ninputs] = input; - def->ninputs++; }
- /* analysis of the sound devices */ if ((n = virXPathNodeSet("./devices/sound", ctxt, &nodes)) < 0) { goto error; @@ -17338,16 +17334,21 @@ 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 graphics is enabled, add the implicit mouse/keyboard */ + 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; + + autoInput.type = VIR_DOMAIN_INPUT_TYPE_KBD; + if (virDomainInputDefFormat(buf, &autoInput, flags) < 0) + goto error;
We can't output the implicit PS/2 keyboard, that would make the XML unreadable by older libvirtd that didn't know the keyboard input type.
ok, I will remove this.
+ }
for (n = 0; n < def->ngraphics; n++) if (virDomainGraphicsDefFormat(buf, def->graphics[n], flags) < 0) 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 | 1 + tests/qemucapabilitiesdata/caps_1.6.50-1.caps | 1 + tests/qemuhelptest.c | 8 ++++++++ 9 files changed, 17 insertions(+) diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index 5e9c65e..f963661 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -246,6 +246,7 @@ VIR_ENUM_IMPL(virQEMUCaps, QEMU_CAPS_LAST, "boot-strict", /* 160 */ "pvpanic", /* 161 */ + "usb-kbd", ); struct _virQEMUCaps { @@ -1398,6 +1399,7 @@ struct virQEMUCapsStringFlags virQEMUCapsObjectTypes[] = { { "virtio-mmio", QEMU_CAPS_DEVICE_VIRTIO_MMIO }, { "ich9-intel-hda", QEMU_CAPS_DEVICE_ICH9_INTEL_HDA }, { "pvpanic", QEMU_CAPS_DEVICE_PANIC }, + { "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 bbf4972..fe487a0 100644 --- a/src/qemu/qemu_capabilities.h +++ b/src/qemu/qemu_capabilities.h @@ -200,6 +200,7 @@ enum virQEMUCapsFlags { QEMU_CAPS_KVM_PIT_TICK_POLICY = 159, /* kvm-pit.lost_tick_policy */ QEMU_CAPS_BOOT_STRICT = 160, /* -boot strict */ QEMU_CAPS_DEVICE_PANIC = 161, /* -device pvpanic */ + QEMU_CAPS_DEVICE_USB_KBD = 162, /*-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 1e5bb74..7548fb9 100644 --- a/tests/qemucapabilitiesdata/caps_1.5.3-1.caps +++ b/tests/qemucapabilitiesdata/caps_1.5.3-1.caps @@ -134,4 +134,5 @@ <flag name='boot-strict'/> <flag name='pvpanic'/> <flag name='reboot-timeout'/> + <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 c7ce591..e6504f5 100644 --- a/tests/qemucapabilitiesdata/caps_1.6.0-1.caps +++ b/tests/qemucapabilitiesdata/caps_1.6.0-1.caps @@ -138,4 +138,5 @@ <flag name='boot-strict'/> <flag name='pvpanic'/> <flag name='reboot-timeout'/> + <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 ba64177..a5f1f55 100644 --- a/tests/qemucapabilitiesdata/caps_1.6.50-1.caps +++ b/tests/qemucapabilitiesdata/caps_1.6.50-1.caps @@ -137,4 +137,5 @@ <flag name='boot-strict'/> <flag name='pvpanic'/> <flag name='reboot-timeout'/> + <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 | 41 ++++++++++++++++------ 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, 103 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 a80559e..00072aa 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -5307,9 +5307,19 @@ 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)) + goto error; + virBufferAsprintf(&buf, "usb-kbd,id=%s", dev->info.alias); + break; + } if (qemuBuildDeviceAddressStr(&buf, def, &dev->info, qemuCaps) < 0) goto error; @@ -8996,9 +9006,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; + } } } } @@ -11684,20 +11702,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 847e96f..4abb821 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -1177,6 +1177,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

On 12/19/2013 08:50 AM, Li Zhang wrote:
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 | 41 ++++++++++++++++------ 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, 103 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/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; } }
I'm not familiar with the xen driver, but I'd feel safer just ignoring the implicit USB keyboard. I think they should also be in a separate commit. Jan

On 2014年02月03日 23:09, Ján Tomko wrote:
On 12/19/2013 08:50 AM, Li Zhang wrote:
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 | 41 ++++++++++++++++------ 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, 103 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/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; } } I'm not familiar with the xen driver, but I'd feel safer just ignoring the implicit USB keyboard. I think they should also be in a separate commit.
I'm not familiar with it either. I just added it according to Dan's comments.
Jan

From: Li Zhang <zhlcindy@linux.vnet.ibm.com> There is no keyboard working on PPC64 and PS2 mouse is only for PPC64 when graphics are enabled. It needs to add a USB keyboard and USB mouse for it. This patch is to add a USB keyboard and USB mouse when graphics are enabled. Signed-off-by: Li Zhang <zhlcindy@linux.vnet.ibm.com> --- src/qemu/qemu_domain.c | 23 +++++++++++++++++++++- .../qemuxml2argvdata/qemuxml2argv-pseries-disk.xml | 2 ++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index e964c75..82d6948 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 addDefaultUSBKBD = false; + bool addDefaultUSBMouse = false; /* check for emulator and create a default one if needed */ if (!def->emulator && @@ -728,9 +730,14 @@ qemuDomainDefPostParse(virDomainDefPtr def, addDefaultMemballoon = false; break; + case VIR_ARCH_PPC64: + addPCIRoot = true; + addDefaultUSBKBD = true; + addDefaultUSBMouse = true; + 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 +790,20 @@ qemuDomainDefPostParse(virDomainDefPtr def, def->memballoon = memballoon; } + if (addDefaultUSBKBD && + def->ngraphics > 0 && + virDomainDefMaybeAddInput(def, + VIR_DOMAIN_INPUT_TYPE_KBD, + VIR_DOMAIN_INPUT_BUS_USB) < 0) + return -1; + + if (addDefaultUSBMouse && + def->ngraphics > 0 && + virDomainDefMaybeAddInput(def, + VIR_DOMAIN_INPUT_TYPE_MOUSE, + 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 8dde776..ac1767b 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-pseries-disk.xml +++ b/tests/qemuxml2argvdata/qemuxml2argv-pseries-disk.xml @@ -30,6 +30,8 @@ <controller type='usb' index='0'/> <controller type='scsi' index='0'/> <controller type='pci' index='0' model='pci-root'/> + <input type='kbd' bus='usb'/> + <input type='mouse' bus='usb'/> <graphics type='sdl'/> <video> <model type='cirrus' vram='9216' heads='1'/> -- 1.8.2.1

ping On 2013年12月19日 15:50, Li Zhang wrote:
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 default input devices. conf: 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 and USB mouse for PPC64
v5 -> v4: * Add PS/2 KBD definition in XML file. (Daniel.P.Berrange) * Allow PS/2 KBD devices and set KBD default bus as PS2 for X86, USB for non-x86. (Daniel.P.Berrange) * Add an implicit PS/2 KBD as PS/2 mouse. (Danniel.P.Berrange)
v4 -> v3: * Don't remove PS2 mouse device for other virtualization drivers (Jan Tomko).
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 | 92 ++++++++++++++-------- 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 | 23 +++++- 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, 212 insertions(+), 62 deletions(-) create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-pseries-usb-kbd.args create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-pseries-usb-kbd.xml

Is this patch series ready to be pushed? Without it, libvirt cannot create VMs in ppc64 hosts with a working VNC console (unless you use the qemu command line pass-through hack), this affects both oVirt and VDSM, since they rely on graphical terminals to work. On Thu, Dec 19, 2013 at 5:50 AM, Li Zhang <zhlcindy@gmail.com> wrote:
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 default input devices. conf: 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 and USB mouse for PPC64
v5 -> v4: * Add PS/2 KBD definition in XML file. (Daniel.P.Berrange) * Allow PS/2 KBD devices and set KBD default bus as PS2 for X86, USB for non-x86. (Daniel.P.Berrange) * Add an implicit PS/2 KBD as PS/2 mouse. (Danniel.P.Berrange)
v4 -> v3: * Don't remove PS2 mouse device for other virtualization drivers (Jan Tomko).
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 | 92 ++++++++++++++-------- 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 | 23 +++++- 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, 212 insertions(+), 62 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
-- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
participants (3)
-
Ján Tomko
-
Li Zhang
-
Vitor Lima