From ae642084cec826c3bfad6111aab9bfc140c67189 Mon Sep 17 00:00:00 2001 From: Peter Krempa Date: Mon, 19 Feb 2024 15:28:33 +0100 Subject: [PATCH] qemu: command: Don't downgrade to '-usb' for x86 based machines MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - '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 Reviewed-by: Ján Tomko Reviewed-by: Andrea Bolognani --- src/qemu/qemu_command.c | 2 +- ...ault-unavailable-i440fx.x86_64-latest.args | 33 ------------------- ...fault-unavailable-i440fx.x86_64-latest.err | 1 + ...ntroller-implicit-isapc.x86_64-latest.args | 1 - tests/qemuxmlconftest.c | 6 ++-- 5 files changed, 6 insertions(+), 37 deletions(-) delete mode 100644 tests/qemuxmlconfdata/usb-controller-default-unavailable-i440fx.x86_64-latest.args create mode 100644 tests/qemuxmlconfdata/usb-controller-default-unavailable-i440fx.x86_64-latest.err diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 2719574fb5..d6328af70b 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -2922,7 +2922,7 @@ qemuBuildControllerDevProps(const virDomainDef *domainDef, static bool qemuBuildDomainForbidLegacyUSBController(const virDomainDef *def) { - if (qemuDomainIsQ35(def) || + if (ARCH_IS_X86(def->os.arch) || qemuDomainIsARMVirt(def) || qemuDomainIsRISCVVirt(def)) return true; diff --git a/tests/qemuxmlconfdata/usb-controller-default-unavailable-i440fx.x86_64-latest.args b/tests/qemuxmlconfdata/usb-controller-default-unavailable-i440fx.x86_64-latest.args deleted file mode 100644 index c8de26e4ee..0000000000 --- a/tests/qemuxmlconfdata/usb-controller-default-unavailable-i440fx.x86_64-latest.args +++ /dev/null @@ -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 diff --git a/tests/qemuxmlconfdata/usb-controller-default-unavailable-i440fx.x86_64-latest.err b/tests/qemuxmlconfdata/usb-controller-default-unavailable-i440fx.x86_64-latest.err new file mode 100644 index 0000000000..7a71aa107d --- /dev/null +++ b/tests/qemuxmlconfdata/usb-controller-default-unavailable-i440fx.x86_64-latest.err @@ -0,0 +1 @@ +unsupported configuration: no model provided for USB controller diff --git a/tests/qemuxmlconfdata/usb-controller-implicit-isapc.x86_64-latest.args b/tests/qemuxmlconfdata/usb-controller-implicit-isapc.x86_64-latest.args index 62dc26ee8b..cf8a176cd8 100644 --- a/tests/qemuxmlconfdata/usb-controller-implicit-isapc.x86_64-latest.args +++ b/tests/qemuxmlconfdata/usb-controller-implicit-isapc.x86_64-latest.args @@ -26,7 +26,6 @@ XDG_CONFIG_HOME=/var/lib/libvirt/qemu/domain--1-QEMUGuest1/.config \ -rtc base=utc \ -no-shutdown \ -boot strict=on \ --usb \ -audiodev '{"id":"audio1","driver":"none"}' \ -sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,resourcecontrol=deny \ -msg timestamp=on diff --git a/tests/qemuxmlconftest.c b/tests/qemuxmlconftest.c index 58ea59aed5..eeabf1f059 100644 --- a/tests/qemuxmlconftest.c +++ b/tests/qemuxmlconftest.c @@ -1865,13 +1865,15 @@ mymain(void) 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-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", ARG_CAPS_ARCH, "x86_64", ARG_CAPS_VER, "latest", + ARG_FLAGS, FLAG_EXPECT_FAILURE, ARG_QEMU_CAPS_DEL, QEMU_CAPS_PIIX3_USB_UHCI, QEMU_CAPS_LAST, 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", ARG_CAPS_ARCH, "x86_64", ARG_CAPS_VER, "latest",