[PATCH v2 36/38] qemu: Remove fallback to piix3-uhci for Arm virt guests

Andrea Bolognani via Devel posted 38 patches 1 week, 2 days ago
[PATCH v2 36/38] qemu: Remove fallback to piix3-uhci for Arm virt guests
Posted by Andrea Bolognani via Devel 1 week, 2 days ago
This is another case where the current behavior can be traced
back to the fact that x86 was the only architecture to really
be taken into account for a long time: in reality, using an
Intel-specific USB1 controller for a modern, PCIe-native,
virtualization-friendly Arm guest just doesn't make any sense.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
---
 src/qemu/qemu_domain.c                               | 10 ++++++++++
 ...default-fallback-virt-aarch64.aarch64-latest.args |  5 ++---
 ...-default-fallback-virt-aarch64.aarch64-latest.xml | 12 ++++--------
 tests/qemuxmlconftest.c                              |  2 +-
 4 files changed, 17 insertions(+), 12 deletions(-)

diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index 9927ab3cbb..b1a92279a7 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -4331,6 +4331,16 @@ qemuDomainDefaultUSBControllerModel(const virDomainDef *def,
         return VIR_DOMAIN_CONTROLLER_MODEL_USB_DEFAULT;
     }
 
+    if (qemuDomainIsARMVirt(def)) {
+        /* Use qemu-xhci or nec-xhci (USB3) with no fallback */
+        if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_QEMU_XHCI))
+            return VIR_DOMAIN_CONTROLLER_MODEL_USB_QEMU_XHCI;
+        if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_NEC_USB_XHCI))
+            return VIR_DOMAIN_CONTROLLER_MODEL_USB_NEC_XHCI;
+
+        return VIR_DOMAIN_CONTROLLER_MODEL_USB_DEFAULT;
+    }
+
     if (ARCH_IS_ARM(def->os.arch)) {
         /* Prefer qemu-xhci or nec-xhci (USB3) */
         if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_QEMU_XHCI))
diff --git a/tests/qemuxmlconfdata/usb-controller-default-fallback-virt-aarch64.aarch64-latest.args b/tests/qemuxmlconfdata/usb-controller-default-fallback-virt-aarch64.aarch64-latest.args
index 63ea7be2aa..44689d81f9 100644
--- a/tests/qemuxmlconfdata/usb-controller-default-fallback-virt-aarch64.aarch64-latest.args
+++ b/tests/qemuxmlconfdata/usb-controller-default-fallback-virt-aarch64.aarch64-latest.args
@@ -27,9 +27,8 @@ XDG_CONFIG_HOME=/var/lib/libvirt/qemu/domain--1-test/.config \
 -no-shutdown \
 -boot strict=on \
 -device '{"driver":"pcie-root-port","port":8,"chassis":1,"id":"pci.1","bus":"pcie.0","multifunction":true,"addr":"0x1"}' \
--device '{"driver":"pcie-pci-bridge","id":"pci.2","bus":"pci.1","addr":"0x0"}' \
--device '{"driver":"pcie-root-port","port":9,"chassis":3,"id":"pci.3","bus":"pcie.0","addr":"0x1.0x1"}' \
--device '{"driver":"piix3-usb-uhci","id":"usb","bus":"pci.2","addr":"0x1"}' \
+-device '{"driver":"pcie-root-port","port":9,"chassis":2,"id":"pci.2","bus":"pcie.0","addr":"0x1.0x1"}' \
+-device '{"driver":"nec-usb-xhci","id":"usb","bus":"pci.1","addr":"0x0"}' \
 -audiodev '{"id":"audio1","driver":"none"}' \
 -sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,resourcecontrol=deny \
 -msg timestamp=on
