From: "Andreas Färber" <afaerber@suse.de>
To: qemu-devel@nongnu.org
Cc: ehabkost@redhat.com, armbru@redhat.com, lcapitulino@redhat.com,
anthony@codemonkey.ws, imammedo@redhat.com, pbonzini@redhat.com,
"Andreas Färber" <afaerber@suse.de>
Subject: [Qemu-devel] [PATCH] qdev: Fix device_add bus assumptions
Date: Tue, 16 Apr 2013 03:50:21 +0200 [thread overview]
Message-ID: <1366077021-28882-1-git-send-email-afaerber@suse.de> (raw)
Drop an unreachable fallback bus assignment to SysBus.
If no ,bus= is specified, only search busses recursively for bus type if
the DeviceClass has a bus_type specified. Handle resulting NULL cases.
Signed-off-by: Andreas Färber <afaerber@suse.de>
---
qdev-monitor.c | 16 ++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/qdev-monitor.c b/qdev-monitor.c
index 9a78ccf..73d7946 100644
--- a/qdev-monitor.c
+++ b/qdev-monitor.c
@@ -18,6 +18,7 @@
*/
#include "hw/qdev.h"
+#include "hw/sysbus.h"
#include "monitor/monitor.h"
#include "monitor/qdev.h"
#include "qmp-commands.h"
@@ -415,7 +416,7 @@ DeviceState *qdev_device_add(QemuOpts *opts)
DeviceClass *k;
const char *driver, *path, *id;
DeviceState *qdev;
- BusState *bus;
+ BusState *bus = NULL;
driver = qemu_opt_get(opts, "driver");
if (!driver) {
@@ -453,7 +454,7 @@ DeviceState *qdev_device_add(QemuOpts *opts)
driver, object_get_typename(OBJECT(bus)));
return NULL;
}
- } else {
+ } else if (k->bus_type != NULL) {
bus = qbus_find_recursive(sysbus_get_default(), NULL, k->bus_type);
if (!bus) {
qerror_report(QERR_NO_BUS_FOR_DEVICE,
@@ -461,18 +462,17 @@ DeviceState *qdev_device_add(QemuOpts *opts)
return NULL;
}
}
- if (qdev_hotplug && !bus->allow_hotplug) {
+ if (qdev_hotplug && bus && !bus->allow_hotplug) {
qerror_report(QERR_BUS_NO_HOTPLUG, bus->name);
return NULL;
}
- if (!bus) {
- bus = sysbus_get_default();
- }
-
/* create device, set properties */
qdev = DEVICE(object_new(driver));
- qdev_set_parent_bus(qdev, bus);
+
+ if (bus) {
+ qdev_set_parent_bus(qdev, bus);
+ }
id = qemu_opts_id(opts);
if (id) {
--
1.8.1.4
next reply other threads:[~2013-04-16 1:50 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-04-16 1:50 Andreas Färber [this message]
2013-04-18 8:41 ` [Qemu-devel] [PATCH] qdev: Fix device_add bus assumptions Igor Mammedov
2013-04-18 9:01 ` Igor Mammedov
2013-04-22 11:51 ` Libaiqing
2013-04-22 13:27 ` Andreas Färber
2013-04-22 13:54 ` KONRAD Frédéric
2013-04-22 14:02 ` Andreas Färber
2013-04-22 14:15 ` KONRAD Frédéric
2013-04-22 14:22 ` Andreas Färber
2013-04-22 15:11 ` KONRAD Frédéric
2013-04-22 13:35 ` Andreas Färber
2013-04-22 18:36 ` Anthony Liguori
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=1366077021-28882-1-git-send-email-afaerber@suse.de \
--to=afaerber@suse.de \
--cc=anthony@codemonkey.ws \
--cc=armbru@redhat.com \
--cc=ehabkost@redhat.com \
--cc=imammedo@redhat.com \
--cc=lcapitulino@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
/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).