mirror of https://github.com/xemu-project/xemu.git
qdev-monitor: Convert qbus_find() to Error
As usual, the conversion breaks printing explanatory messages after
the error: actual printing of the error gets delayed, so the
explanations precede rather than follow it.
Pity. Disable them for now. See also commit 7216ae3
.
While there, eliminate QERR_BUS_NOT_FOUND, and clean up unusual
spelling in the error message.
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
This commit is contained in:
parent
ed238ba2a0
commit
d282842999
|
@ -43,9 +43,6 @@ void qerror_report_err(Error *err);
|
||||||
#define QERR_BUS_NO_HOTPLUG \
|
#define QERR_BUS_NO_HOTPLUG \
|
||||||
ERROR_CLASS_GENERIC_ERROR, "Bus '%s' does not support hotplugging"
|
ERROR_CLASS_GENERIC_ERROR, "Bus '%s' does not support hotplugging"
|
||||||
|
|
||||||
#define QERR_BUS_NOT_FOUND \
|
|
||||||
ERROR_CLASS_GENERIC_ERROR, "Bus '%s' not found"
|
|
||||||
|
|
||||||
#define QERR_DEVICE_HAS_NO_MEDIUM \
|
#define QERR_DEVICE_HAS_NO_MEDIUM \
|
||||||
ERROR_CLASS_GENERIC_ERROR, "Device '%s' has no medium"
|
ERROR_CLASS_GENERIC_ERROR, "Device '%s' has no medium"
|
||||||
|
|
||||||
|
|
|
@ -288,12 +288,13 @@ static Object *qdev_get_peripheral_anon(void)
|
||||||
return dev;
|
return dev;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if 0 /* conversion from qerror_report() to error_set() broke their use */
|
||||||
static void qbus_list_bus(DeviceState *dev)
|
static void qbus_list_bus(DeviceState *dev)
|
||||||
{
|
{
|
||||||
BusState *child;
|
BusState *child;
|
||||||
const char *sep = " ";
|
const char *sep = " ";
|
||||||
|
|
||||||
error_printf("child busses at \"%s\":",
|
error_printf("child buses at \"%s\":",
|
||||||
dev->id ? dev->id : object_get_typename(OBJECT(dev)));
|
dev->id ? dev->id : object_get_typename(OBJECT(dev)));
|
||||||
QLIST_FOREACH(child, &dev->child_bus, sibling) {
|
QLIST_FOREACH(child, &dev->child_bus, sibling) {
|
||||||
error_printf("%s\"%s\"", sep, child->name);
|
error_printf("%s\"%s\"", sep, child->name);
|
||||||
|
@ -317,6 +318,7 @@ static void qbus_list_dev(BusState *bus)
|
||||||
}
|
}
|
||||||
error_printf("\n");
|
error_printf("\n");
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
static BusState *qbus_find_bus(DeviceState *dev, char *elem)
|
static BusState *qbus_find_bus(DeviceState *dev, char *elem)
|
||||||
{
|
{
|
||||||
|
@ -415,7 +417,7 @@ static BusState *qbus_find_recursive(BusState *bus, const char *name,
|
||||||
return pick;
|
return pick;
|
||||||
}
|
}
|
||||||
|
|
||||||
static BusState *qbus_find(const char *path)
|
static BusState *qbus_find(const char *path, Error **errp)
|
||||||
{
|
{
|
||||||
DeviceState *dev;
|
DeviceState *dev;
|
||||||
BusState *bus;
|
BusState *bus;
|
||||||
|
@ -433,7 +435,7 @@ static BusState *qbus_find(const char *path)
|
||||||
}
|
}
|
||||||
bus = qbus_find_recursive(sysbus_get_default(), elem, NULL);
|
bus = qbus_find_recursive(sysbus_get_default(), elem, NULL);
|
||||||
if (!bus) {
|
if (!bus) {
|
||||||
qerror_report(QERR_BUS_NOT_FOUND, elem);
|
error_setg(errp, "Bus '%s' not found", elem);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
pos = len;
|
pos = len;
|
||||||
|
@ -456,10 +458,12 @@ static BusState *qbus_find(const char *path)
|
||||||
pos += len;
|
pos += len;
|
||||||
dev = qbus_find_dev(bus, elem);
|
dev = qbus_find_dev(bus, elem);
|
||||||
if (!dev) {
|
if (!dev) {
|
||||||
qerror_report(QERR_DEVICE_NOT_FOUND, elem);
|
error_set(errp, QERR_DEVICE_NOT_FOUND, elem);
|
||||||
|
#if 0 /* conversion from qerror_report() to error_set() broke this: */
|
||||||
if (!monitor_cur_is_qmp()) {
|
if (!monitor_cur_is_qmp()) {
|
||||||
qbus_list_dev(bus);
|
qbus_list_dev(bus);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -475,14 +479,15 @@ static BusState *qbus_find(const char *path)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (dev->num_child_bus) {
|
if (dev->num_child_bus) {
|
||||||
qerror_report(ERROR_CLASS_GENERIC_ERROR,
|
error_setg(errp, "Device '%s' has multiple child buses",
|
||||||
"Device '%s' has multiple child busses", elem);
|
elem);
|
||||||
|
#if 0 /* conversion from qerror_report() to error_set() broke this: */
|
||||||
if (!monitor_cur_is_qmp()) {
|
if (!monitor_cur_is_qmp()) {
|
||||||
qbus_list_bus(dev);
|
qbus_list_bus(dev);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
} else {
|
} else {
|
||||||
qerror_report(ERROR_CLASS_GENERIC_ERROR,
|
error_setg(errp, "Device '%s' has no child bus", elem);
|
||||||
"Device '%s' has no child bus", elem);
|
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -495,17 +500,18 @@ static BusState *qbus_find(const char *path)
|
||||||
pos += len;
|
pos += len;
|
||||||
bus = qbus_find_bus(dev, elem);
|
bus = qbus_find_bus(dev, elem);
|
||||||
if (!bus) {
|
if (!bus) {
|
||||||
qerror_report(QERR_BUS_NOT_FOUND, elem);
|
error_setg(errp, "Bus '%s' not found", elem);
|
||||||
|
#if 0 /* conversion from qerror_report() to error_set() broke this: */
|
||||||
if (!monitor_cur_is_qmp()) {
|
if (!monitor_cur_is_qmp()) {
|
||||||
qbus_list_bus(dev);
|
qbus_list_bus(dev);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (qbus_is_full(bus)) {
|
if (qbus_is_full(bus)) {
|
||||||
qerror_report(ERROR_CLASS_GENERIC_ERROR, "Bus '%s' is full",
|
error_setg(errp, "Bus '%s' is full", path);
|
||||||
path);
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
return bus;
|
return bus;
|
||||||
|
@ -536,8 +542,10 @@ DeviceState *qdev_device_add(QemuOpts *opts)
|
||||||
/* find bus */
|
/* find bus */
|
||||||
path = qemu_opt_get(opts, "bus");
|
path = qemu_opt_get(opts, "bus");
|
||||||
if (path != NULL) {
|
if (path != NULL) {
|
||||||
bus = qbus_find(path);
|
bus = qbus_find(path, &err);
|
||||||
if (!bus) {
|
if (!bus) {
|
||||||
|
qerror_report_err(err);
|
||||||
|
error_free(err);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
if (!object_dynamic_cast(OBJECT(bus), dc->bus_type)) {
|
if (!object_dynamic_cast(OBJECT(bus), dc->bus_type)) {
|
||||||
|
|
Loading…
Reference in New Issue