Allow BusClass implementation to have their own is_full() handler. Use it in qbus_is_full().
Signed-off-by: Philippe Mathieu-Daudé <[email protected]> --- include/hw/core/qdev.h | 5 +++++ system/qdev-monitor.c | 3 +++ 2 files changed, 8 insertions(+) diff --git a/include/hw/core/qdev.h b/include/hw/core/qdev.h index e1476223411..c1c17bd6f2b 100644 --- a/include/hw/core/qdev.h +++ b/include/hw/core/qdev.h @@ -345,6 +345,11 @@ struct BusClass { */ bool (*check_address)(BusState *bus, DeviceState *dev, Error **errp); + /* + * Return whether more devices can be plugged into @bus. + */ + bool (*is_full)(const BusState *bus); + BusRealize realize; BusUnrealize unrealize; diff --git a/system/qdev-monitor.c b/system/qdev-monitor.c index 00fed791cce..496850bd8ed 100644 --- a/system/qdev-monitor.c +++ b/system/qdev-monitor.c @@ -454,6 +454,9 @@ static inline bool qbus_is_full(BusState *bus) return true; } bus_class = BUS_GET_CLASS(bus); + if (bus_class->is_full && bus_class->is_full(bus)) { + return true; + } return bus_class->max_dev && bus->num_children >= bus_class->max_dev; } -- 2.53.0
