From: Laszlo Ersek <lersek@redhat.com>
To: lcapitulino@redhat.com, qemu-devel@nongnu.org
Subject: [Qemu-devel] [PATCH 6/7] qbus_find(): report errors via Error
Date: Fri, 1 Feb 2013 18:38:18 +0100 [thread overview]
Message-ID: <1359740299-27968-7-git-send-email-lersek@redhat.com> (raw)
In-Reply-To: <1359740299-27968-1-git-send-email-lersek@redhat.com>
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
---
hw/qdev-monitor.c | 29 +++++++++++++++--------------
1 files changed, 15 insertions(+), 14 deletions(-)
diff --git a/hw/qdev-monitor.c b/hw/qdev-monitor.c
index 83540fc..0c01b04 100644
--- a/hw/qdev-monitor.c
+++ b/hw/qdev-monitor.c
@@ -324,7 +324,7 @@ static BusState *qbus_find_recursive(BusState *bus, const char *name,
return NULL;
}
-static BusState *qbus_find(const char *path)
+static BusState *qbus_find(const char *path, Error **errp)
{
DeviceState *dev;
BusState *bus;
@@ -336,20 +336,19 @@ static BusState *qbus_find(const char *path)
bus = sysbus_get_default();
pos = 0;
} else {
- Error *err = NULL;
+ Error *find_err = NULL;
if (sscanf(path, "%127[^/]%n", elem, &len) != 1) {
assert(!path[0]);
elem[0] = len = 0;
}
- bus = qbus_find_recursive(sysbus_get_default(), elem, NULL, &err);
+ bus = qbus_find_recursive(sysbus_get_default(), elem, NULL, &find_err);
if (!bus) {
- if (error_is_set(&err)) {
- qerror_report_err(err);
- error_free(err);
- } else {
- qerror_report(QERR_BUS_NOT_FOUND, elem);
- }
+ Error *not_found;
+
+ error_set(¬_found, QERR_BUS_NOT_FOUND, elem);
+ error_propagate(errp, find_err);
+ error_propagate(errp, not_found);
return NULL;
}
pos = len;
@@ -372,7 +371,7 @@ static BusState *qbus_find(const char *path)
pos += len;
dev = qbus_find_dev(bus, elem);
if (!dev) {
- qerror_report(QERR_DEVICE_NOT_FOUND, elem);
+ error_set(errp, QERR_DEVICE_NOT_FOUND, elem);
if (!monitor_cur_is_qmp()) {
qbus_list_dev(bus);
}
@@ -388,12 +387,12 @@ static BusState *qbus_find(const char *path)
* one child bus accept it nevertheless */
switch (dev->num_child_bus) {
case 0:
- qerror_report(QERR_DEVICE_NO_BUS, elem);
+ error_set(errp, QERR_DEVICE_NO_BUS, elem);
return NULL;
case 1:
return QLIST_FIRST(&dev->child_bus);
default:
- qerror_report(QERR_DEVICE_MULTIPLE_BUSSES, elem);
+ error_set(errp, QERR_DEVICE_MULTIPLE_BUSSES, elem);
if (!monitor_cur_is_qmp()) {
qbus_list_bus(dev);
}
@@ -409,7 +408,7 @@ static BusState *qbus_find(const char *path)
pos += len;
bus = qbus_find_bus(dev, elem);
if (!bus) {
- qerror_report(QERR_BUS_NOT_FOUND, elem);
+ error_set(errp, QERR_BUS_NOT_FOUND, elem);
if (!monitor_cur_is_qmp()) {
qbus_list_bus(dev);
}
@@ -454,8 +453,10 @@ DeviceState *qdev_device_add(QemuOpts *opts)
/* find bus */
path = qemu_opt_get(opts, "bus");
if (path != NULL) {
- bus = qbus_find(path);
+ bus = qbus_find(path, &local_err);
if (!bus) {
+ qerror_report_err(local_err);
+ error_free(local_err);
return NULL;
}
if (!object_dynamic_cast(OBJECT(bus), k->bus_type)) {
--
1.7.1
next prev parent reply other threads:[~2013-02-01 17:36 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-02-01 17:38 [Qemu-devel] [PATCH 0/7] propagate Errors to do_device_add() Laszlo Ersek
2013-02-01 17:38 ` [Qemu-devel] [PATCH 1/7] remove some trailing whitespace Laszlo Ersek
2013-02-01 17:38 ` [Qemu-devel] [PATCH 2/7] do_device_add(): look up "device" opts list with qemu_find_opts_err() Laszlo Ersek
2013-02-01 17:38 ` [Qemu-devel] [PATCH 3/7] qdev_prop_parse(): report errors via Error Laszlo Ersek
2013-02-01 17:38 ` [Qemu-devel] [PATCH 4/7] qbus_find_recursive(): reorganize Laszlo Ersek
2013-02-01 17:38 ` [Qemu-devel] [PATCH 5/7] qbus_find_recursive(): terminate search by name in case of fatal error Laszlo Ersek
2013-02-01 17:38 ` Laszlo Ersek [this message]
2013-02-01 17:38 ` [Qemu-devel] [PATCH 7/7] qdev_device_add(): report errors with Error Laszlo Ersek
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=1359740299-27968-7-git-send-email-lersek@redhat.com \
--to=lersek@redhat.com \
--cc=lcapitulino@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).