@@ -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;
};
@@ -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;
}