From patchwork Tue Nov 27 19:53:35 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: fred.konrad@greensocs.com X-Patchwork-Id: 202287 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 024A02C008F for ; Wed, 28 Nov 2012 06:54:04 +1100 (EST) Received: from localhost ([::1]:46656 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TdREI-0000Kr-84 for incoming@patchwork.ozlabs.org; Tue, 27 Nov 2012 14:54:02 -0500 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 Received: from localhost (unknown [127.0.0.1]) by s15328186.onlinehome-server.info (Postfix) with ESMTP id 8E55540F4C8; Tue, 27 Nov 2012 19:53:39 +0000 (UTC) Received: from s15328186.onlinehome-server.info ([127.0.0.1]) by localhost (s15328186.onlinehome-server.info [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id vcx50INfyex6; Tue, 27 Nov 2012 20:53:39 +0100 (CET) Received: by s15328186.onlinehome-server.info (Postfix, from userid 491) id 5624040F4C9; Tue, 27 Nov 2012 20:53:39 +0100 (CET) Received: from localhost.localdomain (47.155.72.86.rev.sfr.net [86.72.155.47]) by s15328186.onlinehome-server.info (Postfix) with ESMTPSA id 81C4840F4C8; Tue, 27 Nov 2012 20:53:38 +0100 (CET) From: fred.konrad@greensocs.com To: qemu-devel@nongnu.org Date: Tue, 27 Nov 2012 20:53:35 +0100 Message-Id: <1354046015-12836-3-git-send-email-fred.konrad@greensocs.com> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1354046015-12836-1-git-send-email-fred.konrad@greensocs.com> References: <1354046015-12836-1-git-send-email-fred.konrad@greensocs.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 87.106.252.221 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 Subject: [Qemu-devel] [RFC PATCH v3 2/2] qbus : add a maximum device. X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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; }