From: Li Zhang <zhlcindy@xxxxxxxxxxxxxxxxxx> PS2 device only works for X86 platform, other platforms may need USB devices instead. Athough it doesn't influence the QEMU command line, but it's not right to add PS2 mouse/keyboard for non-X86 platform. So, this patch is to remove PS2 devices for non-x86 platforms. Signed-off-by: Li Zhang <zhlcindy@xxxxxxxxxxxxxxxxxx> --- src/conf/domain_conf.c | 31 +++++++++++++--------- src/util/virarch.h | 2 ++ .../qemuxml2argvdata/qemuxml2argv-pseries-disk.xml | 2 -- 3 files changed, 20 insertions(+), 15 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index c475d87..935255d 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -7838,7 +7838,8 @@ virDomainInputDefParseXML(const virDomainDef *dom, } else { if (STREQ(dom->os.type, "hvm")) { if ((def->type == VIR_DOMAIN_INPUT_TYPE_MOUSE || - def->type == VIR_DOMAIN_INPUT_TYPE_KBD)) + 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; @@ -12497,7 +12498,8 @@ virDomainDefParseXML(xmlDocPtr xml, VIR_FREE(nodes); /* If graphics are enabled, there's an implicit PS2 mouse */ - if (def->ngraphics > 0) { + if (def->ngraphics > 0 && + ARCH_IS_X86(def->os.arch)) { int input_bus = VIR_DOMAIN_INPUT_BUS_XEN; if (STREQ(def->os.type, "hvm")) @@ -17533,19 +17535,22 @@ virDomainDefFormatInternal(virDomainDefPtr def, if (def->ngraphics > 0) { /* If graphics is enabled, add the implicit mouse/keyboard */ - 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 (!(flags & VIR_DOMAIN_XML_MIGRATABLE)) { - autoInput.type = VIR_DOMAIN_INPUT_TYPE_KBD; + if ((ARCH_IS_X86(def->os.arch)) || + def->os.arch == VIR_ARCH_NONE) { + 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 (!(flags & VIR_DOMAIN_XML_MIGRATABLE)) { + autoInput.type = VIR_DOMAIN_INPUT_TYPE_KBD; + if (virDomainInputDefFormat(buf, &autoInput, flags) < 0) + goto error; + } } for (n = 0; n < def->ngraphics; n++) diff --git a/src/util/virarch.h b/src/util/virarch.h index b180400..c4d67ce 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 05e0f63..8dde776 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-pseries-disk.xml +++ b/tests/qemuxml2argvdata/qemuxml2argv-pseries-disk.xml @@ -30,8 +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'/> - <input type='keyboard' bus='ps2'/> <graphics type='sdl'/> <video> <model type='cirrus' vram='9216' heads='1'/> -- 1.8.2.1 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list