[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH] qdev/core: Can not replug device on bus that al
Re: [Qemu-devel] [PATCH] qdev/core: Can not replug device on bus that allows one device
Tue, 11 Dec 2018 16:23:03 +0100
On Mon, 10 Dec 2018 14:14:14 -0500
Tony Krowiak <address@hidden> wrote:
> If the maximum number of devices allowed on a bus is 1 and a device
> which is plugged into the bus is subsequently unplugged, attempting to replug
> the device fails with error "Bus 'xxx' does not support hotplugging".
> The "error" is detected in the qbus_is_full(BusState *bus) function
> (qdev_monitor.c) because bus->max_index >= bus_class->max_dev. The
> root of the problem is that the bus->max_index is not decremented when a
> is unplugged from the bus. This patch fixes that problem.
> Signed-off-by: Tony Krowiak <address@hidden>
> hw/core/qdev.c | 2 ++
> 1 file changed, 2 insertions(+)
> diff --git a/hw/core/qdev.c b/hw/core/qdev.c
> index 6b3cc55b27c2..b35b0bf27925 100644
> --- a/hw/core/qdev.c
> +++ b/hw/core/qdev.c
> @@ -59,6 +59,8 @@ static void bus_remove_child(BusState *bus, DeviceState
> snprintf(name, sizeof(name), "child[%d]", kid->index);
> QTAILQ_REMOVE(&bus->children, kid, sibling);
> + bus->max_index--;
that might cause problem when bus is allowed to has more than 1 device
and unplugged device is not the last one.
In that case bus_add_child() might create a child with duplicate name.
> /* This gives back ownership of kid->child back to us. */
> object_property_del(OBJECT(bus), name, NULL);