[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 5/7] qbus_find_recursive(): terminate search by name
From: |
Laszlo Ersek |
Subject: |
[Qemu-devel] [PATCH 5/7] qbus_find_recursive(): terminate search by name in case of fatal error |
Date: |
Fri, 1 Feb 2013 18:38:17 +0100 |
Use an Error to communicate the "stop the search" message.
Signed-off-by: Laszlo Ersek <address@hidden>
---
hw/qdev-monitor.c | 24 ++++++++++++++++--------
1 files changed, 16 insertions(+), 8 deletions(-)
diff --git a/hw/qdev-monitor.c b/hw/qdev-monitor.c
index 284dafa..83540fc 100644
--- a/hw/qdev-monitor.c
+++ b/hw/qdev-monitor.c
@@ -288,7 +288,7 @@ static DeviceState *qbus_find_dev(BusState *bus, char *elem)
}
static BusState *qbus_find_recursive(BusState *bus, const char *name,
- const char *type)
+ const char *type, Error **errp)
{
BusChild *kid;
@@ -303,8 +303,7 @@ static BusState *qbus_find_recursive(BusState *bus, const
char *name,
/* bus is full -- fatal error for search by name */
if (name != NULL) {
- qerror_report(ERROR_CLASS_GENERIC_ERROR, "Bus '%s' is full",
- bus->name);
+ error_setg(errp, "Bus '%s' is full", bus->name);
return NULL;
}
}
@@ -316,8 +315,8 @@ static BusState *qbus_find_recursive(BusState *bus, const
char *name,
QLIST_FOREACH(child, &dev->child_bus, sibling) {
BusState *ret;
- ret = qbus_find_recursive(child, name, type);
- if (ret) {
+ ret = qbus_find_recursive(child, name, type, errp);
+ if (ret || error_is_set(errp)) {
return ret;
}
}
@@ -337,13 +336,20 @@ static BusState *qbus_find(const char *path)
bus = sysbus_get_default();
pos = 0;
} else {
+ Error *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);
+ bus = qbus_find_recursive(sysbus_get_default(), elem, NULL, &err);
if (!bus) {
- qerror_report(QERR_BUS_NOT_FOUND, elem);
+ if (error_is_set(&err)) {
+ qerror_report_err(err);
+ error_free(err);
+ } else {
+ qerror_report(QERR_BUS_NOT_FOUND, elem);
+ }
return NULL;
}
pos = len;
@@ -458,8 +464,10 @@ DeviceState *qdev_device_add(QemuOpts *opts)
return NULL;
}
} else {
- bus = qbus_find_recursive(sysbus_get_default(), NULL, k->bus_type);
+ bus = qbus_find_recursive(sysbus_get_default(), NULL, k->bus_type,
+ &local_err);
if (!bus) {
+ assert(!error_is_set(&local_err));
qerror_report(QERR_NO_BUS_FOR_DEVICE,
k->bus_type, driver);
return NULL;
--
1.7.1
- [Qemu-devel] [PATCH 3/7] qdev_prop_parse(): report errors via Error, (continued)
[Qemu-devel] [PATCH 1/7] remove some trailing whitespace, Laszlo Ersek, 2013/02/01
[Qemu-devel] [PATCH 6/7] qbus_find(): report errors via Error, Laszlo Ersek, 2013/02/01
[Qemu-devel] [PATCH 5/7] qbus_find_recursive(): terminate search by name in case of fatal error,
Laszlo Ersek <=
[Qemu-devel] [PATCH 7/7] qdev_device_add(): report errors with Error, Laszlo Ersek, 2013/02/01
Re: [Qemu-devel] [PATCH 0/7] propagate Errors to do_device_add(), Luiz Capitulino, 2013/02/04