]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
qemu: Update qemuDomainSupportsPCI()
authorAndrea Bolognani <abologna@redhat.com>
Thu, 10 Jul 2025 14:42:32 +0000 (16:42 +0200)
committerAndrea Bolognani <abologna@redhat.com>
Mon, 6 Oct 2025 09:15:47 +0000 (11:15 +0200)
The sparc architecture doesn't support PCI, and neither do the
isapc and microvm machine types on x86 architectures.

One of the isapc/microvm tests starts failing as a consequence
of this change, which is expected; somewhat surprisingly,
another test for the same machine types goes from an early/hard
failure (PARSE_ERROR) to a late/soft one (FAILURE) instead.
This will be rectified by a later commit.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
src/qemu/qemu_domain.c
tests/qemuxmlconfdata/isapc-pci.x86_64-latest.args [deleted file]
tests/qemuxmlconfdata/isapc-pci.x86_64-latest.err [new file with mode: 0644]
tests/qemuxmlconfdata/microvm-pci.x86_64-latest.args [deleted file]
tests/qemuxmlconfdata/microvm-pci.x86_64-latest.err [new file with mode: 0644]
tests/qemuxmlconfdata/usb-controller-default-isapc.x86_64-latest.xml [moved from tests/qemuxmlconfdata/isapc-pci.x86_64-latest.xml with 86% similarity]
tests/qemuxmlconfdata/usb-controller-default-microvm.x86_64-latest.xml [moved from tests/qemuxmlconfdata/microvm-pci.x86_64-latest.xml with 84% similarity]
tests/qemuxmlconftest.c

index 81a8ca906dd31a37d87be7a99251e4df2b4d7ef9..889e96c3d36b58b7ad1b48141270d583e7a83caf 100644 (file)
@@ -7703,6 +7703,17 @@ qemuDomainSupportsPCI(const virDomainDef *def)
         return false;
     }
 
+    if (ARCH_IS_X86(def->os.arch)) {
+        if (STREQ(def->os.machine, "isapc") ||
+            STREQ(def->os.machine, "microvm")) {
+            return false;
+        }
+        return true;
+    }
+
+    if (def->os.arch == VIR_ARCH_SPARC)
+        return false;
+
     /* On all other architectures, PCI support is assumed to
      * be present */
     return true;
diff --git a/tests/qemuxmlconfdata/isapc-pci.x86_64-latest.args b/tests/qemuxmlconfdata/isapc-pci.x86_64-latest.args
deleted file mode 100644 (file)
index 789b7de..0000000
+++ /dev/null
@@ -1,31 +0,0 @@
-LC_ALL=C \
-PATH=/bin \
-HOME=/var/lib/libvirt/qemu/domain--1-test \
-USER=test \
-LOGNAME=test \
-XDG_DATA_HOME=/var/lib/libvirt/qemu/domain--1-test/.local/share \
-XDG_CACHE_HOME=/var/lib/libvirt/qemu/domain--1-test/.cache \
-XDG_CONFIG_HOME=/var/lib/libvirt/qemu/domain--1-test/.config \
-/usr/bin/qemu-system-x86_64 \
--name guest=test,debug-threads=on \
--S \
--object '{"qom-type":"secret","id":"masterKey0","format":"raw","file":"/var/lib/libvirt/qemu/domain--1-test/master-key.aes"}' \
--machine isapc,usb=off,dump-guest-core=off,memory-backend=pc.ram,acpi=off \
--accel tcg \
--cpu 486 \
--m size=2097152k \
--object '{"qom-type":"memory-backend-ram","id":"pc.ram","size":2147483648}' \
--overcommit mem-lock=off \
--smp 1,sockets=1,cores=1,threads=1 \
--uuid 11dbdcdd-4c3b-482b-8903-9bdb8c0a2774 \
--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/isapc-pci.x86_64-latest.err b/tests/qemuxmlconfdata/isapc-pci.x86_64-latest.err
new file mode 100644 (file)
index 0000000..0a45494
--- /dev/null
@@ -0,0 +1 @@
+unsupported configuration: Machine type 'isapc' does not support PCI
diff --git a/tests/qemuxmlconfdata/microvm-pci.x86_64-latest.args b/tests/qemuxmlconfdata/microvm-pci.x86_64-latest.args
deleted file mode 100644 (file)
index 06598dd..0000000
+++ /dev/null
@@ -1,31 +0,0 @@
-LC_ALL=C \
-PATH=/bin \
-HOME=/var/lib/libvirt/qemu/domain--1-test \
-USER=test \
-LOGNAME=test \
-XDG_DATA_HOME=/var/lib/libvirt/qemu/domain--1-test/.local/share \
-XDG_CACHE_HOME=/var/lib/libvirt/qemu/domain--1-test/.cache \
-XDG_CONFIG_HOME=/var/lib/libvirt/qemu/domain--1-test/.config \
-/usr/bin/qemu-system-x86_64 \
--name guest=test,debug-threads=on \
--S \
--object '{"qom-type":"secret","id":"masterKey0","format":"raw","file":"/var/lib/libvirt/qemu/domain--1-test/master-key.aes"}' \
--machine microvm,usb=off,dump-guest-core=off,memory-backend=microvm.ram,acpi=off \
--accel tcg \
--cpu qemu64 \
--m size=2097152k \
--object '{"qom-type":"memory-backend-ram","id":"microvm.ram","size":2147483648}' \
--overcommit mem-lock=off \
--smp 1,sockets=1,cores=1,threads=1 \
--uuid 11dbdcdd-4c3b-482b-8903-9bdb8c0a2774 \
--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/microvm-pci.x86_64-latest.err b/tests/qemuxmlconfdata/microvm-pci.x86_64-latest.err
new file mode 100644 (file)
index 0000000..6e329d3
--- /dev/null
@@ -0,0 +1 @@
+unsupported configuration: Machine type 'microvm' does not support PCI
similarity index 86%
rename from tests/qemuxmlconfdata/isapc-pci.x86_64-latest.xml
rename to tests/qemuxmlconfdata/usb-controller-default-isapc.x86_64-latest.xml
index a32f3243d5b2affefe91106fde1bbe6cae4ad5a8..c18e2b1b0d601dc7ad8361b131bf47288ca289d7 100644 (file)
@@ -1,5 +1,5 @@
 <domain type='qemu'>
