qemu: Refuse to use "ps2" on machines that do not have this bus

The "ps2" bus is only available on certain machines like x86. On
machines like s390x, we should refuse to add a device to this bus
instead of silently ignoring it.

Looking at the QEMU sources, PS/2 is only available if the QEMU binary
has the "i8042" device, so let's check for that and only allow "ps2"
devices if this QEMU device is available, or if we're on x86 anyway
(so we don't have to fake the QEMU_CAPS_DEVICE_I8042 capability in
all the tests that use <input ... bus='ps2'/> in their xml data).

Reported-by: Sebastian Mitterle <smitterl@redhat.com>
Buglink: https://bugzilla.redhat.com/show_bug.cgi?id=1763191
Signed-off-by: Thomas Huth <thuth@redhat.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
Thomas Huth 2020-01-15 13:23:56 +01:00 committed by Michal Privoznik
parent 4494b9b9d0
commit e7a65484ba
37 changed files with 42 additions and 49 deletions

View File

@ -554,6 +554,9 @@ VIR_ENUM_IMPL(virQEMUCaps,
"savevm-monitor-nodes",
"drive-nvme",
"smp-dies",
/* 350 */
"i8042",
);
@ -1245,6 +1248,7 @@ struct virQEMUCapsStringFlags virQEMUCapsObjectTypes[] = {
{ "vhost-user-vga", QEMU_CAPS_DEVICE_VHOST_USER_VGA },
{ "ramfb", QEMU_CAPS_DEVICE_RAMFB },
{ "max-arm-cpu", QEMU_CAPS_ARM_MAX_CPU },
{ "i8042", QEMU_CAPS_DEVICE_I8042 },
};
static struct virQEMUCapsStringFlags virQEMUCapsDevicePropsVirtioBalloon[] = {

View File

@ -536,6 +536,9 @@ typedef enum { /* virQEMUCapsFlags grouping marker for syntax-check */
QEMU_CAPS_DRIVE_NVME, /* -drive file.driver=nvme */
QEMU_CAPS_SMP_DIES, /* -smp dies= */
/* 350 */
QEMU_CAPS_DEVICE_I8042, /* PS/2 controller */
QEMU_CAPS_LAST /* this must always be the last item */
} virQEMUCapsFlags;

View File

@ -8039,13 +8039,21 @@ qemuDomainDeviceDefValidateGraphics(const virDomainGraphicsDef *graphics,
static int
qemuDomainDeviceDefValidateInput(const virDomainInputDef *input,
const virDomainDef *def G_GNUC_UNUSED,
const virDomainDef *def,
virQEMUCapsPtr qemuCaps)
{
const char *baseName;
int cap;
int ccwCap;
if (input->bus == VIR_DOMAIN_INPUT_BUS_PS2 && !ARCH_IS_X86(def->os.arch) &&
!virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_I8042)) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("%s is not supported by this QEMU binary"),
virDomainInputBusTypeToString(input->bus));
return -1;
}
if (input->bus != VIR_DOMAIN_INPUT_BUS_VIRTIO)
return 0;

View File

@ -84,6 +84,7 @@
<flag name='isa-serial'/>
<flag name='hda-output'/>
<flag name='mch'/>
<flag name='i8042'/>
<version>1005003</version>
<kvmVersion>0</kvmVersion>
<microcodeVersion>43100245</microcodeVersion>

View File

@ -89,6 +89,7 @@
<flag name='isa-serial'/>
<flag name='hda-output'/>
<flag name='mch'/>
<flag name='i8042'/>
<version>1006000</version>
<kvmVersion>0</kvmVersion>
<microcodeVersion>43100243</microcodeVersion>

View File

@ -91,6 +91,7 @@
<flag name='isa-serial'/>
<flag name='hda-output'/>
<flag name='mch'/>
<flag name='i8042'/>
<version>1007000</version>
<kvmVersion>0</kvmVersion>
<microcodeVersion>43100244</microcodeVersion>

View File

@ -107,6 +107,7 @@
<flag name='isa-serial'/>
<flag name='hda-output'/>
<flag name='mch'/>
<flag name='i8042'/>
<version>2001001</version>
<kvmVersion>0</kvmVersion>
<microcodeVersion>43100240</microcodeVersion>

View File

@ -139,6 +139,7 @@
<flag name='vhost-vsock'/>
<flag name='egl-headless'/>
<flag name='iothread.poll-max-ns'/>
<flag name='i8042'/>
<version>2010000</version>
<kvmVersion>0</kvmVersion>
<microcodeVersion>42900287</microcodeVersion>

View File

