qemu-devel
[Top][All Lists]
Advanced

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

Re: [PATCH 22/24] qdev: Assert devices are plugged into a bus that can t


From: Mark Cave-Ayland
Subject: Re: [PATCH 22/24] qdev: Assert devices are plugged into a bus that can take them
Date: Mon, 18 May 2020 21:42:28 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.8.0

On 18/05/2020 06:04, Markus Armbruster wrote:

> This would have caught some of the bugs I just fixed.
> 
> Signed-off-by: Markus Armbruster <address@hidden>
> ---
>  hw/core/qdev.c | 5 +++++
>  1 file changed, 5 insertions(+)
> 
> diff --git a/hw/core/qdev.c b/hw/core/qdev.c
> index 9e5538aeae..0df995eb94 100644
> --- a/hw/core/qdev.c
> +++ b/hw/core/qdev.c
> @@ -97,6 +97,11 @@ static void bus_add_child(BusState *bus, DeviceState 
> *child)
>  void qdev_set_parent_bus(DeviceState *dev, BusState *bus)
>  {
>      BusState *old_parent_bus = dev->parent_bus;
> +    DeviceClass *dc = DEVICE_GET_CLASS(dev);
> +
> +    assert(dc->bus_type
> +           ? bus && object_dynamic_cast(OBJECT(bus), dc->bus_type)
> +           : !bus);
>  
>      if (old_parent_bus) {
>          trace_qdev_update_parent_bus(dev, object_get_typename(OBJECT(dev)),

Works for me. If you've managed to fix up a large number of bad cases, let's not
allow people to go on making the same mistakes.

Reviewed-by: Mark Cave-Ayland <address@hidden>


ATB,

Mark.



reply via email to

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