From: Peng Fan <[email protected]>

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.

Fixes: 250e797ceada ("hw/xen: Have legacy Xen backend inherit from 
DYNAMIC_SYS_BUS_DEVICE")
Signed-off-by: Peng Fan <[email protected]>
Tested-by: Julian Vetter <[email protected]>
Acked-by: Stefano Stabellini <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
---
 hw/xen/xen-legacy-backend.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/hw/xen/xen-legacy-backend.c b/hw/xen/xen-legacy-backend.c
index 7977b527127b..bf4396c9460d 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;
 }
 
-- 
2.55.0


Reply via email to