]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
qemu: Fix PCI/USB handling for Arm realview boards
authorAndrea Bolognani <abologna@redhat.com>
Tue, 8 Jul 2025 20:27:02 +0000 (22:27 +0200)
committerAndrea Bolognani <abologna@redhat.com>
Mon, 6 Oct 2025 09:15:31 +0000 (11:15 +0200)
Only the -eb variants of the realview board support PCI
devices, so those are the only ones that should automatically
get a USB controller (addDefaultUSB). libvirt will currently
add one for the other realview variants too, but that will
result in QEMU reporting an error due to lack of PCI support
as soon as the domain is started.

Additionally, they should get a PCI controller added
automatically (addPCIRoot) too, same as versatilepb.

Finally, qemuDomainSupportsPCI() should correctly report the
fact that these machine types support PCI.

As a consequence of these fixes, the USB controllers now
correctly get assigned PCI addresses across the board.

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>
14 files changed:
src/qemu/qemu_domain.c
src/qemu/qemu_postparse.c
tests/qemuxmlconfdata/aarch64-realview-minimal.aarch64-latest.abi-update.args
tests/qemuxmlconfdata/aarch64-realview-minimal.aarch64-latest.abi-update.xml
tests/qemuxmlconfdata/aarch64-realview-minimal.aarch64-latest.args
tests/qemuxmlconfdata/aarch64-realview-minimal.aarch64-latest.xml
tests/qemuxmlconfdata/usb-controller-automatic-realview.aarch64-latest.args
tests/qemuxmlconfdata/usb-controller-automatic-realview.aarch64-latest.xml
tests/qemuxmlconfdata/usb-controller-automatic-unavailable-realview.aarch64-latest.xml
tests/qemuxmlconfdata/usb-controller-default-fallback-realview.aarch64-latest.args
tests/qemuxmlconfdata/usb-controller-default-fallback-realview.aarch64-latest.xml
tests/qemuxmlconfdata/usb-controller-default-realview.aarch64-latest.args
tests/qemuxmlconfdata/usb-controller-default-realview.aarch64-latest.xml
tests/qemuxmlconfdata/usb-controller-default-unavailable-realview.aarch64-latest.xml

