]> xenbits.xensource.com Git - libvirt.git/commitdiff
qemuxmlconftest: Add test cases for the new 'ps2' feature
authorKamil Szczęk <kamil@szczek.dev>
Mon, 19 Aug 2024 01:19:55 +0000 (01:19 +0000)
committerMichal Privoznik <mprivozn@redhat.com>
Wed, 21 Aug 2024 15:10:51 +0000 (17:10 +0200)
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@szczek.dev>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
13 files changed:
tests/qemuxmlconfdata/machine-i8042-off-explicit-ps2-inputs.x86_64-latest.err [new file with mode: 0644]
tests/qemuxmlconfdata/machine-i8042-off-explicit-ps2-inputs.xml [new file with mode: 0644]
tests/qemuxmlconfdata/machine-i8042-off-vmport-on.x86_64-latest.err [new file with mode: 0644]
tests/qemuxmlconfdata/machine-i8042-off-vmport-on.xml [new file with mode: 0644]
tests/qemuxmlconfdata/machine-i8042-off.x86_64-6.2.0.err [new file with mode: 0644]
tests/qemuxmlconfdata/machine-i8042-off.x86_64-latest.args [new file with mode: 0644]
tests/qemuxmlconfdata/machine-i8042-off.x86_64-latest.xml [new file with mode: 0644]
tests/qemuxmlconfdata/machine-i8042-off.xml [new file with mode: 0644]
tests/qemuxmlconfdata/machine-i8042-on.x86_64-6.2.0.err [new file with mode: 0644]
tests/qemuxmlconfdata/machine-i8042-on.x86_64-latest.args [new file with mode: 0644]
tests/qemuxmlconfdata/machine-i8042-on.x86_64-latest.xml [new file with mode: 0644]
tests/qemuxmlconfdata/machine-i8042-on.xml [new file with mode: 0644]
tests/qemuxmlconftest.c

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 (file)
index 0000000..4fed60a
--- /dev/null
@@ -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 (file)
index 0000000..f906776
--- /dev/null
@@ -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 (file)
index 0000000..0c3b728
--- /dev/null
@@ -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 (file)
index 0000000..957da05
--- /dev/null
@@ -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 (file)
index 0000000..3a12712
--- /dev/null
@@ -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 (file)
index 0000000..e340d16
--- /dev/null
@@ -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 (file)
index 0000000..b5c503e
--- /dev/null
@@ -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 (file)
index 0000000..ed03aeb
--- /dev/null
@@ -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 (file)
index 0000000..3a12712
--- /dev/null
@@ -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 (file)
index 0000000..cda5002
--- /dev/null
@@ -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 (file)
index 0000000..5d08dd9
--- /dev/null
@@ -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 (file)
index 0000000..669451e
--- /dev/null
@@ -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>
index 436d58b977da6127d26f737da405ad9bd64e7992..f7c0cf4ad0c932f9bcf89f9504b2ab293fe77eb2 100644 (file)
@@ -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");