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 +++++++
...ault-models.riscv64-latest.abi-update.args | 15 +++++------
...fault-models.riscv64-latest.abi-update.xml | 26 ++++++++-----------
...64-virt-default-models.riscv64-latest.args | 15 +++++------
...v64-virt-default-models.riscv64-latest.xml | 26 ++++++++-----------
5 files changed, 45 insertions(+), 46 deletions(-)
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index db09af496b..47058de2f2 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -4166,6 +4166,15 @@ qemuDomainDefaultUSBControllerModelInternal(bool autoAdded,
{
bool abiUpdate = !!(parseFlags & VIR_DOMAIN_DEF_PARSE_ABI_UPDATE);
+ /* For modern architectures we want to use qemu-xhci (USB3), with
+ * no fallback if that's not available */
+ if (qemuDomainIsRISCVVirt(def)) {
+ if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_QEMU_XHCI)) {
+ return VIR_DOMAIN_CONTROLLER_MODEL_USB_QEMU_XHCI;
+ }
+ return VIR_DOMAIN_CONTROLLER_MODEL_USB_DEFAULT;
+ }
+
if (ARCH_IS_S390(def->os.arch)) {
/* No default model on s390x, one has to be provided
* explicitly by the user */
diff --git
a/tests/qemuxmlconfdata/riscv64-virt-default-models.riscv64-latest.abi-update.args
b/tests/qemuxmlconfdata/riscv64-virt-default-models.riscv64-latest.abi-update.args
index 7990f7f6a0..155c5aed9c 100644
--- a/tests/qemuxmlconfdata/riscv64-virt-default-models.riscv64-latest.abi-update.args
+++ b/tests/qemuxmlconfdata/riscv64-virt-default-models.riscv64-latest.abi-update.args
@@ -27,17 +27,16 @@ 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":11,"chassis":5,"id":"pci.5","bus":"pcie.0","addr":"0x1.0x3"}'
\
--device
'{"driver":"pcie-root-port","port":12,"chassis":6,"id":"pci.6","bus":"pcie.0","addr":"0x1.0x4"}'
\
--device
'{"driver":"piix3-usb-uhci","id":"usb","bus":"pci.3","addr":"0x1"}'
\
--device
'{"driver":"virtio-scsi-pci","id":"scsi0","bus":"pci.4","addr":"0x0"}'
\
+-device
'{"driver":"pcie-root-port","port":10,"chassis":3,"id":"pci.3","bus":"pcie.0","addr":"0x1.0x2"}'
\
+-device
'{"driver":"pcie-root-port","port":11,"chassis":4,"id":"pci.4","bus":"pcie.0","addr":"0x1.0x3"}'
\
+-device
'{"driver":"pcie-root-port","port":12,"chassis":5,"id":"pci.5","bus":"pcie.0","addr":"0x1.0x4"}'
\
+-device
'{"driver":"qemu-xhci","id":"usb","bus":"pci.2","addr":"0x0"}'
\
+-device
'{"driver":"virtio-scsi-pci","id":"scsi0","bus":"pci.3","addr":"0x0"}'
\
-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"}'
\
+-device
'{"driver":"virtio-net-pci","netdev":"hostnet0","id":"net0","mac":"52:54:00:09:a4:37","bus":"pci.1","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.5","addr":"0x0"}'
\
+-device
'{"driver":"virtio-vga","id":"video0","max_outputs":1,"bus":"pci.4","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.abi-update.xml
b/tests/qemuxmlconfdata/riscv64-virt-default-models.riscv64-latest.abi-update.xml
index 72dc447d33..4628cd7895 100644
--- a/tests/qemuxmlconfdata/riscv64-virt-default-models.riscv64-latest.abi-update.xml
+++ b/tests/qemuxmlconfdata/riscv64-virt-default-models.riscv64-latest.abi-update.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='0x02'
slot='0x00' function='0x0'/>
</controller>
<controller type='scsi' index='0' model='virtio-scsi'>
- <address type='pci' domain='0x0000' bus='0x04'
slot='0x00' function='0x0'/>
+ <address type='pci' domain='0x0000' bus='0x03'
slot='0x00' function='0x0'/>
</controller>
<controller type='pci' index='0' model='pcie-root'/>
<controller type='pci' index='1'
model='pcie-root-port'>
@@ -31,29 +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='5'
model='pcie-root-port'>
+ <controller type='pci' index='4'
model='pcie-root-port'>
<model name='pcie-root-port'/>
- <target chassis='5' port='0xb'/>
+ <target chassis='4' port='0xb'/>
<address type='pci' domain='0x0000' bus='0x00'
slot='0x01' function='0x3'/>
</controller>
- <controller type='pci' index='6'
model='pcie-root-port'>
+ <controller type='pci' index='5'
model='pcie-root-port'>
<model name='pcie-root-port'/>
- <target chassis='6' port='0xc'/>
+ <target chassis='5' 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'/>
- <address type='pci' domain='0x0000' bus='0x02'
slot='0x00' function='0x0'/>
+ <address type='pci' domain='0x0000' bus='0x01'
slot='0x00' function='0x0'/>
</interface>
<serial type='pty'>
<target type='system-serial' port='0'>
@@ -66,7 +62,7 @@
<audio id='1' type='none'/>
<video>
<model type='virtio' heads='1' primary='yes'/>
- <address type='pci' domain='0x0000' bus='0x05'
slot='0x00' function='0x0'/>
+ <address type='pci' domain='0x0000' bus='0x04'
slot='0x00' function='0x0'/>
</video>
<memballoon model='none'/>
</devices>
diff --git a/tests/qemuxmlconfdata/riscv64-virt-default-models.riscv64-latest.args
b/tests/qemuxmlconfdata/riscv64-virt-default-models.riscv64-latest.args
index 7990f7f6a0..155c5aed9c 100644
--- a/tests/qemuxmlconfdata/riscv64-virt-default-models.riscv64-latest.args
+++ b/tests/qemuxmlconfdata/riscv64-virt-default-models.riscv64-latest.args
@@ -27,17 +27,16 @@ 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":11,"chassis":5,"id":"pci.5","bus":"pcie.0","addr":"0x1.0x3"}'
\
--device
'{"driver":"pcie-root-port","port":12,"chassis":6,"id":"pci.6","bus":"pcie.0","addr":"0x1.0x4"}'
\
--device
'{"driver":"piix3-usb-uhci","id":"usb","bus":"pci.3","addr":"0x1"}'
\
--device
'{"driver":"virtio-scsi-pci","id":"scsi0","bus":"pci.4","addr":"0x0"}'
\
+-device
'{"driver":"pcie-root-port","port":10,"chassis":3,"id":"pci.3","bus":"pcie.0","addr":"0x1.0x2"}'
\
+-device
'{"driver":"pcie-root-port","port":11,"chassis":4,"id":"pci.4","bus":"pcie.0","addr":"0x1.0x3"}'
\
+-device
'{"driver":"pcie-root-port","port":12,"chassis":5,"id":"pci.5","bus":"pcie.0","addr":"0x1.0x4"}'
\
+-device
'{"driver":"qemu-xhci","id":"usb","bus":"pci.2","addr":"0x0"}'
\
+-device
'{"driver":"virtio-scsi-pci","id":"scsi0","bus":"pci.3","addr":"0x0"}'
\
-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"}'
\
+-device
'{"driver":"virtio-net-pci","netdev":"hostnet0","id":"net0","mac":"52:54:00:09:a4:37","bus":"pci.1","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.5","addr":"0x0"}'
\
+-device
'{"driver":"virtio-vga","id":"video0","max_outputs":1,"bus":"pci.4","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 72dc447d33..4628cd7895 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='0x02'
slot='0x00' function='0x0'/>
</controller>
<controller type='scsi' index='0' model='virtio-scsi'>
- <address type='pci' domain='0x0000' bus='0x04'
slot='0x00' function='0x0'/>
+ <address type='pci' domain='0x0000' bus='0x03'
slot='0x00' function='0x0'/>
</controller>
<controller type='pci' index='0' model='pcie-root'/>
<controller type='pci' index='1'
model='pcie-root-port'>
@@ -31,29 +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='5'
model='pcie-root-port'>
+ <controller type='pci' index='4'
model='pcie-root-port'>
<model name='pcie-root-port'/>
- <target chassis='5' port='0xb'/>
+ <target chassis='4' port='0xb'/>
<address type='pci' domain='0x0000' bus='0x00'
slot='0x01' function='0x3'/>
</controller>
- <controller type='pci' index='6'
model='pcie-root-port'>
+ <controller type='pci' index='5'
model='pcie-root-port'>
<model name='pcie-root-port'/>
- <target chassis='6' port='0xc'/>
+ <target chassis='5' 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'/>
- <address type='pci' domain='0x0000' bus='0x02'
slot='0x00' function='0x0'/>
+ <address type='pci' domain='0x0000' bus='0x01'
slot='0x00' function='0x0'/>
</interface>
<serial type='pty'>
<target type='system-serial' port='0'>
@@ -66,7 +62,7 @@
<audio id='1' type='none'/>
<video>
<model type='virtio' heads='1' primary='yes'/>
- <address type='pci' domain='0x0000' bus='0x05'
slot='0x00' function='0x0'/>
+ <address type='pci' domain='0x0000' bus='0x04'
slot='0x00' function='0x0'/>
</video>
<memballoon model='none'/>
</devices>
--
2.43.0