@ -182,6 +182,7 @@
<flag name='egl-headless'/>
<flag name='iothread.poll-max-ns'/>
<flag name='x86-max-cpu'/>
<flag name='i8042'/>
<version>2010000</version>
<kvmVersion>0</kvmVersion>
<microcodeVersion>43100287</microcodeVersion>

View File

@ -188,6 +188,7 @@
<flag name='egl-headless'/>
<flag name='iothread.poll-max-ns'/>
<flag name='x86-max-cpu'/>
<flag name='i8042'/>
<version>2011000</version>
<kvmVersion>0</kvmVersion>
<microcodeVersion>43100288</microcodeVersion>

View File

@ -153,6 +153,7 @@
<flag name='iothread.poll-max-ns'/>
<flag name='memory-backend-file.align'/>
<flag name='drive-nvme'/>
<flag name='i8042'/>
<version>2011090</version>
<kvmVersion>0</kvmVersion>
<microcodeVersion>42900289</microcodeVersion>

View File

@ -197,6 +197,7 @@
<flag name='memory-backend-file.align'/>
<flag name='x86-max-cpu'/>
<flag name='drive-nvme'/>
<flag name='i8042'/>
<version>2011090</version>
<kvmVersion>0</kvmVersion>
<microcodeVersion>43100289</microcodeVersion>

View File

@ -133,6 +133,7 @@
<flag name='sdl-gl'/>
<flag name='hda-output'/>
<flag name='mch'/>
<flag name='i8042'/>
<version>2004000</version>
<kvmVersion>0</kvmVersion>
<microcodeVersion>43100242</microcodeVersion>

View File

@ -139,6 +139,7 @@
<flag name='sdl-gl'/>
<flag name='hda-output'/>
<flag name='mch'/>
<flag name='i8042'/>
<version>2005000</version>
<kvmVersion>0</kvmVersion>
<microcodeVersion>43100243</microcodeVersion>

View File

@ -118,6 +118,7 @@
<flag name='nbd-tls'/>
<flag name='sdl-gl'/>
<flag name='hda-output'/>
<flag name='i8042'/>
<version>2006000</version>
<kvmVersion>0</kvmVersion>
<microcodeVersion>42900244</microcodeVersion>

View File

@ -151,6 +151,7 @@
<flag name='sdl-gl'/>
<flag name='hda-output'/>
<flag name='mch'/>
<flag name='i8042'/>
<version>2006000</version>
<kvmVersion>0</kvmVersion>
<microcodeVersion>43100244</microcodeVersion>

View File

@ -156,6 +156,7 @@
<flag name='sdl-gl'/>
<flag name='hda-output'/>
<flag name='mch'/>
<flag name='i8042'/>
<version>2007000</version>
<kvmVersion>0</kvmVersion>
<microcodeVersion>43100245</microcodeVersion>

View File

@ -159,6 +159,7 @@
<flag name='hda-output'/>
<flag name='vhost-vsock'/>
<flag name='mch'/>
<flag name='i8042'/>
<version>2008000</version>
<kvmVersion>0</kvmVersion>
<microcodeVersion>43100246</microcodeVersion>

View File

@ -131,6 +131,7 @@
<flag name='blockdev-del'/>
<flag name='vhost-vsock'/>
<flag name='iothread.poll-max-ns'/>
<flag name='i8042'/>
<version>2009000</version>
<kvmVersion>0</kvmVersion>
<microcodeVersion>42900247</microcodeVersion>

View File

@ -176,6 +176,7 @@
<flag name='mch'/>
<flag name='iothread.poll-max-ns'/>
<flag name='x86-max-cpu'/>
<flag name='i8042'/>
<version>2009000</version>
<kvmVersion>0</kvmVersion>
<microcodeVersion>43100247</microcodeVersion>

View File

@ -155,6 +155,7 @@
<flag name='bochs-display'/>
<flag name='ramfb'/>
<flag name='drive-nvme'/>
<flag name='i8042'/>
<version>2012050</version>
<kvmVersion>0</kvmVersion>
<microcodeVersion>42900239</microcodeVersion>

View File

@ -202,6 +202,7 @@
<flag name='bochs-display'/>
<flag name='ramfb'/>
<flag name='drive-nvme'/>
<flag name='i8042'/>
<version>3000000</version>
<kvmVersion>0</kvmVersion>
<microcodeVersion>43100239</microcodeVersion>

View File

@ -159,6 +159,7 @@
<flag name='overcommit'/>
<flag name='bochs-display'/>
<flag name='drive-nvme'/>
<flag name='i8042'/>
<version>3000091</version>
<kvmVersion>0</kvmVersion>
<microcodeVersion>42900240</microcodeVersion>

View File