index e45757ccd50630fe61ca25ef10b7b77b48f2b3c0..81a8ca906dd31a37d87be7a99251e4df2b4d7ef9 100644 (file)
@@ -7688,7 +7688,8 @@ qemuDomainSupportsPCI(const virDomainDef *def)
      * machine types support PCI */
     if (ARCH_IS_ARM(def->os.arch)) {
         if (qemuDomainIsARMVirt(def) ||
-            STREQ(def->os.machine, "versatilepb")) {
+            STREQ(def->os.machine, "versatilepb") ||
+            STRPREFIX(def->os.machine, "realview-eb")) {
             return true;
         }
         return false;
index 5f59b79d56c519c29c69cd213209a43bcebbbc95..3c481ead5ec3c29e9f0ccb0acca71d71316dca76 100644 (file)
@@ -1291,13 +1291,11 @@ qemuDomainDefAddDefaultDevices(virQEMUDriver *driver,
     case VIR_ARCH_ARMV7L:
     case VIR_ARCH_ARMV7B:
     case VIR_ARCH_AARCH64:
-        if (STREQ(def->os.machine, "versatilepb"))
-            addPCIRoot = true;
-
-        /* Add default USB for the two machine types which historically
-         * supported -usb */
+        /* Add default PCI and USB for the two machine types which
+         * historically supported -usb */
         if (STREQ(def->os.machine, "versatilepb") ||
-            STRPREFIX(def->os.machine, "realview")) {
+            STRPREFIX(def->os.machine, "realview-eb")) {
+            addPCIRoot = true;
             addDefaultUSB = true;
             if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_PCI_OHCI))
                 usbModel = VIR_DOMAIN_CONTROLLER_MODEL_USB_PCI_OHCI;
index fc88d9cf6b9173d2e1c5e87d418503548496ebf6..0d956241fceada77bdee50eaf844b2af7fe9404e 100644 (file)
@@ -25,7 +25,7 @@ XDG_CONFIG_HOME=/var/lib/libvirt/qemu/domain--1-aarch64test/.config \
 -rtc base=utc \
 -no-shutdown \
 -boot strict=on \
--device '{"driver":"pci-ohci","id":"usb"}' \
+-device '{"driver":"pci-ohci","id":"usb","bus":"pci","addr":"0x1"}' \
 -audiodev '{"id":"audio1","driver":"none"}' \
 -sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,resourcecontrol=deny \
 -msg timestamp=on
index b16454b94cdcabf195e0706be0965b0650796624..c31c7b2bbc806d6da35dad0bca17d530b08a2ae0 100644 (file)
   <on_crash>destroy</on_crash>
   <devices>
     <emulator>/usr/bin/qemu-system-aarch64</emulator>
-    <controller type='usb' index='0' model='pci-ohci'/>
+    <controller type='usb' index='0' model='pci-ohci'>
+      <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x0'/>
+    </controller>
+    <controller type='pci' index='0' model='pci-root'/>
     <audio id='1' type='none'/>
   </devices>
 </domain>
index fc88d9cf6b9173d2e1c5e87d418503548496ebf6..0d956241fceada77bdee50eaf844b2af7fe9404e 100644 (file)
@@ -25,7 +25,7 @@ XDG_CONFIG_HOME=/var/lib/libvirt/qemu/domain--1-aarch64test/.config \
 -rtc base=utc \
 -no-shutdown \
 -boot strict=on \
--device '{"driver":"pci-ohci","id":"usb"}' \
+-device '{"driver":"pci-ohci","id":"usb","bus":"pci","addr":"0x1"}' \
 -audiodev '{"id":"audio1","driver":"none"}' \
 -sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,resourcecontrol=deny \
 -msg timestamp=on
index b16454b94cdcabf195e0706be0965b0650796624..c31c7b2bbc806d6da35dad0bca17d530b08a2ae0 100644 (file)
   <on_crash>destroy</on_crash>
   <devices>
     <emulator>/usr/bin/qemu-system-aarch64</emulator>
-    <controller type='usb' index='0' model='pci-ohci'/>
+    <controller type='usb' index='0' model='pci-ohci'>
+      <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x0'/>
+    </controller>
+    <controller type='pci' index='0' model='pci-root'/>
     <audio id='1' type='none'/>
   </devices>
 </domain>
index fc88d9cf6b9173d2e1c5e87d418503548496ebf6..0d956241fceada77bdee50eaf844b2af7fe9404e 100644 (file)
@@ -25,7 +25,7 @@ XDG_CONFIG_HOME=/var/lib/libvirt/qemu/domain--1-aarch64test/.config \
 -rtc base=utc \
 -no-shutdown \
 -boot strict=on \
--device '{"driver":"pci-ohci","id":"usb"}' \
+-device '{"driver":"pci-ohci","id":"usb","bus":"pci","addr":"0x1"}' \
 -audiodev '{"id":"audio1","driver":"none"}' \
 -sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,resourcecontrol=deny \
 -msg timestamp=on
index dc32fd50cdbd9f99c60b71b32aeee0bf9f26b8a1..250da1b5e01cd22b10a218be585d08ac572d6ac0 100644 (file)
   <on_crash>destroy</on_crash>
   <devices>
     <emulator>/usr/bin/qemu-system-aarch64</emulator>
-    <controller type='usb' index='0' model='pci-ohci'/>
+    <controller type='usb' index='0' model='pci-ohci'>
+      <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x0'/>
+    </controller>
+    <controller type='pci' index='0' model='pci-root'/>
     <audio id='1' type='none'/>
     <memballoon model='none'/>
   </devices>
index 9da9abaa884bfd5bcf9c804bb8c596918f411210..128a7d420e11f0531b43c38fb848759c71573326 100644 (file)
   <on_crash>destroy</on_crash>
   <devices>
     <emulator>/usr/bin/qemu-system-aarch64</emulator>
-    <controller type='usb' index='0'/>
+    <controller type='usb' index='0'>
+      <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x0'/>
+    </controller>
+    <controller type='pci' index='0' model='pci-root'/>
     <audio id='1' type='none'/>
     <memballoon model='none'/>
   </devices>
index 604c5ec4735c50bc97a621c25239a70aacdbdbb8..ccbff79f3578ddf4696bf8ec0117b6d57617e89b 100644 (file)
@@ -25,7 +25,7 @@ XDG_CONFIG_HOME=/var/lib/libvirt/qemu/domain--1-aarch64test/.config \
 -rtc base=utc \
 -no-shutdown \
 -boot strict=on \
--device '{"driver":"qemu-xhci","id":"usb"}' \
+-device '{"driver":"qemu-xhci","id":"usb","bus":"pci","addr":"0x1"}' \
 -audiodev '{"id":"audio1","driver":"none"}' \
 -sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,resourcecontrol=deny \
 -msg timestamp=on
index f61322ddb5aba118c2f41f12101653596ed4c8fd..8bb25de20ae1d7abe756a75db113326f5343843b 100644 (file)
   <on_crash>destroy</on_crash>
   <devices>
     <emulator>/usr/bin/qemu-system-aarch64</emulator>
-    <controller type='usb' index='0' model='qemu-xhci'/>
+    <controller type='usb' index='0' model='qemu-xhci'>
+      <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x0'/>
+    </controller>
+    <controller type='pci' index='0' model='pci-root'/>
     <audio id='1' type='none'/>
     <memballoon model='none'/>
   </devices>
index 604c5ec4735c50bc97a621c25239a70aacdbdbb8..ccbff79f3578ddf4696bf8ec0117b6d57617e89b 100644 (file)
@@ -25,7 +25,7 @@ XDG_CONFIG_HOME=/var/lib/libvirt/qemu/domain--1-aarch64test/.config \
 -rtc base=utc \
 -no-shutdown \
 -boot strict=on \
--device '{"driver":"qemu-xhci","id":"usb"}' \
+-device '{"driver":"qemu-xhci","id":"usb","bus":"pci","addr":"0x1"}' \
 -audiodev '{"id":"audio1","driver":"none"}' \
 -sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,resourcecontrol=deny \
 -msg timestamp=on
index f61322ddb5aba118c2f41f12101653596ed4c8fd..8bb25de20ae1d7abe756a75db113326f5343843b 100644 (file)
   <on_crash>destroy</on_crash>
   <devices>
     <emulator>/usr/bin/qemu-system-aarch64</emulator>
-    <controller type='usb' index='0' model='qemu-xhci'/>
+    <controller type='usb' index='0' model='qemu-xhci'>
+      <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x0'/>
+    </controller>
+    <controller type='pci' index='0' model='pci-root'/>
     <audio id='1' type='none'/>
     <memballoon model='none'/>
   </devices>
index 9da9abaa884bfd5bcf9c804bb8c596918f411210..128a7d420e11f0531b43c38fb848759c71573326 100644 (file)
   <on_crash>destroy</on_crash>
   <devices>
     <emulator>/usr/bin/qemu-system-aarch64</emulator>
-    <controller type='usb' index='0'/>
+    <controller type='usb' index='0'>
+      <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x0'/>
+    </controller>
+    <controller type='pci' index='0' model='pci-root'/>
     <audio id='1' type='none'/>
     <memballoon model='none'/>
   </devices>