[PATCH] hw/xen: Mark legacy Xen backends as hotpluggable

Peng Fan (OSS) posted 1 patch 1 week ago
There is a newer version of this series
hw/xen/xen-legacy-backend.c | 7 +++++++
1 file changed, 7 insertions(+)
[PATCH] hw/xen: Mark legacy Xen backends as hotpluggable
Posted by Peng Fan (OSS) 1 week ago
From: Peng Fan <peng.fan@nxp.com>

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 <peng.fan@nxp.com>
---
 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 7977b527127..bf4396c9460 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;
 }
 

---
base-commit: e9fa1f66f0d47c74b6766e1b8b87ad7c2a9394d5
change-id: 20261116-qemu-xen-usb-1a36b002a561

Best regards,
--  
Peng Fan <peng.fan@nxp.com>
Re: [PATCH] hw/xen: Mark legacy Xen backends as hotpluggable
Posted by Julian Vetter 1 week ago
On 11/16/26 03:56, Peng Fan (OSS) wrote:

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

This also fixes the legacy vfb/vkbd backends with -machine xenpv 
(qemu-system-i386 -xen-attach -machine xenpv -vga xenfb) on an arm64 Xen 
4.21 host. Without this fix QEMU exits with "Device 'xen-backend' does 
not support hotplugging" as soon as the backends are created from 
xenstore. Tested on top of QEMU 10.1.0 with an arm64 Debian 13 guest 
(xen-fbfront/xen-kbdfront).

Tested-by: Julian Vetter <julian.vetter@vates.tech>

> 
> ---
> base-commit: e9fa1f66f0d47c74b6766e1b8b87ad7c2a9394d5
> change-id: 20261116-qemu-xen-usb-1a36b002a561
> 
> Best regards,
> --
> Peng Fan <peng.fan@nxp.com>
> 
> 



-- 
Julian Vetter | Vates Hypervisor & Kernel Developer

XCP-ng & Xen Orchestra - Vates solutions

web: https://vates.tech
Re: [PATCH] hw/xen: Mark legacy Xen backends as hotpluggable
Posted by Stefano Stabellini 1 week ago
On Mon, 16 Nov 2026, Julian Vetter wrote:
> On 11/16/26 03:56, Peng Fan (OSS) wrote:
> 
> > diff --git a/hw/xen/xen-legacy-backend.c b/hw/xen/xen-legacy-backend.c
> > index 7977b527127..bf4396c9460 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;
> >   }
> >   
> 
> This also fixes the legacy vfb/vkbd backends with -machine xenpv 
> (qemu-system-i386 -xen-attach -machine xenpv -vga xenfb) on an arm64 Xen 
> 4.21 host. Without this fix QEMU exits with "Device 'xen-backend' does 
> not support hotplugging" as soon as the backends are created from 
> xenstore. Tested on top of QEMU 10.1.0 with an arm64 Debian 13 guest 
> (xen-fbfront/xen-kbdfront).
> 
> Tested-by: Julian Vetter <julian.vetter@vates.tech>

Acked-by: Stefano Stabellini <sstabellini@kernel.org>