diff --git a/tests/qemuxmlconfdata/usb-controller-default-fallback-virt-aarch64.aarch64-latest.xml b/tests/qemuxmlconfdata/usb-controller-default-fallback-virt-aarch64.aarch64-latest.xml
index cea6dde62d..943c433f40 100644
--- a/tests/qemuxmlconfdata/usb-controller-default-fallback-virt-aarch64.aarch64-latest.xml
+++ b/tests/qemuxmlconfdata/usb-controller-default-fallback-virt-aarch64.aarch64-latest.xml
@@ -20,8 +20,8 @@
   <on_crash>destroy</on_crash>
   <devices>
     <emulator>/usr/bin/qemu-system-aarch64</emulator>
-    <controller type='usb' index='0' model='piix3-uhci'>
-      <address type='pci' domain='0x0000' bus='0x02' slot='0x01' function='0x0'/>
+    <controller type='usb' index='0' model='nec-xhci'>
+      <address type='pci' domain='0x0000' bus='0x01' slot='0x00' function='0x0'/>
     </controller>
     <controller type='pci' index='0' model='pcie-root'/>
     <controller type='pci' index='1' model='pcie-root-port'>
@@ -29,13 +29,9 @@
       <target chassis='1' port='0x8'/>
       <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x0' multifunction='on'/>
     </controller>
-    <controller type='pci' index='2' model='pcie-to-pci-bridge'>
-      <model name='pcie-pci-bridge'/>
-      <address type='pci' domain='0x0000' bus='0x01' slot='0x00' function='0x0'/>
-    </controller>
-    <controller type='pci' index='3' model='pcie-root-port'>
+    <controller type='pci' index='2' model='pcie-root-port'>
       <model name='pcie-root-port'/>
-      <target chassis='3' port='0x9'/>
+      <target chassis='2' port='0x9'/>
       <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/>
     </controller>
     <audio id='1' type='none'/>
diff --git a/tests/qemuxmlconftest.c b/tests/qemuxmlconftest.c
index 7663a43856..a68a887645 100644
--- a/tests/qemuxmlconftest.c
+++ b/tests/qemuxmlconftest.c
@@ -2157,7 +2157,7 @@ mymain(void)
     DO_TEST_FULL("usb-controller-default-fallback-virt-aarch64", ".aarch64-latest",
                  ARG_CAPS_ARCH, "aarch64",
                  ARG_CAPS_VER, "latest",
-                 ARG_QEMU_CAPS_DEL, QEMU_CAPS_DEVICE_QEMU_XHCI, QEMU_CAPS_NEC_USB_XHCI, QEMU_CAPS_LAST,
+                 ARG_QEMU_CAPS_DEL, QEMU_CAPS_DEVICE_QEMU_XHCI, QEMU_CAPS_LAST,
                  ARG_END);
     DO_TEST_FULL("usb-controller-default-unavailable-virt-aarch64", ".aarch64-latest",
                  ARG_CAPS_ARCH, "aarch64",
-- 
2.51.0
Re: [PATCH v2 36/38] qemu: Remove fallback to piix3-uhci for Arm virt guests
Posted by Peter Krempa via Devel 1 day, 11 hours ago
On Thu, Sep 25, 2025 at 20:07:22 +0200, Andrea Bolognani via Devel wrote:
> This is another case where the current behavior can be traced
> back to the fact that x86 was the only architecture to really
> be taken into account for a long time: in reality, using an
> Intel-specific USB1 controller for a modern, PCIe-native,
> virtualization-friendly Arm guest just doesn't make any sense.
> 
> Signed-off-by: Andrea Bolognani <abologna@redhat.com>
> ---
>  src/qemu/qemu_domain.c                               | 10 ++++++++++
>  ...default-fallback-virt-aarch64.aarch64-latest.args |  5 ++---
>  ...-default-fallback-virt-aarch64.aarch64-latest.xml | 12 ++++--------
>  tests/qemuxmlconftest.c                              |  2 +-
>  4 files changed, 17 insertions(+), 12 deletions(-)

Reviewed-by: Peter Krempa <pkrempa@redhat.com>