Since these architectures were introduced when qemu-xhci was already a thing, we never considered allowing the older nec-xhci model as a fallback.
That said, every other architecture that defaults to USB3 allows this, so we might as well be consistent. The chances of nec-xhci being available when qemu-xhci isn't are of course close to zero. Signed-off-by: Andrea Bolognani <abolo...@redhat.com> --- src/qemu/qemu_domain.c | 4 +- ...-fallback-virt-riscv64.riscv64-latest.args | 34 +++++++++++++++++ ...t-fallback-virt-riscv64.riscv64-latest.xml | 37 +++++++++++++++++++ ...ntroller-default-fallback-virt-riscv64.xml | 1 + tests/qemuxmlconftest.c | 7 +++- 5 files changed, 81 insertions(+), 2 deletions(-) create mode 100644 tests/qemuxmlconfdata/usb-controller-default-fallback-virt-riscv64.riscv64-latest.args create mode 100644 tests/qemuxmlconfdata/usb-controller-default-fallback-virt-riscv64.riscv64-latest.xml create mode 120000 tests/qemuxmlconfdata/usb-controller-default-fallback-virt-riscv64.xml diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index d5ddc4ef43..529acefbd7 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -4323,9 +4323,11 @@ qemuDomainDefaultUSBControllerModel(const virDomainDef *def, if (ARCH_IS_LOONGARCH(def->os.arch) || qemuDomainIsRISCVVirt(def)) { - /* Use qemu-xhci (USB3) for modern architectures */ + /* Use USB3 for modern architectures */ 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; /* No fallback if that's not available */ return VIR_DOMAIN_CONTROLLER_MODEL_USB_DEFAULT; diff --git a/tests/qemuxmlconfdata/usb-controller-default-fallback-virt-riscv64.riscv64-latest.args b/tests/qemuxmlconfdata/usb-controller-default-fallback-virt-riscv64.riscv64-latest.args new file mode 100644 index 0000000000..7292cb52db --- /dev/null +++ b/tests/qemuxmlconfdata/usb-controller-default-fallback-virt-riscv64.riscv64-latest.args @@ -0,0 +1,34 @@ +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-riscv64 \ +-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 virt,usb=off,dump-guest-core=off,memory-backend=riscv_virt_board.ram,acpi=off \ +-accel tcg \ +-cpu rv64 \ +-m size=2097152k \ +-object '{"qom-type":"memory-backend-ram","id":"riscv_virt_board.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 \ +-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":"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-riscv64.riscv64-latest.xml b/tests/qemuxmlconfdata/usb-controller-default-fallback-virt-riscv64.riscv64-latest.xml new file mode 100644 index 0000000000..6f0461d0fc --- /dev/null +++ b/tests/qemuxmlconfdata/usb-controller-default-fallback-virt-riscv64.riscv64-latest.xml @@ -0,0 +1,37 @@ +<domain type='qemu'> + <name>test</name> + <uuid>11dbdcdd-4c3b-482b-8903-9bdb8c0a2774</uuid> + <memory unit='KiB'>2097152</memory> + <currentMemory unit='KiB'>2097152</currentMemory> + <vcpu placement='static'>1</vcpu> + <os> + <type arch='riscv64' machine='virt'>hvm</type> + <boot dev='hd'/> + </os> + <cpu mode='custom' match='exact' check='none'> + <model fallback='forbid'>rv64</model> + </cpu> + <clock offset='utc'/> + <on_poweroff>destroy</on_poweroff> + <on_reboot>restart</on_reboot> + <on_crash>destroy</on_crash> + <devices> + <emulator>/usr/bin/qemu-system-riscv64</emulator> + <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'> + <model name='pcie-root-port'/> + <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-root-port'> + <model name='pcie-root-port'/> + <target chassis='2' port='0x9'/> + <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/> + </controller> + <audio id='1' type='none'/> + <memballoon model='none'/> + </devices> +</domain> diff --git a/tests/qemuxmlconfdata/usb-controller-default-fallback-virt-riscv64.xml b/tests/qemuxmlconfdata/usb-controller-default-fallback-virt-riscv64.xml new file mode 120000 index 0000000000..061240f8f2 --- /dev/null +++ b/tests/qemuxmlconfdata/usb-controller-default-fallback-virt-riscv64.xml @@ -0,0 +1 @@ +usb-controller-default-virt-riscv64.xml \ No newline at end of file diff --git a/tests/qemuxmlconftest.c b/tests/qemuxmlconftest.c index a955861dc4..439aa42e6b 100644 --- a/tests/qemuxmlconftest.c +++ b/tests/qemuxmlconftest.c @@ -2029,11 +2029,16 @@ mymain(void) ARG_END); DO_TEST_CAPS_ARCH_LATEST("usb-controller-default-virt-riscv64", "riscv64"); + DO_TEST_FULL("usb-controller-default-fallback-virt-riscv64", ".riscv64-latest", + ARG_CAPS_ARCH, "riscv64", + ARG_CAPS_VER, "latest", + ARG_QEMU_CAPS_DEL, QEMU_CAPS_DEVICE_QEMU_XHCI, QEMU_CAPS_LAST, + ARG_END); DO_TEST_FULL("usb-controller-default-unavailable-virt-riscv64", ".riscv64-latest", ARG_CAPS_ARCH, "riscv64", ARG_CAPS_VER, "latest", ARG_FLAGS, FLAG_EXPECT_PARSE_ERROR, - ARG_QEMU_CAPS_DEL, QEMU_CAPS_DEVICE_QEMU_XHCI, QEMU_CAPS_LAST, + ARG_QEMU_CAPS_DEL, QEMU_CAPS_DEVICE_QEMU_XHCI, QEMU_CAPS_NEC_USB_XHCI, QEMU_CAPS_LAST, ARG_END); /* controller selection tests for various uncommon machine types */ -- 2.50.1