Don't add any default devices and any default USB controller models for
the machine type and add few basic tests.
Signed-off-by: Peter Krempa <pkrempa(a)redhat.com>
---
src/qemu/qemu_command.c | 1 +
src/qemu/qemu_domain.c | 16 ++++++++-
.../microvm.x86_64-latest.args | 34 +++++++++++++++++++
.../qemuxmlconfdata/microvm.x86_64-latest.xml | 29 ++++++++++++++++
tests/qemuxmlconfdata/microvm.xml | 20 +++++++++++
...troller-implicit-microvm.x86_64-latest.err | 1 +
...troller-implicit-microvm.x86_64-latest.xml | 25 ++++++++++++++
.../usb-controller-implicit-microvm.xml | 17 ++++++++++
...rovm-minimal.x86_64-latest.abi-update.args | 31 +++++++++++++++++
...crovm-minimal.x86_64-latest.abi-update.xml | 23 +++++++++++++
.../x86_64-microvm-minimal.x86_64-latest.args | 31 +++++++++++++++++
.../x86_64-microvm-minimal.x86_64-latest.xml | 23 +++++++++++++
.../x86_64-microvm-minimal.xml | 14 ++++++++
tests/qemuxmlconftest.c | 4 +++
14 files changed, 268 insertions(+), 1 deletion(-)
create mode 100644 tests/qemuxmlconfdata/microvm.x86_64-latest.args
create mode 100644 tests/qemuxmlconfdata/microvm.x86_64-latest.xml
create mode 100644 tests/qemuxmlconfdata/microvm.xml
create mode 100644
tests/qemuxmlconfdata/usb-controller-implicit-microvm.x86_64-latest.err
create mode 100644
tests/qemuxmlconfdata/usb-controller-implicit-microvm.x86_64-latest.xml
create mode 100644 tests/qemuxmlconfdata/usb-controller-implicit-microvm.xml
create mode 100644
tests/qemuxmlconfdata/x86_64-microvm-minimal.x86_64-latest.abi-update.args
create mode 100644
tests/qemuxmlconfdata/x86_64-microvm-minimal.x86_64-latest.abi-update.xml
create mode 100644 tests/qemuxmlconfdata/x86_64-microvm-minimal.x86_64-latest.args
create mode 100644 tests/qemuxmlconfdata/x86_64-microvm-minimal.x86_64-latest.xml
create mode 100644 tests/qemuxmlconfdata/x86_64-microvm-minimal.xml
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 2719574fb5..d0fa31a506 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -2923,6 +2923,7 @@ static bool
qemuBuildDomainForbidLegacyUSBController(const virDomainDef *def)
{
if (qemuDomainIsQ35(def) ||
+ qemuDomainIsMicrovm(def) ||
qemuDomainIsARMVirt(def) ||
qemuDomainIsRISCVVirt(def))
return true;
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index 25cb650c07..aa58af8c22 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -3911,7 +3911,8 @@ virXMLNamespace virQEMUDriverDomainXMLNamespace = {
static int
qemuDomainDefAddImplicitInputDevice(virDomainDef *def)
{
- if (ARCH_IS_X86(def->os.arch)) {
+ if (ARCH_IS_X86(def->os.arch) &&
+ !qemuDomainIsMicrovm(def)) {
if (virDomainDefMaybeAddInput(def,
VIR_DOMAIN_INPUT_TYPE_MOUSE,
VIR_DOMAIN_INPUT_BUS_PS2) < 0)
@@ -4157,6 +4158,14 @@ qemuDomainDefAddDefaultDevices(virQEMUDriver *driver,
switch (def->os.arch) {
case VIR_ARCH_I686:
case VIR_ARCH_X86_64:
+ /* don't add anything for microvm */
+ if (qemuDomainIsMicrovm(def)) {
+ /* explicitly add 'none' USB controller */
+ usbModel = VIR_DOMAIN_CONTROLLER_MODEL_USB_NONE;
+ addDefaultUSB = true;
+ break;
+ }
+
addDefaultMemballoon = true;
if (STREQ(def->os.machine, "isapc")) {
@@ -5665,6 +5674,11 @@ qemuDomainControllerDefPostParse(virDomainControllerDef *cont,
cont->model = VIR_DOMAIN_CONTROLLER_MODEL_USB_QEMU_XHCI;
else if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_NEC_USB_XHCI))
cont->model = VIR_DOMAIN_CONTROLLER_MODEL_USB_NEC_XHCI;
+ } else if (ARCH_IS_X86(def->os.arch)) {
+ if (qemuDomainIsMicrovm(def)) {
+ /* do not select any automatic model for 'microvm' machines
*/
+ cont->model = -1;
+ }
}
}
/* forbid usb model 'qusb1' and 'qusb2' in this kind of
hyperviosr */
diff --git a/tests/qemuxmlconfdata/microvm.x86_64-latest.args
b/tests/qemuxmlconfdata/microvm.x86_64-latest.args
new file mode 100644
index 0000000000..a2ee9ce3a4
--- /dev/null
+++ b/tests/qemuxmlconfdata/microvm.x86_64-latest.args
@@ -0,0 +1,34 @@
+LC_ALL=C \
+PATH=/bin \
+HOME=/var/lib/libvirt/qemu/domain--1-microvm \
+USER=test \
+LOGNAME=test \
+XDG_DATA_HOME=/var/lib/libvirt/qemu/domain--1-microvm/.local/share \
+XDG_CACHE_HOME=/var/lib/libvirt/qemu/domain--1-microvm/.cache \
+XDG_CONFIG_HOME=/var/lib/libvirt/qemu/domain--1-microvm/.config \
+/usr/bin/qemu-system-x86_64 \
+-name guest=microvm,debug-threads=on \
+-S \
+-object
'{"qom-type":"secret","id":"masterKey0","format":"raw","file":"/var/lib/libvirt/qemu/domain--1-microvm/master-key.aes"}'
\
+-machine microvm,usb=off,dump-guest-core=off,memory-backend=microvm.ram,acpi=off \
+-accel kvm \
+-cpu qemu64 \
+-m size=1024000k \
+-object
'{"qom-type":"memory-backend-ram","id":"microvm.ram","size":1048576000}'
\
+-overcommit mem-lock=off \
+-smp 1,sockets=1,cores=1,threads=1 \
+-uuid e739ac15-61b5-48c2-acc8-e7fb2b79774f \
+-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 \
+-blockdev
'{"driver":"file","filename":"/var/lib/libvirt/images/microvm.qcow2","node-name":"libvirt-1-storage","auto-read-only":true,"discard":"unmap"}'
\
+-blockdev
'{"node-name":"libvirt-1-format","read-only":false,"driver":"qcow2","file":"libvirt-1-storage"}'
\
+-device
'{"driver":"virtio-blk-device","drive":"libvirt-1-format","id":"virtio-disk0","bootindex":1}'
\
+-audiodev
'{"id":"audio1","driver":"none"}' \
+-sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,resourcecontrol=deny \
+-msg timestamp=on
diff --git a/tests/qemuxmlconfdata/microvm.x86_64-latest.xml
b/tests/qemuxmlconfdata/microvm.x86_64-latest.xml
new file mode 100644
index 0000000000..24a4eccf83
--- /dev/null
+++ b/tests/qemuxmlconfdata/microvm.x86_64-latest.xml
@@ -0,0 +1,29 @@
+<domain type='kvm'>
+ <name>microvm</name>
+ <uuid>e739ac15-61b5-48c2-acc8-e7fb2b79774f</uuid>
+ <memory unit='KiB'>1024000</memory>
+ <currentMemory unit='KiB'>1024000</currentMemory>
+ <vcpu placement='static'>1</vcpu>
+ <os>
+ <type arch='x86_64' machine='microvm'>hvm</type>
+ <boot dev='hd'/>
+ </os>
+ <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>
+ <disk type='file' device='disk'>
+ <driver name='qemu' type='qcow2'/>
+ <source file='/var/lib/libvirt/images/microvm.qcow2'/>
+ <target dev='vda' bus='virtio'/>
+ <address type='virtio-mmio'/>
+ </disk>
+ <controller type='usb' index='0' model='none'/>
+ <audio id='1' type='none'/>
+ </devices>
+</domain>
diff --git a/tests/qemuxmlconfdata/microvm.xml b/tests/qemuxmlconfdata/microvm.xml
new file mode 100644
index 0000000000..4aa576b0bc
--- /dev/null
+++ b/tests/qemuxmlconfdata/microvm.xml
@@ -0,0 +1,20 @@
+<domain type='kvm'>
+ <name>microvm</name>
+ <uuid>e739ac15-61b5-48c2-acc8-e7fb2b79774f</uuid>
+ <memory unit='KiB'>1024000</memory>
+ <currentMemory unit='KiB'>1024000</currentMemory>
+ <vcpu placement='static'>1</vcpu>
+ <os>
+ <type arch='x86_64' machine='microvm'>hvm</type>
+ <boot dev='hd'/>
+ </os>
+ <devices>
+ <emulator>/usr/bin/qemu-system-x86_64</emulator>
+ <disk type='file' device='disk'>
+ <driver name='qemu' type='qcow2'/>
+ <source file='/var/lib/libvirt/images/microvm.qcow2'/>
+ <target dev='vda' bus='virtio'/>
+ <address type='virtio-mmio'/>
+ </disk>
+ </devices>
+</domain>
diff --git a/tests/qemuxmlconfdata/usb-controller-implicit-microvm.x86_64-latest.err
b/tests/qemuxmlconfdata/usb-controller-implicit-microvm.x86_64-latest.err
new file mode 100644
index 0000000000..7a71aa107d
--- /dev/null
+++ b/tests/qemuxmlconfdata/usb-controller-implicit-microvm.x86_64-latest.err
@@ -0,0 +1 @@
+unsupported configuration: no model provided for USB controller
diff --git a/tests/qemuxmlconfdata/usb-controller-implicit-microvm.x86_64-latest.xml
b/tests/qemuxmlconfdata/usb-controller-implicit-microvm.x86_64-latest.xml
new file mode 100644
index 0000000000..50b3c1e908
--- /dev/null
+++ b/tests/qemuxmlconfdata/usb-controller-implicit-microvm.x86_64-latest.xml
@@ -0,0 +1,25 @@
+<domain type='kvm'>
+ <name>microvm</name>
+ <uuid>e739ac15-61b5-48c2-acc8-e7fb2b79774f</uuid>
+ <memory unit='KiB'>1024000</memory>
+ <currentMemory unit='KiB'>1024000</currentMemory>
+ <vcpu placement='static'>1</vcpu>
+ <os>
+ <type arch='x86_64' machine='microvm'>hvm</type>
+ <boot dev='hd'/>
+ </os>
+ <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'>
+ <address type='virtio-mmio'/>
+ </controller>
+ <audio id='1' type='none'/>
+ </devices>
+</domain>
diff --git a/tests/qemuxmlconfdata/usb-controller-implicit-microvm.xml
b/tests/qemuxmlconfdata/usb-controller-implicit-microvm.xml
new file mode 100644
index 0000000000..f4c28e0f79
--- /dev/null
+++ b/tests/qemuxmlconfdata/usb-controller-implicit-microvm.xml
@@ -0,0 +1,17 @@
+<domain type='kvm'>
+ <name>microvm</name>
+ <uuid>e739ac15-61b5-48c2-acc8-e7fb2b79774f</uuid>
+ <memory unit='KiB'>1024000</memory>
+ <currentMemory unit='KiB'>1024000</currentMemory>
+ <vcpu placement='static'>1</vcpu>
+ <os>
+ <type arch='x86_64' machine='microvm'>hvm</type>
+ <boot dev='hd'/>
+ </os>
+ <devices>
+ <emulator>/usr/bin/qemu-system-x86_64</emulator>
+ <controller type='usb' index='0'>
+ <address type='virtio-mmio'/>
+ </controller>
+ </devices>
+</domain>
diff --git a/tests/qemuxmlconfdata/x86_64-microvm-minimal.x86_64-latest.abi-update.args
b/tests/qemuxmlconfdata/x86_64-microvm-minimal.x86_64-latest.abi-update.args
new file mode 100644
index 0000000000..12e8302a85
--- /dev/null
+++ b/tests/qemuxmlconfdata/x86_64-microvm-minimal.x86_64-latest.abi-update.args
@@ -0,0 +1,31 @@
+LC_ALL=C \
+PATH=/bin \
+HOME=/var/lib/libvirt/qemu/domain--1-microvm \
+USER=test \
+LOGNAME=test \
+XDG_DATA_HOME=/var/lib/libvirt/qemu/domain--1-microvm/.local/share \
+XDG_CACHE_HOME=/var/lib/libvirt/qemu/domain--1-microvm/.cache \
+XDG_CONFIG_HOME=/var/lib/libvirt/qemu/domain--1-microvm/.config \
+/usr/bin/qemu-system-x86_64 \
+-name guest=microvm,debug-threads=on \
+-S \
+-object
'{"qom-type":"secret","id":"masterKey0","format":"raw","file":"/var/lib/libvirt/qemu/domain--1-microvm/master-key.aes"}'
\
+-machine microvm,usb=off,dump-guest-core=off,memory-backend=microvm.ram,acpi=off \
+-accel kvm \
+-cpu qemu64 \
+-m size=1024000k \
+-object
'{"qom-type":"memory-backend-ram","id":"microvm.ram","size":1048576000}'
\
+-overcommit mem-lock=off \
+-smp 1,sockets=1,cores=1,threads=1 \
+-uuid e739ac15-61b5-48c2-acc8-e7fb2b79774f \
+-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"}' \
+-sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,resourcecontrol=deny \
+-msg timestamp=on
diff --git a/tests/qemuxmlconfdata/x86_64-microvm-minimal.x86_64-latest.abi-update.xml
b/tests/qemuxmlconfdata/x86_64-microvm-minimal.x86_64-latest.abi-update.xml
new file mode 100644
index 0000000000..287eb3f58e
--- /dev/null
+++ b/tests/qemuxmlconfdata/x86_64-microvm-minimal.x86_64-latest.abi-update.xml
@@ -0,0 +1,23 @@
+<domain type='kvm'>
+ <name>microvm</name>
+ <uuid>e739ac15-61b5-48c2-acc8-e7fb2b79774f</uuid>
+ <memory unit='KiB'>1024000</memory>
+ <currentMemory unit='KiB'>1024000</currentMemory>
+ <vcpu placement='static'>1</vcpu>
+ <os>
+ <type arch='x86_64' machine='microvm'>hvm</type>
+ <boot dev='hd'/>
+ </os>
+ <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'/>
+ <audio id='1' type='none'/>
+ </devices>
+</domain>
diff --git a/tests/qemuxmlconfdata/x86_64-microvm-minimal.x86_64-latest.args
b/tests/qemuxmlconfdata/x86_64-microvm-minimal.x86_64-latest.args
new file mode 100644
index 0000000000..12e8302a85
--- /dev/null
+++ b/tests/qemuxmlconfdata/x86_64-microvm-minimal.x86_64-latest.args
@@ -0,0 +1,31 @@
+LC_ALL=C \
+PATH=/bin \
+HOME=/var/lib/libvirt/qemu/domain--1-microvm \
+USER=test \
+LOGNAME=test \
+XDG_DATA_HOME=/var/lib/libvirt/qemu/domain--1-microvm/.local/share \
+XDG_CACHE_HOME=/var/lib/libvirt/qemu/domain--1-microvm/.cache \
+XDG_CONFIG_HOME=/var/lib/libvirt/qemu/domain--1-microvm/.config \
+/usr/bin/qemu-system-x86_64 \
+-name guest=microvm,debug-threads=on \
+-S \
+-object
'{"qom-type":"secret","id":"masterKey0","format":"raw","file":"/var/lib/libvirt/qemu/domain--1-microvm/master-key.aes"}'
\
+-machine microvm,usb=off,dump-guest-core=off,memory-backend=microvm.ram,acpi=off \
+-accel kvm \
+-cpu qemu64 \
+-m size=1024000k \
+-object
'{"qom-type":"memory-backend-ram","id":"microvm.ram","size":1048576000}'
\
+-overcommit mem-lock=off \
+-smp 1,sockets=1,cores=1,threads=1 \
+-uuid e739ac15-61b5-48c2-acc8-e7fb2b79774f \
+-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"}' \
+-sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,resourcecontrol=deny \
+-msg timestamp=on
diff --git a/tests/qemuxmlconfdata/x86_64-microvm-minimal.x86_64-latest.xml
b/tests/qemuxmlconfdata/x86_64-microvm-minimal.x86_64-latest.xml
new file mode 100644
index 0000000000..287eb3f58e
--- /dev/null
+++ b/tests/qemuxmlconfdata/x86_64-microvm-minimal.x86_64-latest.xml
@@ -0,0 +1,23 @@
+<domain type='kvm'>
+ <name>microvm</name>
+ <uuid>e739ac15-61b5-48c2-acc8-e7fb2b79774f</uuid>
+ <memory unit='KiB'>1024000</memory>
+ <currentMemory unit='KiB'>1024000</currentMemory>
+ <vcpu placement='static'>1</vcpu>
+ <os>
+ <type arch='x86_64' machine='microvm'>hvm</type>
+ <boot dev='hd'/>
+ </os>
+ <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'/>
+ <audio id='1' type='none'/>
+ </devices>
+</domain>
diff --git a/tests/qemuxmlconfdata/x86_64-microvm-minimal.xml
b/tests/qemuxmlconfdata/x86_64-microvm-minimal.xml
new file mode 100644
index 0000000000..f0d8e54494
--- /dev/null
+++ b/tests/qemuxmlconfdata/x86_64-microvm-minimal.xml
@@ -0,0 +1,14 @@
+<domain type='kvm'>
+ <name>microvm</name>
+ <uuid>e739ac15-61b5-48c2-acc8-e7fb2b79774f</uuid>
+ <memory unit='KiB'>1024000</memory>
+ <currentMemory unit='KiB'>1024000</currentMemory>
+ <vcpu placement='static'>1</vcpu>
+ <os>
+ <type arch='x86_64' machine='microvm'>hvm</type>
+ <boot dev='hd'/>
+ </os>
+ <devices>
+ <emulator>/usr/bin/qemu-system-x86_64</emulator>
+ </devices>
+</domain>
diff --git a/tests/qemuxmlconftest.c b/tests/qemuxmlconftest.c
index 03453e8ec8..33f185dbc9 100644
--- a/tests/qemuxmlconftest.c
+++ b/tests/qemuxmlconftest.c
@@ -1238,6 +1238,8 @@ mymain(void)
DO_TEST_CAPS_LATEST_ABI_UPDATE("x86_64-pc-minimal");
DO_TEST_CAPS_LATEST("x86_64-q35-minimal");
DO_TEST_CAPS_LATEST_ABI_UPDATE("x86_64-q35-minimal");
+ DO_TEST_CAPS_LATEST("x86_64-microvm-minimal");
+ DO_TEST_CAPS_LATEST_ABI_UPDATE("x86_64-microvm-minimal");
DO_TEST_CAPS_ARCH_LATEST("aarch64-virt-minimal", "aarch64");
DO_TEST_CAPS_ARCH_LATEST_ABI_UPDATE("aarch64-virt-minimal",
"aarch64");
DO_TEST_CAPS_ARCH_LATEST("riscv64-virt-minimal", "riscv64");
@@ -1839,6 +1841,7 @@ mymain(void)
DO_TEST_CAPS_LATEST("usb-controller-implicit-isapc");
DO_TEST_CAPS_LATEST("usb-controller-implicit-i440fx");
DO_TEST_CAPS_LATEST("usb-controller-implicit-q35");
+ DO_TEST_CAPS_LATEST_FAILURE("usb-controller-implicit-microvm");
DO_TEST_CAPS_LATEST_PARSE_ERROR("usb-controller-default-isapc");
DO_TEST_CAPS_LATEST("usb-controller-default-i440fx");
DO_TEST_CAPS_LATEST("usb-controller-default-q35");
@@ -2365,6 +2368,7 @@ mymain(void)
DO_TEST_CAPS_LATEST("pci-bridge-many-disks");
DO_TEST_CAPS_LATEST("pcie-root");
DO_TEST_CAPS_LATEST("q35");
+ DO_TEST_CAPS_LATEST("microvm");
DO_TEST_CAPS_LATEST_PARSE_ERROR("q35-dmi-bad-address1");
DO_TEST_CAPS_LATEST_PARSE_ERROR("q35-dmi-bad-address2");
DO_TEST_CAPS_LATEST("pc-i440fx-acpi-root-hotplug-disable");
--
2.43.0