Commit 8c40d4495d for qemu.org
commit 8c40d4495d19c2d2d5a97a432d9fb18e23cc8f66
Author: Peng Fan <peng.fan@nxp.com>
Date: Mon Nov 16 10:49:57 2026 +0800
hw/xen: Mark legacy Xen backends as hotpluggable
Commit 250e797ceada ("hw/xen: Have legacy Xen backend inherit from
DYNAMIC_SYS_BUS_DEVICE") changed TYPE_XENBACKEND to inherit from
TYPE_DYNAMIC_SYS_BUS_DEVICE, whose class sets hotpluggable = false.
Legacy Xen backends are created from xenstore at runtime, after the
machine is ready, so device_initfn() marks them as hotplugged. The new
class setting makes device_set_realized() reject them with:
Device 'xen-backend' does not support hotplugging
Since xen_be_get_xendev() realizes the device with &error_fatal, QEMU
then exits. For example, "xl usbdev-attach" triggers this when the qusb
backend is created dynamically, killing the guest. The same flag also
causes qdev_unplug() to ignore these devices.
Override hotpluggable in xendev_class_init() to restore the behavior
before the offending commit.
Cc: qemu-stable@nongnu.org
Fixes: 250e797ceada ("hw/xen: Have legacy Xen backend inherit from DYNAMIC_SYS_BUS_DEVICE")
Signed-off-by: Peng Fan <peng.fan@nxp.com>
Tested-by: Julian Vetter <julian.vetter@vates.tech>
Acked-by: Stefano Stabellini <sstabellini@kernel.org>
Message-ID: <20261116-qemu-xen-usb-v1-1-bff36d5b646b@nxp.com>
Signed-off-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>
diff --git a/hw/xen/xen-legacy-backend.c b/hw/xen/xen-legacy-backend.c
index 75f8ac7efd..54af624672 100644
--- a/hw/xen/xen-legacy-backend.c
+++ b/hw/xen/xen-legacy-backend.c
@@ -640,6 +640,13 @@ static void xendev_class_init(ObjectClass *klass, const void *data)
DeviceClass *dc = DEVICE_CLASS(klass);
set_bit(DEVICE_CATEGORY_MISC, dc->categories);
+ /*
+ * Legacy Xen backends are created and destroyed dynamically from
+ * xenstore at runtime, after the machine has been initialized.
+ * TYPE_DYNAMIC_SYS_BUS_DEVICE marks devices as not hotpluggable,
+ * so override that here.
+ */
+ dc->hotpluggable = true;
dc->bus_type = TYPE_XENSYSBUS;
}