From: fred.konrad@greensocs.com
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
Subject: [Qemu-devel] [RFC PATCH v3 2/2] qbus : add a maximum device.
Date: Tue, 27 Nov 2012 20:53:35 +0100 [thread overview]
Message-ID: <1354046015-12836-3-git-send-email-fred.konrad@greensocs.com> (raw)
In-Reply-To: <1354046015-12836-1-git-send-email-fred.konrad@greensocs.com>
From: KONRAD Frederic <fred.konrad@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.konrad@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
prev parent reply other threads:[~2012-11-27 19:53 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-11-27 19:53 [Qemu-devel] [RFC PATCH v3 0/2] Introduce virtio-bus fred.konrad
2012-11-27 19:53 ` [Qemu-devel] [RFC PATCH v3 1/2] virtio-bus : " fred.konrad
2012-11-27 19:53 ` fred.konrad [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1354046015-12836-3-git-send-email-fred.konrad@greensocs.com \
--to=fred.konrad@greensocs.com \
--cc=afaerber@suse.de \
--cc=aliguori@us.ibm.com \
--cc=cornelia.huck@de.ibm.com \
--cc=e.voevodin@samsung.com \
--cc=mark.burton@greensocs.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
--cc=stefanha@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).