From: KONRAD Frederic <fred.kon...@greensocs.com> Only one device can be connected to virtio-bus. This patch add a field max_dev which is : * the maximum amount of devices connected on the bus ( when * max_dev!=0 ). * have no effect ( when max_dev=0 ).
The function qbus_find_recursive is modified : * to return a non full bus when the "bus=" option is not present. * to give an error when the "bus=" option is pointing a full bus. Signed-off-by: KONRAD Frederic <fred.kon...@greensocs.com> --- hw/qdev-core.h | 1 + hw/qdev-monitor.c | 12 ++++++++++++ 2 files changed, 13 insertions(+), 0 deletions(-) diff --git a/hw/qdev-core.h b/hw/qdev-core.h index fce9e22..15161f7 100644 --- a/hw/qdev-core.h +++ b/hw/qdev-core.h @@ -118,6 +118,7 @@ struct BusState { bool qom_allocated; bool glib_allocated; int max_index; + int max_dev; QTAILQ_HEAD(ChildrenHead, BusChild) children; QLIST_ENTRY(BusState) sibling; }; diff --git a/hw/qdev-monitor.c b/hw/qdev-monitor.c index 479eecd..66d8e59 100644 --- a/hw/qdev-monitor.c +++ b/hw/qdev-monitor.c @@ -293,6 +293,18 @@ static BusState *qbus_find_recursive(BusState *bus, const char *name, (strcmp(object_get_typename(OBJECT(bus)), bus_typename) != 0)) { match = 0; } + + /* Check if max_dev is reached */ + if ((bus->max_dev != 0) && (bus->max_dev <= bus->max_index)) { + if (name != NULL) { + error_report("maximum amount of devices reached for %s\n", + bus->name); + return NULL; + } else { + match = 0; + } + } + if (match) { return bus; } -- 1.7.1