From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:34260) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TdRE2-0008En-Ax for qemu-devel@nongnu.org; Tue, 27 Nov 2012 14:53:47 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TdRDw-0000LG-C6 for qemu-devel@nongnu.org; Tue, 27 Nov 2012 14:53:46 -0500 Received: from greensocs.com ([87.106.252.221]:57652 helo=s15328186.onlinehome-server.info) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TdRDw-0000LB-5S for qemu-devel@nongnu.org; Tue, 27 Nov 2012 14:53:40 -0500 From: fred.konrad@greensocs.com Date: Tue, 27 Nov 2012 20:53:35 +0100 Message-Id: <1354046015-12836-3-git-send-email-fred.konrad@greensocs.com> In-Reply-To: <1354046015-12836-1-git-send-email-fred.konrad@greensocs.com> References: <1354046015-12836-1-git-send-email-fred.konrad@greensocs.com> Subject: [Qemu-devel] [RFC PATCH v3 2/2] qbus : add a maximum device. List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: peter.maydell@linaro.org, aliguori@us.ibm.com, e.voevodin@samsung.com, mark.burton@greensocs.com, stefanha@redhat.com, cornelia.huck@de.ibm.com, afaerber@suse.de, fred.konrad@greensocs.com From: KONRAD Frederic 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 --- 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