Introduce tests to verify that the 'ps2' feature is correctly parsed
when given either 'dirty' XML from a user or 'clean' canonical XML,
as produced by libvirt. This also tests the transformation from libvirt's
internal state to the aforementioned canonical form and to a QEMU
command line.
As a bonus, we also test some known bad configurations:
- When user explicitly adds ps2 bus inputs, but also explicitly disables
the 'ps2' feature.
- When user explicitly enables the 'vmport' feature, but also explicitly
disables the 'ps2' feature. This is not supported by QEMU and will
result in vmport device not being created without emitting any warning
or error.
Signed-off-by: Kamil Szczęk <kamil(a)szczek.dev>
---
...-off-explicit-ps2-inputs.x86_64-latest.err | 1 +
.../machine-i8042-off-explicit-ps2-inputs.xml | 19 +++++++++++
...hine-i8042-off-vmport-on.x86_64-latest.err | 1 +
.../machine-i8042-off-vmport-on.xml | 18 ++++++++++
.../machine-i8042-off.x86_64-6.2.0.err | 1 +
.../machine-i8042-off.x86_64-latest.args | 33 ++++++++++++++++++
.../machine-i8042-off.x86_64-latest.xml | 32 +++++++++++++++++
tests/qemuxmlconfdata/machine-i8042-off.xml | 17 ++++++++++
.../machine-i8042-on.x86_64-6.2.0.err | 1 +
.../machine-i8042-on.x86_64-latest.args | 33 ++++++++++++++++++
.../machine-i8042-on.x86_64-latest.xml | 34 +++++++++++++++++++
tests/qemuxmlconfdata/machine-i8042-on.xml | 17 ++++++++++
tests/qemuxmlconftest.c | 6 ++++
13 files changed, 213 insertions(+)
create mode 100644
tests/qemuxmlconfdata/machine-i8042-off-explicit-ps2-inputs.x86_64-latest.err
create mode 100644 tests/qemuxmlconfdata/machine-i8042-off-explicit-ps2-inputs.xml
create mode 100644 tests/qemuxmlconfdata/machine-i8042-off-vmport-on.x86_64-latest.err
create mode 100644 tests/qemuxmlconfdata/machine-i8042-off-vmport-on.xml
create mode 100644 tests/qemuxmlconfdata/machine-i8042-off.x86_64-6.2.0.err
create mode 100644 tests/qemuxmlconfdata/machine-i8042-off.x86_64-latest.args
create mode 100644 tests/qemuxmlconfdata/machine-i8042-off.x86_64-latest.xml
create mode 100644 tests/qemuxmlconfdata/machine-i8042-off.xml
create mode 100644 tests/qemuxmlconfdata/machine-i8042-on.x86_64-6.2.0.err
create mode 100644 tests/qemuxmlconfdata/machine-i8042-on.x86_64-latest.args
create mode 100644 tests/qemuxmlconfdata/machine-i8042-on.x86_64-latest.xml
create mode 100644 tests/qemuxmlconfdata/machine-i8042-on.xml
diff --git a/tests/qemuxmlconfdata/machine-i8042-off-explicit-ps2-inputs.x86_64-latest.err
b/tests/qemuxmlconfdata/machine-i8042-off-explicit-ps2-inputs.x86_64-latest.err
new file mode 100644
index 0000000000..4fed60aa37
--- /dev/null
+++ b/tests/qemuxmlconfdata/machine-i8042-off-explicit-ps2-inputs.x86_64-latest.err
@@ -0,0 +1 @@
+unsupported configuration: ps2 bus inputs require the ps2 feature not to be disabled
diff --git a/tests/qemuxmlconfdata/machine-i8042-off-explicit-ps2-inputs.xml
b/tests/qemuxmlconfdata/machine-i8042-off-explicit-ps2-inputs.xml
new file mode 100644
index 0000000000..f90677670b
--- /dev/null
+++ b/tests/qemuxmlconfdata/machine-i8042-off-explicit-ps2-inputs.xml
@@ -0,0 +1,19 @@
+<domain type='qemu'>
+ <name>QEMUGuest1</name>
+ <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
+ <memory unit='KiB'>219100</memory>
+ <vcpu placement='static'>1</vcpu>
+ <os>
+ <type arch='x86_64' machine='q35'>hvm</type>
+ </os>
+ <features>
+ <ps2 state='off'/>
+ </features>
+ <devices>
+ <emulator>/usr/bin/qemu-system-x86_64</emulator>
+ <controller type='usb' model='none'/>
+ <input type='mouse' bus='ps2'/>
+ <input type='keyboard' bus='ps2'/>
+ <memballoon model='none'/>
+ </devices>
+</domain>
diff --git a/tests/qemuxmlconfdata/machine-i8042-off-vmport-on.x86_64-latest.err
b/tests/qemuxmlconfdata/machine-i8042-off-vmport-on.x86_64-latest.err
new file mode 100644
index 0000000000..0c3b7280c0
--- /dev/null
+++ b/tests/qemuxmlconfdata/machine-i8042-off-vmport-on.x86_64-latest.err
@@ -0,0 +1 @@
+unsupported configuration: vmport feature requires the ps2 feature not to be disabled
diff --git a/tests/qemuxmlconfdata/machine-i8042-off-vmport-on.xml
b/tests/qemuxmlconfdata/machine-i8042-off-vmport-on.xml
new file mode 100644
index 0000000000..957da054b8
--- /dev/null
+++ b/tests/qemuxmlconfdata/machine-i8042-off-vmport-on.xml
@@ -0,0 +1,18 @@
+<domain type='qemu'>
+ <name>QEMUGuest1</name>
+ <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
+ <memory unit='KiB'>219100</memory>
+ <vcpu placement='static'>1</vcpu>
+ <os>
+ <type arch='x86_64' machine='q35'>hvm</type>
+ </os>
+ <features>
+ <vmport state='on'/>
+ <ps2 state='off'/>
+ </features>
+ <devices>
+ <emulator>/usr/bin/qemu-system-x86_64</emulator>
+ <controller type='usb' model='none'/>
+ <memballoon model='none'/>
+ </devices>
+</domain>
diff --git a/tests/qemuxmlconfdata/machine-i8042-off.x86_64-6.2.0.err
b/tests/qemuxmlconfdata/machine-i8042-off.x86_64-6.2.0.err
new file mode 100644
index 0000000000..3a12712915
--- /dev/null
+++ b/tests/qemuxmlconfdata/machine-i8042-off.x86_64-6.2.0.err
@@ -0,0 +1 @@
+unsupported configuration: ps2 feature state cannot be controlled with this QEMU binary
diff --git a/tests/qemuxmlconfdata/machine-i8042-off.x86_64-latest.args
b/tests/qemuxmlconfdata/machine-i8042-off.x86_64-latest.args
new file mode 100644
index 0000000000..e340d164fc
--- /dev/null
+++ b/tests/qemuxmlconfdata/machine-i8042-off.x86_64-latest.args
@@ -0,0 +1,33 @@
+LC_ALL=C \
+PATH=/bin \
+HOME=/var/lib/libvirt/qemu/domain--1-QEMUGuest1 \
+USER=test \
+LOGNAME=test \
+XDG_DATA_HOME=/var/lib/libvirt/qemu/domain--1-QEMUGuest1/.local/share \
+XDG_CACHE_HOME=/var/lib/libvirt/qemu/domain--1-QEMUGuest1/.cache \
+XDG_CONFIG_HOME=/var/lib/libvirt/qemu/domain--1-QEMUGuest1/.config \
+/usr/bin/qemu-system-x86_64 \
+-name guest=QEMUGuest1,debug-threads=on \
+-S \
+-object
'{"qom-type":"secret","id":"masterKey0","format":"raw","file":"/var/lib/libvirt/qemu/domain--1-QEMUGuest1/master-key.aes"}'
\
+-machine q35,usb=off,i8042=off,dump-guest-core=off,memory-backend=pc.ram,acpi=off \
+-accel tcg \
+-cpu qemu64 \
+-m size=219136k \
+-object
'{"qom-type":"memory-backend-ram","id":"pc.ram","size":224395264}'
\
+-overcommit mem-lock=off \
+-smp 1,sockets=1,cores=1,threads=1 \
+-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \
+-display none \
+-no-user-config \
+-nodefaults \
+-chardev socket,id=charmonitor,fd=1729,server=on,wait=off \
+-mon chardev=charmonitor,id=monitor,mode=control \
+-rtc base=utc \
+-no-shutdown \
+-boot strict=on \
+-audiodev
'{"id":"audio1","driver":"none"}' \
+-global ICH9-LPC.noreboot=off \
+-watchdog-action reset \
+-sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,resourcecontrol=deny \
+-msg timestamp=on
diff --git a/tests/qemuxmlconfdata/machine-i8042-off.x86_64-latest.xml
b/tests/qemuxmlconfdata/machine-i8042-off.x86_64-latest.xml
new file mode 100644
index 0000000000..b5c503e6df
--- /dev/null
+++ b/tests/qemuxmlconfdata/machine-i8042-off.x86_64-latest.xml
@@ -0,0 +1,32 @@
+<domain type='qemu'>
+ <name>QEMUGuest1</name>
+ <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
+ <memory unit='KiB'>219100</memory>
+ <currentMemory unit='KiB'>219100</currentMemory>
+ <vcpu placement='static'>1</vcpu>
+ <os>
+ <type arch='x86_64' machine='q35'>hvm</type>
+ <boot dev='hd'/>
+ </os>
+ <features>
+ <ps2 state='off'/>
+ </features>
+ <cpu mode='custom' match='exact' check='none'>
+ <model fallback='forbid'>qemu64</model>
+ </cpu>
+ <clock offset='utc'/>
+ <on_poweroff>destroy</on_poweroff>
+ <on_reboot>restart</on_reboot>
+ <on_crash>destroy</on_crash>
+ <devices>
+ <emulator>/usr/bin/qemu-system-x86_64</emulator>
+ <controller type='usb' index='0' model='none'/>
+ <controller type='sata' index='0'>
+ <address type='pci' domain='0x0000' bus='0x00'
slot='0x1f' function='0x2'/>
+ </controller>
+ <controller type='pci' index='0' model='pcie-root'/>
+ <audio id='1' type='none'/>
+ <watchdog model='itco' action='reset'/>
+ <memballoon model='none'/>
+ </devices>
+</domain>
diff --git a/tests/qemuxmlconfdata/machine-i8042-off.xml
b/tests/qemuxmlconfdata/machine-i8042-off.xml
new file mode 100644
index 0000000000..ed03aeb2b8
--- /dev/null
+++ b/tests/qemuxmlconfdata/machine-i8042-off.xml
@@ -0,0 +1,17 @@
+<domain type='qemu'>
+ <name>QEMUGuest1</name>
+ <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
+ <memory unit='KiB'>219100</memory>
+ <vcpu placement='static'>1</vcpu>
+ <os>
+ <type arch='x86_64' machine='q35'>hvm</type>
+ </os>
+ <features>
+ <ps2 state='off'/>
+ </features>
+ <devices>
+ <emulator>/usr/bin/qemu-system-x86_64</emulator>
+ <controller type='usb' model='none'/>
+ <memballoon model='none'/>
+ </devices>
+</domain>
diff --git a/tests/qemuxmlconfdata/machine-i8042-on.x86_64-6.2.0.err
b/tests/qemuxmlconfdata/machine-i8042-on.x86_64-6.2.0.err
new file mode 100644
index 0000000000..3a12712915
--- /dev/null
+++ b/tests/qemuxmlconfdata/machine-i8042-on.x86_64-6.2.0.err
@@ -0,0 +1 @@
+unsupported configuration: ps2 feature state cannot be controlled with this QEMU binary
diff --git a/tests/qemuxmlconfdata/machine-i8042-on.x86_64-latest.args
b/tests/qemuxmlconfdata/machine-i8042-on.x86_64-latest.args
new file mode 100644
index 0000000000..cda5002fec
--- /dev/null
+++ b/tests/qemuxmlconfdata/machine-i8042-on.x86_64-latest.args
@@ -0,0 +1,33 @@
+LC_ALL=C \
+PATH=/bin \
+HOME=/var/lib/libvirt/qemu/domain--1-QEMUGuest1 \
+USER=test \
+LOGNAME=test \
+XDG_DATA_HOME=/var/lib/libvirt/qemu/domain--1-QEMUGuest1/.local/share \
+XDG_CACHE_HOME=/var/lib/libvirt/qemu/domain--1-QEMUGuest1/.cache \
+XDG_CONFIG_HOME=/var/lib/libvirt/qemu/domain--1-QEMUGuest1/.config \
+/usr/bin/qemu-system-x86_64 \
+-name guest=QEMUGuest1,debug-threads=on \
+-S \
+-object
'{"qom-type":"secret","id":"masterKey0","format":"raw","file":"/var/lib/libvirt/qemu/domain--1-QEMUGuest1/master-key.aes"}'
\
+-machine q35,usb=off,i8042=on,dump-guest-core=off,memory-backend=pc.ram,acpi=off \
+-accel tcg \
+-cpu qemu64 \
+-m size=219136k \
+-object
'{"qom-type":"memory-backend-ram","id":"pc.ram","size":224395264}'
\
+-overcommit mem-lock=off \
+-smp 1,sockets=1,cores=1,threads=1 \
+-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \
+-display none \
+-no-user-config \
+-nodefaults \
+-chardev socket,id=charmonitor,fd=1729,server=on,wait=off \
+-mon chardev=charmonitor,id=monitor,mode=control \
+-rtc base=utc \
+-no-shutdown \
+-boot strict=on \
+-audiodev
'{"id":"audio1","driver":"none"}' \
+-global ICH9-LPC.noreboot=off \
+-watchdog-action reset \
+-sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,resourcecontrol=deny \
+-msg timestamp=on
diff --git a/tests/qemuxmlconfdata/machine-i8042-on.x86_64-latest.xml
b/tests/qemuxmlconfdata/machine-i8042-on.x86_64-latest.xml
new file mode 100644
index 0000000000..5d08dd9fb8
--- /dev/null
+++ b/tests/qemuxmlconfdata/machine-i8042-on.x86_64-latest.xml
@@ -0,0 +1,34 @@
+<domain type='qemu'>
+ <name>QEMUGuest1</name>
+ <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
+ <memory unit='KiB'>219100</memory>
+ <currentMemory unit='KiB'>219100</currentMemory>
+ <vcpu placement='static'>1</vcpu>
+ <os>
+ <type arch='x86_64' machine='q35'>hvm</type>
+ <boot dev='hd'/>
+ </os>
+ <features>
+ <ps2 state='on'/>
+ </features>
+ <cpu mode='custom' match='exact' check='none'>
+ <model fallback='forbid'>qemu64</model>
+ </cpu>
+ <clock offset='utc'/>
+ <on_poweroff>destroy</on_poweroff>
+ <on_reboot>restart</on_reboot>
+ <on_crash>destroy</on_crash>
+ <devices>
+ <emulator>/usr/bin/qemu-system-x86_64</emulator>
+ <controller type='usb' index='0' model='none'/>
+ <controller type='sata' index='0'>
+ <address type='pci' domain='0x0000' bus='0x00'
slot='0x1f' function='0x2'/>
+ </controller>
+ <controller type='pci' index='0' model='pcie-root'/>
+ <input type='mouse' bus='ps2'/>
+ <input type='keyboard' bus='ps2'/>
+ <audio id='1' type='none'/>
+ <watchdog model='itco' action='reset'/>
+ <memballoon model='none'/>
+ </devices>
+</domain>
diff --git a/tests/qemuxmlconfdata/machine-i8042-on.xml
b/tests/qemuxmlconfdata/machine-i8042-on.xml
new file mode 100644
index 0000000000..669451e2e1
--- /dev/null
+++ b/tests/qemuxmlconfdata/machine-i8042-on.xml
@@ -0,0 +1,17 @@
+<domain type='qemu'>
+ <name>QEMUGuest1</name>
+ <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
+ <memory unit='KiB'>219100</memory>
+ <vcpu placement='static'>1</vcpu>
+ <os>
+ <type arch='x86_64' machine='q35'>hvm</type>
+ </os>
+ <features>
+ <ps2 state='on'/>
+ </features>
+ <devices>
+ <emulator>/usr/bin/qemu-system-x86_64</emulator>
+ <controller type='usb' model='none'/>
+ <memballoon model='none'/>
+ </devices>
+</domain>
diff --git a/tests/qemuxmlconftest.c b/tests/qemuxmlconftest.c
index 89292af300..961d3d688a 100644
--- a/tests/qemuxmlconftest.c
+++ b/tests/qemuxmlconftest.c
@@ -1304,6 +1304,12 @@ mymain(void)
DO_TEST_CAPS_LATEST("machine-smm-on");
DO_TEST_CAPS_LATEST("machine-smm-off");
DO_TEST_CAPS_LATEST("machine-vmport-opt");
+ DO_TEST_CAPS_LATEST("machine-i8042-on");
+ DO_TEST_CAPS_VER_PARSE_ERROR("machine-i8042-on", "6.2.0");
+ DO_TEST_CAPS_LATEST("machine-i8042-off");
+ DO_TEST_CAPS_VER_PARSE_ERROR("machine-i8042-off", "6.2.0");
+ DO_TEST_CAPS_LATEST_PARSE_ERROR("machine-i8042-off-vmport-on");
+ DO_TEST_CAPS_LATEST_PARSE_ERROR("machine-i8042-off-explicit-ps2-inputs");
DO_TEST_CAPS_LATEST("default-kvm-host-arch");
DO_TEST_CAPS_LATEST("default-qemu-host-arch");
DO_TEST_CAPS_LATEST("x86-kvm-32-on-64");
--
2.45.0