Message ID | 1433789877-6950-6-git-send-email-armbru@redhat.com |
---|---|
State | New |
Headers | show |
On 06/08/2015 12:57 PM, Markus Armbruster wrote: > 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. Could we add some sort of error_append_hmp_hint() that adds additional messages to an existing error object, for use when the error will be printed via HMP but is a no-op for QMP? (and make it callable more than once, since qbus_list_dev() uses error_printf() in that role more than once) But that can be a later patch, this one is fine as-is for following existing practice. > > Signed-off-by: Markus Armbruster <armbru@redhat.com> > --- > include/qapi/qmp/qerror.h | 3 --- > qdev-monitor.c | 30 +++++++++++++++++++----------- > 2 files changed, 19 insertions(+), 14 deletions(-) > > diff --git a/include/qapi/qmp/qerror.h b/include/qapi/qmp/qerror.h > index e567339..6468e40 100644 > --- a/include/qapi/qmp/qerror.h > +++ b/include/qapi/qmp/qerror.h > @@ -43,9 +43,6 @@ void qerror_report_err(Error *err); > #define QERR_BUS_NO_HOTPLUG \ > ERROR_CLASS_GENERIC_ERROR, "Bus '%s' does not support hotplugging" > > -#define QERR_BUS_NOT_FOUND \ > - ERROR_CLASS_GENERIC_ERROR, "Bus '%s' not found" Might want to mention one less baroque macro in qerror.h in the commit message as an intentional part of the conversion. > @@ -475,14 +479,15 @@ static BusState *qbus_find(const char *path) > break; > } > if (dev->num_child_bus) { > - qerror_report(ERROR_CLASS_GENERIC_ERROR, > - "Device '%s' has multiple child busses", elem); > + error_setg(errp, "Device '%s' has multiple child busses", Stupid spell-check on my mailer is flagging 'busses' as a typo, even though dictionary.com says both spellings are acceptable. Other sources prefer 'buses' and say 'busses' is out of favor: http://grammarist.com/spelling/buses-busses/ You could always skirt the confusion by creative wording like "has multiple bus children". But it is a pre-existing issue [if an issue at all], so I don't care enough to make it hold up this patch. Reviewed-by: Eric Blake <eblake@redhat.com>
Eric Blake <eblake@redhat.com> writes: > On 06/08/2015 12:57 PM, Markus Armbruster wrote: >> 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. > > Could we add some sort of error_append_hmp_hint() that adds additional > messages to an existing error object, for use when the error will be > printed via HMP but is a no-op for QMP? (and make it callable more than > once, since qbus_list_dev() uses error_printf() in that role more than once) Should work. Should get its own series, of course. Volunteer welcome :) > But that can be a later patch, this one is fine as-is for following > existing practice. Agree. >> Signed-off-by: Markus Armbruster <armbru@redhat.com> >> --- >> include/qapi/qmp/qerror.h | 3 --- >> qdev-monitor.c | 30 +++++++++++++++++++----------- >> 2 files changed, 19 insertions(+), 14 deletions(-) >> >> diff --git a/include/qapi/qmp/qerror.h b/include/qapi/qmp/qerror.h >> index e567339..6468e40 100644 >> --- a/include/qapi/qmp/qerror.h >> +++ b/include/qapi/qmp/qerror.h >> @@ -43,9 +43,6 @@ void qerror_report_err(Error *err); >> #define QERR_BUS_NO_HOTPLUG \ >> ERROR_CLASS_GENERIC_ERROR, "Bus '%s' does not support hotplugging" >> >> -#define QERR_BUS_NOT_FOUND \ >> - ERROR_CLASS_GENERIC_ERROR, "Bus '%s' not found" > > Might want to mention one less baroque macro in qerror.h in the commit > message as an intentional part of the conversion. Could append: While there, eliminate QERR_BUS_NOT_FOUND. >> @@ -475,14 +479,15 @@ static BusState *qbus_find(const char *path) >> break; >> } >> if (dev->num_child_bus) { >> - qerror_report(ERROR_CLASS_GENERIC_ERROR, >> - "Device '%s' has multiple child busses", elem); >> + error_setg(errp, "Device '%s' has multiple child busses", > > Stupid spell-check on my mailer is flagging 'busses' as a typo, even > though dictionary.com says both spellings are acceptable. Other sources > prefer 'buses' and say 'busses' is out of favor: > http://grammarist.com/spelling/buses-busses/ If I have to respin anyway, I can fold in s/busses/buses/, and amend While there, eliminate QERR_BUS_NOT_FOUND, and clean up unusual spelling in the error message. > You could always skirt the confusion by creative wording like "has > multiple bus children". Nah, we just spell like the dictionary says we should. > But it is a pre-existing issue [if an issue at > all], so I don't care enough to make it hold up this patch. > > Reviewed-by: Eric Blake <eblake@redhat.com> Thanks!
diff --git a/include/qapi/qmp/qerror.h b/include/qapi/qmp/qerror.h index e567339..6468e40 100644 --- a/include/qapi/qmp/qerror.h +++ b/include/qapi/qmp/qerror.h @@ -43,9 +43,6 @@ void qerror_report_err(Error *err); #define QERR_BUS_NO_HOTPLUG \ 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 \ ERROR_CLASS_GENERIC_ERROR, "Device '%s' has no medium" diff --git a/qdev-monitor.c b/qdev-monitor.c index a54c368..f8876ef 100644 --- a/qdev-monitor.c +++ b/qdev-monitor.c @@ -288,6 +288,7 @@ static Object *qdev_get_peripheral_anon(void) return dev; } +#if 0 /* conversion from qerror_report() to error_set() broke their use */ static void qbus_list_bus(DeviceState *dev) { BusState *child; @@ -317,6 +318,7 @@ static void qbus_list_dev(BusState *bus) } error_printf("\n"); } +#endif 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; } -static BusState *qbus_find(const char *path) +static BusState *qbus_find(const char *path, Error **errp) { DeviceState *dev; BusState *bus; @@ -433,7 +435,7 @@ static BusState *qbus_find(const char *path) } bus = qbus_find_recursive(sysbus_get_default(), elem, NULL); if (!bus) { - qerror_report(QERR_BUS_NOT_FOUND, elem); + error_setg(errp, "Bus '%s' not found", elem); return NULL; } pos = len; @@ -456,10 +458,12 @@ 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 0 /* conversion from qerror_report() to error_set() broke this: */ if (!monitor_cur_is_qmp()) { qbus_list_dev(bus); } +#endif return NULL; } @@ -475,14 +479,15 @@ static BusState *qbus_find(const char *path) break; } if (dev->num_child_bus) { - qerror_report(ERROR_CLASS_GENERIC_ERROR, - "Device '%s' has multiple child busses", elem); + error_setg(errp, "Device '%s' has multiple child busses", + elem); +#if 0 /* conversion from qerror_report() to error_set() broke this: */ if (!monitor_cur_is_qmp()) { qbus_list_bus(dev); } +#endif } else { - qerror_report(ERROR_CLASS_GENERIC_ERROR, - "Device '%s' has no child bus", elem); + error_setg(errp, "Device '%s' has no child bus", elem); } return NULL; } @@ -495,17 +500,18 @@ 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_setg(errp, "Bus '%s' not found", elem); +#if 0 /* conversion from qerror_report() to error_set() broke this: */ if (!monitor_cur_is_qmp()) { qbus_list_bus(dev); } +#endif return NULL; } } if (qbus_is_full(bus)) { - qerror_report(ERROR_CLASS_GENERIC_ERROR, "Bus '%s' is full", - path); + error_setg(errp, "Bus '%s' is full", path); return NULL; } return bus; @@ -536,8 +542,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, &err); if (!bus) { + qerror_report_err(err); + error_free(err); return NULL; } if (!object_dynamic_cast(OBJECT(bus), dc->bus_type)) {
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. Signed-off-by: Markus Armbruster <armbru@redhat.com> --- include/qapi/qmp/qerror.h | 3 --- qdev-monitor.c | 30 +++++++++++++++++++----------- 2 files changed, 19 insertions(+), 14 deletions(-)