qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH-for-5.1] qdev: Allow to create hotplug device before plugging


From: Markus Armbruster
Subject: Re: [PATCH-for-5.1] qdev: Allow to create hotplug device before plugging it to a bus
Date: Mon, 20 Jul 2020 10:27:18 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/26.3 (gnu/linux)

Philippe Mathieu-Daudé <f4bug@amsat.org> writes:

> Commit 510ef98dca made qdev_realize() support bus-less devices,
> asserting either the device is bus-less or the device is created
> on a bus. Commit 464a22c757 used qdev_realize() instead of
> object_property_set_bool(). Since qdev_realize() now checks for
> a bus, it is not possible to create hotplug devices unattached
> to any bus anymore.
>
> Fix by only asserting if the device is not hotpluggable.
>
> Fixes: 464a22c757 "qdev: Use qdev_realize() in qdev_device_add()"
> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
> ---
>  hw/core/qdev.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/hw/core/qdev.c b/hw/core/qdev.c
> index 01796823b4..6c5540ecdc 100644
> --- a/hw/core/qdev.c
> +++ b/hw/core/qdev.c
> @@ -393,7 +393,9 @@ bool qdev_realize(DeviceState *dev, BusState *bus, Error 
> **errp)
>      if (bus) {
>          qdev_set_parent_bus(dev, bus);
>      } else {
> -        assert(!DEVICE_GET_CLASS(dev)->bus_type);
> +        DeviceClass *dc = DEVICE_GET_CLASS(dev);
> +
> +        assert(dc->hotpluggable || !dc->bus_type);
>      }
>  
>      return object_property_set_bool(OBJECT(dev), "realized", true, errp);

I think this is wrong.

Invariant about realized devices and their bus:

* realized "bus-full" devices are plugged into an appropriate bus, and

* realized bus-less devices are not plugged into any bus.

Since qdev_realize() goes from unrealized to realized, it needs to
establish the invariant, regardless of dc->hotpluggable.

I suspect the bug is in the caller.  Give me a concrete reproducer, and
I'll look.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]