[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH v2 06/15] set_property(): extend signature with
From: |
Luiz Capitulino |
Subject: |
Re: [Qemu-devel] [PATCH v2 06/15] set_property(): extend signature with Error |
Date: |
Thu, 7 Feb 2013 16:03:59 -0200 |
On Thu, 7 Feb 2013 15:18:41 -0200
Eduardo Habkost <address@hidden> wrote:
> On Tue, Feb 05, 2013 at 09:39:19PM +0100, Laszlo Ersek wrote:
> >
> > Signed-off-by: Laszlo Ersek <address@hidden>
> > ---
> > hw/qdev-monitor.c | 21 ++++++++++++++++-----
> > 1 files changed, 16 insertions(+), 5 deletions(-)
> >
> > diff --git a/hw/qdev-monitor.c b/hw/qdev-monitor.c
> > index cf96046..545e66c 100644
> > --- a/hw/qdev-monitor.c
> > +++ b/hw/qdev-monitor.c
> > @@ -100,9 +100,14 @@ static void qdev_print_devinfo(ObjectClass *klass,
> > void *opaque)
> > error_printf("\n");
> > }
> >
> > +typedef struct {
> > + DeviceState *dev;
> > + Error **errp;
> > +} PropertyContext;
> > +
> > static int set_property(const char *name, const char *value, void *opaque)
> > {
> > - DeviceState *dev = opaque;
> > + PropertyContext *ctx = opaque;
> > Error *err = NULL;
> >
> > if (strcmp(name, "driver") == 0)
> > @@ -110,7 +115,7 @@ static int set_property(const char *name, const char
> > *value, void *opaque)
> > if (strcmp(name, "bus") == 0)
> > return 0;
> >
> > - qdev_prop_parse(dev, name, value, &err);
> > + qdev_prop_parse(ctx->dev, name, value, &err);
> > if (error_is_set(&err)) {
> > qerror_report_err(err);
> > error_free(err);
> > @@ -481,10 +486,16 @@ DeviceState *qdev_device_add(QemuOpts *opts)
> > if (id) {
> > qdev->id = id;
> > }
> > - if (qemu_opt_foreach(opts, set_property, qdev, 1) != 0) {
> > - qdev_free(qdev);
> > - return NULL;
> > +
> > + {
> > + PropertyContext ctx = { .dev = qdev, .errp = NULL };
> > +
> > + if (qemu_opt_foreach(opts, set_property, &ctx, 1) != 0) {
>
> What about redefining qemu_opt_loopfunc to accept an Error parameter?
>
> qemu_opt_foreach() is used in only 4 places in the whole QEMU code, and
> it already has code to abort on error (but using the function return
> value instead of an Error** paramater).
He would have to convert the users too, which would be very welcome,
but it's out of the scope of this series IMO (but would be fine as
a first series to this work).
>
>
>
> > + qdev_free(qdev);
> > + return NULL;
> > + }
> > }
> > +
> > if (qdev->id) {
> > object_property_add_child(qdev_get_peripheral(), qdev->id,
> > OBJECT(qdev), NULL);
> > --
> > 1.7.1
> >
> >
>
- [Qemu-devel] [PATCH v2 03/15] qdev_prop_parse(): extend signature with Error, (continued)
- [Qemu-devel] [PATCH v2 03/15] qdev_prop_parse(): extend signature with Error, Laszlo Ersek, 2013/02/05
- [Qemu-devel] [PATCH v2 04/15] qdev_prop_parse(): push error handling to callers, Laszlo Ersek, 2013/02/05
- [Qemu-devel] [PATCH v2 05/15] qdev_prop_parse(): change return type to void, Laszlo Ersek, 2013/02/05
- [Qemu-devel] [PATCH v2 06/15] set_property(): extend signature with Error, Laszlo Ersek, 2013/02/05
- [Qemu-devel] [PATCH v2 07/15] set_property(): push error handling to callers, Laszlo Ersek, 2013/02/05
- [Qemu-devel] [PATCH v2 12/15] qbus_find(): propagate error handling / consumption to callers, Laszlo Ersek, 2013/02/05
- [Qemu-devel] [PATCH v2 11/15] qbus_find(): extend signature with Error, Laszlo Ersek, 2013/02/05
- [Qemu-devel] [PATCH v2 15/15] qdev_device_add(): beautify "driver not found" error message, Laszlo Ersek, 2013/02/05
- [Qemu-devel] [PATCH v2 09/15] qbus_find_recursive(): extend signature with Error, Laszlo Ersek, 2013/02/05
- [Qemu-devel] [PATCH v2 08/15] qbus_find_recursive(): reorganize, Laszlo Ersek, 2013/02/05
- [Qemu-devel] [PATCH v2 13/15] qdev_device_add(): extend signature with Error, Laszlo Ersek, 2013/02/05
- [Qemu-devel] [PATCH v2 14/15] qdev_device_add(): push error handling/consumption to callers, Laszlo Ersek, 2013/02/05
- [Qemu-devel] [PATCH v2 10/15] qbus_find_recursive(): push Error and make it terminate a recursive search, Laszlo Ersek, 2013/02/05