@ -205,6 +205,7 @@
<flag name='bochs-display'/>
<flag name='ramfb'/>
<flag name='drive-nvme'/>
<flag name='i8042'/>
<version>3000092</version>
<kvmVersion>0</kvmVersion>
<microcodeVersion>43100240</microcodeVersion>

View File

@ -173,6 +173,7 @@
<flag name='migration-file-drop-cache'/>
<flag name='machine.pseries.cap-ccf-assist'/>
<flag name='drive-nvme'/>
<flag name='i8042'/>
<version>4000000</version>
<kvmVersion>0</kvmVersion>
<microcodeVersion>42900240</microcodeVersion>

View File

@ -210,6 +210,7 @@
<flag name='migration-file-drop-cache'/>
<flag name='ramfb'/>
<flag name='drive-nvme'/>
<flag name='i8042'/>
<version>4000000</version>
<kvmVersion>0</kvmVersion>
<microcodeVersion>43100240</microcodeVersion>

View File

@ -216,6 +216,7 @@
<flag name='blockdev-file-dynamic-auto-read-only'/>
<flag name='drive-nvme'/>
<flag name='smp-dies'/>
<flag name='i8042'/>
<version>4001000</version>
<kvmVersion>0</kvmVersion>
<microcodeVersion>43100241</microcodeVersion>

View File

@ -177,6 +177,7 @@
<flag name='blockdev-file-dynamic-auto-read-only'/>
<flag name='drive-nvme'/>
<flag name='smp-dies'/>
<flag name='i8042'/>
<version>4001050</version>
<kvmVersion>0</kvmVersion>
<microcodeVersion>42900242</microcodeVersion>

View File

@ -219,6 +219,7 @@
<flag name='savevm-monitor-nodes'/>
<flag name='drive-nvme'/>
<flag name='smp-dies'/>
<flag name='i8042'/>
<version>4002000</version>
<kvmVersion>0</kvmVersion>
<microcodeVersion>43100242</microcodeVersion>

View File

@ -44,12 +44,6 @@
<alias name='virtio-serial0'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/>
</controller>
<input type='mouse' bus='ps2'>
<alias name='input0'/>
</input>
<input type='keyboard' bus='ps2'>
<alias name='input1'/>
</input>
<memballoon model='none'/>
<panic model='s390'/>
</devices>

View File

@ -54,12 +54,6 @@
<alias name='virtio-serial0'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/>
</controller>
<input type='mouse' bus='ps2'>
<alias name='input0'/>
</input>
<input type='keyboard' bus='ps2'>
<alias name='input1'/>
</input>
<memballoon model='none'>
<alias name='balloon0'/>
</memballoon>

View File

@ -54,12 +54,6 @@
<alias name='virtio-serial0'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/>
</controller>
<input type='mouse' bus='ps2'>
<alias name='input0'/>
</input>
<input type='keyboard' bus='ps2'>
<alias name='input1'/>
</input>
<memballoon model='none'/>
<panic model='s390'/>
</devices>

View File

@ -44,12 +44,6 @@
<alias name='virtio-serial0'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/>
</controller>
<input type='mouse' bus='ps2'>
<alias name='input0'/>
</input>
<input type='keyboard' bus='ps2'>
<alias name='input1'/>
</input>
<memballoon model='none'/>
<panic model='s390'/>
</devices>

View File

@ -53,12 +53,6 @@
<alias name='virtio-serial0'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/>
</controller>
<input type='mouse' bus='ps2'>
<alias name='input0'/>
</input>
<input type='keyboard' bus='ps2'>
<alias name='input1'/>
</input>
<memballoon model='none'/>
<panic model='s390'/>
</devices>

View File

@ -53,12 +53,6 @@
<alias name='virtio-serial0'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/>
</controller>
<input type='mouse' bus='ps2'>
<alias name='input0'/>
</input>
<input type='keyboard' bus='ps2'>
<alias name='input1'/>
</input>
<memballoon model='none'/>
<panic model='s390'/>
</devices>

View File

@ -43,12 +43,6 @@
<alias name='virtio-serial0'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/>
</controller>
<input type='mouse' bus='ps2'>
<alias name='input0'/>
</input>
<input type='keyboard' bus='ps2'>
<alias name='input1'/>
</input>
<memballoon model='none'/>
<panic model='s390'/>
</devices>

View File

@ -34,12 +34,6 @@
<alias name='virtio-serial0'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/>
</controller>
<input type='mouse' bus='ps2'>
<alias name='input0'/>
</input>
<input type='keyboard' bus='ps2'>
<alias name='input1'/>
</input>
<memballoon model='none'/>
<panic model='s390'/>
</devices>