-  <name>test</name>
+  <name>q35-test</name>
   <uuid>11dbdcdd-4c3b-482b-8903-9bdb8c0a2774</uuid>
   <memory unit='KiB'>2097152</memory>
   <currentMemory unit='KiB'>2097152</currentMemory>
   <on_crash>destroy</on_crash>
   <devices>
     <emulator>/usr/bin/qemu-system-x86_64</emulator>
-    <controller type='pci' index='0' model='pci-root'/>
+    <controller type='usb' index='0' model='piix3-uhci'/>
     <input type='mouse' bus='ps2'/>
     <input type='keyboard' bus='ps2'/>
     <audio id='1' type='none'/>
+    <memballoon model='none'/>
   </devices>
 </domain>
similarity index 84%
rename from tests/qemuxmlconfdata/microvm-pci.x86_64-latest.xml
rename to tests/qemuxmlconfdata/usb-controller-default-microvm.x86_64-latest.xml
index 06b5a8b78910d77adb4bd515e4271eccc10bbc96..b8e55a70446f7dada8e354f88d6a0f6051262044 100644 (file)
@@ -1,5 +1,5 @@
 <domain type='qemu'>
-  <name>test</name>
+  <name>q35-test</name>
   <uuid>11dbdcdd-4c3b-482b-8903-9bdb8c0a2774</uuid>
   <memory unit='KiB'>2097152</memory>
   <currentMemory unit='KiB'>2097152</currentMemory>
@@ -17,7 +17,8 @@
   <on_crash>destroy</on_crash>
   <devices>
     <emulator>/usr/bin/qemu-system-x86_64</emulator>
-    <controller type='pci' index='0' model='pci-root'/>
+    <controller type='usb' index='0' model='piix3-uhci'/>
     <audio id='1' type='none'/>
+    <memballoon model='none'/>
   </devices>
 </domain>
index 1ec20805c5ef520402d186576c9446f9179c36e7..91ac3b8a5129613cc6fe3d4a01a53a1642ec620e 100644 (file)
@@ -1423,8 +1423,8 @@ mymain(void)
 
     DO_TEST_CAPS_LATEST_PARSE_ERROR("no-memory");
 
-    DO_TEST_CAPS_LATEST("isapc-pci");
-    DO_TEST_CAPS_LATEST("microvm-pci");
+    DO_TEST_CAPS_LATEST_PARSE_ERROR("isapc-pci");
+    DO_TEST_CAPS_LATEST_PARSE_ERROR("microvm-pci");
 
     DO_TEST_CAPS_LATEST("genid");
     DO_TEST_CAPS_LATEST("genid-auto");
@@ -2118,8 +2118,8 @@ mymain(void)
                  ARG_QEMU_CAPS_DEL, QEMU_CAPS_DEVICE_QEMU_XHCI, QEMU_CAPS_NEC_USB_XHCI, QEMU_CAPS_PCI_OHCI, QEMU_CAPS_LAST,
                  ARG_END);
 
-    DO_TEST_CAPS_LATEST_PARSE_ERROR("usb-controller-default-isapc");
-    DO_TEST_CAPS_LATEST_PARSE_ERROR("usb-controller-default-microvm");
+    DO_TEST_CAPS_LATEST_FAILURE("usb-controller-default-isapc");
+    DO_TEST_CAPS_LATEST_FAILURE("usb-controller-default-microvm");
     DO_TEST_CAPS_LATEST("usb-controller-default-i440fx");
     DO_TEST_CAPS_LATEST("usb-controller-default-q35");
     DO_TEST_CAPS_ARCH_LATEST("usb-controller-default-pseries", "ppc64");