Currently we fall back to the x86-derived default of piix3-uhci,
which is a USB1 controller that's not virtualization-friendly
and overall a terrible choice for a modern architecture. The
fact that we didn't choose a better default when RISC-V support
was introduced was an oversight which is now addressed.
Signed-off-by: Andrea Bolognani <abologna(a)redhat.com>
---
src/qemu/qemu_domain.c | 9 +++++++
...64-virt-default-models.riscv64-latest.args | 11 ++++----
...v64-virt-default-models.riscv64-latest.xml | 25 +++++++++++--------
3 files changed, 30 insertions(+), 15 deletions(-)
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index bf45198c09..bc83052920 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -4248,6 +4248,15 @@ qemuDomainDefaultUSBControllerModel(const virDomainDef *def,
}
}
+ if (ARCH_IS_RISCV(def->os.arch)) {
+ if (qemuDomainIsRISCVVirt(def)) {
+ /* USB3 only, no fallback */
+ if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_QEMU_XHCI))
+ return VIR_DOMAIN_CONTROLLER_MODEL_USB_QEMU_XHCI;
+ return -1;
+ }
+ }
+
/* piix3-uhci (USB1) is the last ditch effort before giving up */
if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_PIIX3_USB_UHCI))
return VIR_DOMAIN_CONTROLLER_MODEL_USB_PIIX3_UHCI;
diff --git a/tests/qemuxmlconfdata/riscv64-virt-default-models.riscv64-latest.args
b/tests/qemuxmlconfdata/riscv64-virt-default-models.riscv64-latest.args
index 28b56d876c..3a5cceb5e7 100644
--- a/tests/qemuxmlconfdata/riscv64-virt-default-models.riscv64-latest.args
+++ b/tests/qemuxmlconfdata/riscv64-virt-default-models.riscv64-latest.args
@@ -27,16 +27,17 @@ XDG_CONFIG_HOME=/var/lib/libvirt/qemu/domain--1-guest/.config \
-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-root-port","port":9,"chassis":2,"id":"pci.2","bus":"pcie.0","addr":"0x1.0x1"}'
\
--device
'{"driver":"pcie-pci-bridge","id":"pci.3","bus":"pci.1","addr":"0x0"}'
\
--device
'{"driver":"pcie-root-port","port":10,"chassis":4,"id":"pci.4","bus":"pcie.0","addr":"0x1.0x2"}'
\
+-device
'{"driver":"pcie-root-port","port":10,"chassis":3,"id":"pci.3","bus":"pcie.0","addr":"0x1.0x2"}'
\
+-device
'{"driver":"pcie-pci-bridge","id":"pci.4","bus":"pci.1","addr":"0x0"}'
\
-device
'{"driver":"pcie-root-port","port":11,"chassis":5,"id":"pci.5","bus":"pcie.0","addr":"0x1.0x3"}'
\
--device
'{"driver":"piix3-usb-uhci","id":"usb","bus":"pci.3","addr":"0x1"}'
\
--device
'{"driver":"lsi","id":"scsi0","bus":"pci.3","addr":"0x2"}'
\
+-device
'{"driver":"pcie-root-port","port":12,"chassis":6,"id":"pci.6","bus":"pcie.0","addr":"0x1.0x4"}'
\
+-device
'{"driver":"qemu-xhci","id":"usb","bus":"pci.3","addr":"0x0"}'
\
+-device
'{"driver":"lsi","id":"scsi0","bus":"pci.4","addr":"0x1"}'
\
-netdev '{"type":"user","id":"hostnet0"}'
\
-device
'{"driver":"virtio-net-pci","netdev":"hostnet0","id":"net0","mac":"52:54:00:09:a4:37","bus":"pci.2","addr":"0x0"}'
\
-chardev pty,id=charserial0 \
-serial chardev:charserial0 \
-audiodev
'{"id":"audio1","driver":"none"}' \
--device
'{"driver":"virtio-vga","id":"video0","max_outputs":1,"bus":"pci.4","addr":"0x0"}'
\
+-device
'{"driver":"virtio-vga","id":"video0","max_outputs":1,"bus":"pci.5","addr":"0x0"}'
\
-sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,resourcecontrol=deny \
-msg timestamp=on
diff --git a/tests/qemuxmlconfdata/riscv64-virt-default-models.riscv64-latest.xml
b/tests/qemuxmlconfdata/riscv64-virt-default-models.riscv64-latest.xml
index 942bd21f9e..896bd7d0f0 100644
--- a/tests/qemuxmlconfdata/riscv64-virt-default-models.riscv64-latest.xml
+++ b/tests/qemuxmlconfdata/riscv64-virt-default-models.riscv64-latest.xml
@@ -14,11 +14,11 @@
<on_crash>destroy</on_crash>
<devices>
<emulator>/usr/bin/qemu-system-riscv64</emulator>
- <controller type='usb' index='0' model='piix3-uhci'>
- <address type='pci' domain='0x0000' bus='0x03'
slot='0x01' function='0x0'/>
+ <controller type='usb' index='0' model='qemu-xhci'>
+ <address type='pci' domain='0x0000' bus='0x03'
slot='0x00' function='0x0'/>
</controller>
<controller type='scsi' index='0' model='lsilogic'>
- <address type='pci' domain='0x0000' bus='0x03'
slot='0x02' function='0x0'/>
+ <address type='pci' domain='0x0000' bus='0x04'
slot='0x01' function='0x0'/>
</controller>
<controller type='pci' index='0' model='pcie-root'/>
<controller type='pci' index='1'
model='pcie-root-port'>
@@ -31,20 +31,25 @@
<target chassis='2' port='0x9'/>
<address type='pci' domain='0x0000' bus='0x00'
slot='0x01' function='0x1'/>
</controller>
- <controller type='pci' index='3'
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='4'
model='pcie-root-port'>
+ <controller type='pci' index='3'
model='pcie-root-port'>
<model name='pcie-root-port'/>
- <target chassis='4' port='0xa'/>
+ <target chassis='3' port='0xa'/>
<address type='pci' domain='0x0000' bus='0x00'
slot='0x01' function='0x2'/>
</controller>
+ <controller type='pci' index='4'
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='5'
model='pcie-root-port'>
<model name='pcie-root-port'/>
<target chassis='5' port='0xb'/>
<address type='pci' domain='0x0000' bus='0x00'
slot='0x01' function='0x3'/>
</controller>
+ <controller type='pci' index='6'
model='pcie-root-port'>
+ <model name='pcie-root-port'/>
+ <target chassis='6' port='0xc'/>
+ <address type='pci' domain='0x0000' bus='0x00'
slot='0x01' function='0x4'/>
+ </controller>
<interface type='user'>
<mac address='52:54:00:09:a4:37'/>
<model type='virtio'/>
@@ -61,7 +66,7 @@
<audio id='1' type='none'/>
<video>
<model type='virtio' heads='1' primary='yes'/>
- <address type='pci' domain='0x0000' bus='0x04'
slot='0x00' function='0x0'/>
+ <address type='pci' domain='0x0000' bus='0x05'
slot='0x00' function='0x0'/>
</video>
<memballoon model='none'/>
</devices>
--
2.43.0