From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:58214) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TqOzn-0007jH-QZ for qemu-devel@nongnu.org; Wed, 02 Jan 2013 09:08:42 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TqOzk-0004PZ-EA for qemu-devel@nongnu.org; Wed, 02 Jan 2013 09:08:39 -0500 Received: from e32.co.us.ibm.com ([32.97.110.150]:54157) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TqOzk-0004Ok-81 for qemu-devel@nongnu.org; Wed, 02 Jan 2013 09:08:36 -0500 Received: from /spool/local by e32.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 2 Jan 2013 07:08:34 -0700 Received: from d03relay04.boulder.ibm.com (d03relay04.boulder.ibm.com [9.17.195.106]) by d03dlp01.boulder.ibm.com (Postfix) with ESMTP id E69E0C40002 for ; Wed, 2 Jan 2013 07:08:22 -0700 (MST) Received: from d03av05.boulder.ibm.com (d03av05.boulder.ibm.com [9.17.195.85]) by d03relay04.boulder.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id r02E8WL1297820 for ; Wed, 2 Jan 2013 07:08:32 -0700 Received: from d03av05.boulder.ibm.com (loopback [127.0.0.1]) by d03av05.boulder.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id r02E8RPn006721 for ; Wed, 2 Jan 2013 07:08:30 -0700 From: Anthony Liguori In-Reply-To: <1355910821-21302-2-git-send-email-fred.konrad@greensocs.com> References: <1355910821-21302-1-git-send-email-fred.konrad@greensocs.com> <1355910821-21302-2-git-send-email-fred.konrad@greensocs.com> Date: Wed, 02 Jan 2013 08:08:18 -0600 Message-ID: <87obh7d6el.fsf@codemonkey.ws> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Subject: Re: [Qemu-devel] [RFC PATCH V8 01/15] qdev : add a maximum device allowed field for the bus. List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: fred.konrad@greensocs.com, qemu-devel@nongnu.org Cc: peter.maydell@linaro.org, e.voevodin@samsung.com, mark.burton@greensocs.com, agraf@suse.de, stefanha@redhat.com, cornelia.huck@de.ibm.com, afaerber@suse.de fred.konrad@greensocs.com writes: > From: KONRAD Frederic > > Add a max_dev field to BusState to specify the maximum amount of devices allowed > on the bus ( have no effect if max_dev=0 ) > > Signed-off-by: KONRAD Frederic > --- > hw/qdev-core.h | 2 ++ > hw/qdev-monitor.c | 11 +++++++++++ > 2 files changed, 13 insertions(+) > > diff --git a/hw/qdev-core.h b/hw/qdev-core.h > index d672cca..af909b9 100644 > --- a/hw/qdev-core.h > +++ b/hw/qdev-core.h > @@ -104,6 +104,8 @@ struct BusState { > const char *name; > int allow_hotplug; > int max_index; > + /* maximum devices allowed on the bus, 0 : no limit. */ > + 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 a1b4d6a..7a9d275 100644 > --- a/hw/qdev-monitor.c > +++ b/hw/qdev-monitor.c > @@ -292,6 +292,17 @@ static BusState *qbus_find_recursive(BusState *bus, const char *name, > if (bus_typename && !object_dynamic_cast(OBJECT(bus), bus_typename)) { > match = 0; > } > + if ((bus->max_dev != 0) && (bus->max_dev <= bus->max_index)) { > + if (name != NULL) { > + /* bus was explicitly specified : return an error. */ > + qerror_report(ERROR_CLASS_GENERIC_ERROR, "Bus '%s' is full", > + bus->name); > + return NULL; > + } else { > + /* bus was not specified : try to find another one. */ > + match = 0; > + } > + } > if (match) { > return bus; > } Nice change, but I wonder if this should be a class property instead of an object property? Would different objects of the same class ever set this differently? Regards, Anthony Liguori > -- > 1.7.11.7