On 2014年02月03日 23:09, Ján Tomko wrote:
On 12/19/2013 08:50 AM, Li Zhang wrote:
> From: Li Zhang <zhlcindy(a)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(a)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