qemu: command: Don't downgrade to '-usb' for x86 based machines

- 'q35' machine type already explicitly forbids fallback
- 'isapc' never supported USB and '-usb' is ignored
- 'i440fx' does support '-usb' and translates it into 'piix3-uhci' which
  is identical to what libvirt selects
- we currently don't care about 'microvm'

Attempting to start an 'pc' (i440fx) machine with -usb when 'piix3-uhci'
is compiled out will fail and in any other case libvirt will use the
proper explicitly selected controller.

Drop the '-usb' downgrade for x86 arch.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
This commit is contained in:
Peter Krempa 2024-02-19 15:28:33 +01:00
parent b37096778b
commit ae642084ce
5 changed files with 6 additions and 37 deletions

View File

@ -2922,7 +2922,7 @@ qemuBuildControllerDevProps(const virDomainDef *domainDef,
static bool static bool
qemuBuildDomainForbidLegacyUSBController(const virDomainDef *def) qemuBuildDomainForbidLegacyUSBController(const virDomainDef *def)
{ {
if (qemuDomainIsQ35(def) || if (ARCH_IS_X86(def->os.arch) ||
qemuDomainIsARMVirt(def) || qemuDomainIsARMVirt(def) ||
qemuDomainIsRISCVVirt(def)) qemuDomainIsRISCVVirt(def))
return true; return true;

View File

@ -1,33 +0,0 @@
LC_ALL=C \
PATH=/bin \
HOME=/var/lib/libvirt/qemu/domain--1-QEMUGuest1 \
USER=test \
LOGNAME=test \
XDG_DATA_HOME=/var/lib/libvirt/qemu/domain--1-QEMUGuest1/.local/share \
XDG_CACHE_HOME=/var/lib/libvirt/qemu/domain--1-QEMUGuest1/.cache \
XDG_CONFIG_HOME=/var/lib/libvirt/qemu/domain--1-QEMUGuest1/.config \
/usr/bin/qemu-system-x86_64 \
-name guest=QEMUGuest1,debug-threads=on \
-S \
-object '{"qom-type":"secret","id":"masterKey0","format":"raw","file":"/var/lib/libvirt/qemu/domain--1-QEMUGuest1/master-key.aes"}' \
-machine pc,usb=off,dump-guest-core=off,memory-backend=pc.ram,acpi=off \
-accel tcg \
-cpu qemu64 \
-m size=219136k \
-object '{"qom-type":"memory-backend-ram","id":"pc.ram","size":224395264}' \
-overcommit mem-lock=off \
-smp 1,sockets=1,cores=1,threads=1 \
-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \
-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 \
-usb \
-audiodev '{"id":"audio1","driver":"none"}' \
-device '{"driver":"virtio-balloon-pci","id":"balloon0","bus":"pci.0","addr":"0x2"}' \
-sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,resourcecontrol=deny \
-msg timestamp=on

View File

@ -0,0 +1 @@
unsupported configuration: no model provided for USB controller

View File

@ -26,7 +26,6 @@ XDG_CONFIG_HOME=/var/lib/libvirt/qemu/domain--1-QEMUGuest1/.config \
-rtc base=utc \ -rtc base=utc \
-no-shutdown \ -no-shutdown \
-boot strict=on \ -boot strict=on \
-usb \
-audiodev '{"id":"audio1","driver":"none"}' \ -audiodev '{"id":"audio1","driver":"none"}' \
-sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,resourcecontrol=deny \ -sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,resourcecontrol=deny \
-msg timestamp=on -msg timestamp=on

View File

@ -1865,13 +1865,15 @@ mymain(void)
DO_TEST_CAPS_ARCH_LATEST("usb-controller-default-mac99", "ppc64"); DO_TEST_CAPS_ARCH_LATEST("usb-controller-default-mac99", "ppc64");
DO_TEST_CAPS_ARCH_LATEST("usb-controller-default-mac99ppc", "ppc"); DO_TEST_CAPS_ARCH_LATEST("usb-controller-default-mac99ppc", "ppc");
DO_TEST_CAPS_ARCH_LATEST("usb-controller-default-powernv9", "ppc64"); DO_TEST_CAPS_ARCH_LATEST("usb-controller-default-powernv9", "ppc64");
/* i440fx downgrades to use '-usb' if the explicit controller is not present */ /* Until qemu-8.1 (see commit 6fe4464c05f) it was possible to compile
* out USB support from i440fx; the implicit -usb controller still failed */
DO_TEST_FULL("usb-controller-default-unavailable-i440fx", ".x86_64-latest", DO_TEST_FULL("usb-controller-default-unavailable-i440fx", ".x86_64-latest",
ARG_CAPS_ARCH, "x86_64", ARG_CAPS_ARCH, "x86_64",
ARG_CAPS_VER, "latest", ARG_CAPS_VER, "latest",
ARG_FLAGS, FLAG_EXPECT_FAILURE,
ARG_QEMU_CAPS_DEL, QEMU_CAPS_PIIX3_USB_UHCI, QEMU_CAPS_LAST, ARG_QEMU_CAPS_DEL, QEMU_CAPS_PIIX3_USB_UHCI, QEMU_CAPS_LAST,
ARG_END); ARG_END);
/* q35 fails instead */ /* The implicit controller can be compiled out for q35; initialization fails though */
DO_TEST_FULL("usb-controller-default-unavailable-q35", ".x86_64-latest", DO_TEST_FULL("usb-controller-default-unavailable-q35", ".x86_64-latest",
ARG_CAPS_ARCH, "x86_64", ARG_CAPS_ARCH, "x86_64",
ARG_CAPS_VER, "latest", ARG_CAPS_VER, "latest",