Message ID | 1332775847-29202-1-git-send-email-peter.maydell@linaro.org |
---|---|
State | Superseded |
Headers | show |
Am 26.03.2012 17:30, schrieb Peter Maydell: > Add a new QError QERR_PROPERTY_SET_AFTER_REALIZE for attempts > to set a QOM or qdev property after the object/device has been > realized. This allows a slightly more informative diagnostic > than the previous "Insufficient permission" message. > > Signed-off-by: Peter Maydell <peter.maydell@linaro.org> > --- > We've talked about the rather unhelpful nature of the "Insufficient > permission" diagnostic before: > http://lists.gnu.org/archive/html/qemu-devel/2012-02/msg02368.html > and I finally got round to writing a patch to improve it... Not aware of the submission, I suggested to append this to my series, since upstream does not yet have "realize" as such. > hw/qdev-properties.c | 22 +++++++++++----------- > qerror.c | 4 ++++ > qerror.h | 3 +++ > 3 files changed, 18 insertions(+), 11 deletions(-) > > diff --git a/hw/qdev-properties.c b/hw/qdev-properties.c > index bff9152..627c6ba 100644 > --- a/hw/qdev-properties.c > +++ b/hw/qdev-properties.c > @@ -54,7 +54,7 @@ static void set_bit(Object *obj, Visitor *v, void *opaque, > bool value; > > if (dev->state != DEV_STATE_CREATED) { > - error_set(errp, QERR_PERMISSION_DENIED); > + error_set(errp, QERR_PROPERTY_SET_AFTER_REALIZE, dev->id?:"", name); I suggested spaces around ?: but was told this was the surrounding style - leave or fix? > return; > } > > @@ -98,7 +98,7 @@ static void set_int8(Object *obj, Visitor *v, void *opaque, > int64_t value; > > if (dev->state != DEV_STATE_CREATED) { > - error_set(errp, QERR_PERMISSION_DENIED); > + error_set(errp, QERR_PROPERTY_SET_AFTER_REALIZE, dev->id?:"", name); > return; > } > > @@ -184,7 +184,7 @@ static void set_int16(Object *obj, Visitor *v, void *opaque, > int64_t value; > > if (dev->state != DEV_STATE_CREATED) { > - error_set(errp, QERR_PERMISSION_DENIED); > + error_set(errp, QERR_PROPERTY_SET_AFTER_REALIZE, dev->id?:"", name); > return; > } > > @@ -234,7 +234,7 @@ static void set_int32(Object *obj, Visitor *v, void *opaque, > int64_t value; > > if (dev->state != DEV_STATE_CREATED) { > - error_set(errp, QERR_PERMISSION_DENIED); > + error_set(errp, QERR_PROPERTY_SET_AFTER_REALIZE, dev->id?:"", name); > return; > } > > @@ -324,7 +324,7 @@ static void set_int64(Object *obj, Visitor *v, void *opaque, > int64_t *ptr = qdev_get_prop_ptr(dev, prop); > > if (dev->state != DEV_STATE_CREATED) { > - error_set(errp, QERR_PERMISSION_DENIED); > + error_set(errp, QERR_PROPERTY_SET_AFTER_REALIZE, dev->id?:"", name); > return; > } > > @@ -412,7 +412,7 @@ static void set_string(Object *obj, Visitor *v, void *opaque, > char *str; > > if (dev->state != DEV_STATE_CREATED) { > - error_set(errp, QERR_PERMISSION_DENIED); > + error_set(errp, QERR_PROPERTY_SET_AFTER_REALIZE, dev->id?:"", name); > return; > } > > @@ -490,7 +490,7 @@ static void set_pointer(Object *obj, Visitor *v, Property *prop, > int ret; > > if (dev->state != DEV_STATE_CREATED) { > - error_set(errp, QERR_PERMISSION_DENIED); > + error_set(errp, QERR_PROPERTY_SET_AFTER_REALIZE, dev->id?:"", name); > return; > } > > @@ -659,7 +659,7 @@ static void set_vlan(Object *obj, Visitor *v, void *opaque, > VLANState *vlan; > > if (dev->state != DEV_STATE_CREATED) { > - error_set(errp, QERR_PERMISSION_DENIED); > + error_set(errp, QERR_PROPERTY_SET_AFTER_REALIZE, dev->id?:"", name); > return; > } > > @@ -729,7 +729,7 @@ static void set_mac(Object *obj, Visitor *v, void *opaque, > char *str, *p; > > if (dev->state != DEV_STATE_CREATED) { > - error_set(errp, QERR_PERMISSION_DENIED); > + error_set(errp, QERR_PROPERTY_SET_AFTER_REALIZE, dev->id?:"", name); > return; > } > > @@ -797,7 +797,7 @@ static void set_enum(Object *obj, Visitor *v, void *opaque, > int *ptr = qdev_get_prop_ptr(dev, prop); > > if (dev->state != DEV_STATE_CREATED) { > - error_set(errp, QERR_PERMISSION_DENIED); > + error_set(errp, QERR_PROPERTY_SET_AFTER_REALIZE, dev->id?:"", name); > return; > } > > @@ -828,7 +828,7 @@ static void set_pci_devfn(Object *obj, Visitor *v, void *opaque, > char *str = (char *)""; > > if (dev->state != DEV_STATE_CREATED) { > - error_set(errp, QERR_PERMISSION_DENIED); > + error_set(errp, QERR_PROPERTY_SET_AFTER_REALIZE, dev->id?:"", name); > return; > } > > diff --git a/qerror.c b/qerror.c > index 41c729a..7d9aa4f 100644 > --- a/qerror.c > +++ b/qerror.c > @@ -229,6 +229,10 @@ static const QErrorStringTable qerror_table[] = { > .desc = "Property '%(device).%(property)' not found", > }, > { > + .error_fmt = QERR_PROPERTY_SET_AFTER_REALIZE, > + .desc = "Property '%(device).%(property)' cannot be set after realize", > + }, > + { > .error_fmt = QERR_PROPERTY_VALUE_BAD, > .desc = "Property '%(device).%(property)' doesn't take value '%(value)'", > }, > diff --git a/qerror.h b/qerror.h > index e16f9c2..266a04a 100644 > --- a/qerror.h > +++ b/qerror.h > @@ -193,6 +193,9 @@ QError *qobject_to_qerror(const QObject *obj); > #define QERR_PROPERTY_NOT_FOUND \ > "{ 'class': 'PropertyNotFound', 'data': { 'device': %s, 'property': %s } }" > > +#define QERR_PROPERTY_SET_AFTER_REALIZE \ > + "{ 'class': 'PropertySetAfterRealize', 'data': { 'device': %s, 'property': %s } }" Properties are no longer a device concept. Can we start using a different key name here, e.g., 'type'? Andreas > + > #define QERR_PROPERTY_VALUE_BAD \ > "{ 'class': 'PropertyValueBad', 'data': { 'device': %s, 'property': %s, 'value': %s } }" >
Il 26/03/2012 17:48, Andreas Färber ha scritto: > Am 26.03.2012 17:30, schrieb Peter Maydell: >> Add a new QError QERR_PROPERTY_SET_AFTER_REALIZE for attempts >> to set a QOM or qdev property after the object/device has been >> realized. This allows a slightly more informative diagnostic >> than the previous "Insufficient permission" message. >> >> Signed-off-by: Peter Maydell <peter.maydell@linaro.org> >> --- >> We've talked about the rather unhelpful nature of the "Insufficient >> permission" diagnostic before: >> http://lists.gnu.org/archive/html/qemu-devel/2012-02/msg02368.html >> and I finally got round to writing a patch to improve it... > > Not aware of the submission, I suggested to append this to my series, > since upstream does not yet have "realize" as such. Yes, good idea. >> +#define QERR_PROPERTY_SET_AFTER_REALIZE \ >> + "{ 'class': 'PropertySetAfterRealize', 'data': { 'device': %s, 'property': %s } }" > > Properties are no longer a device concept. Can we start using a > different key name here, e.g., 'type'? Too late I guess, I prefer consistency. Paolo
diff --git a/hw/qdev-properties.c b/hw/qdev-properties.c index bff9152..627c6ba 100644 --- a/hw/qdev-properties.c +++ b/hw/qdev-properties.c @@ -54,7 +54,7 @@ static void set_bit(Object *obj, Visitor *v, void *opaque, bool value; if (dev->state != DEV_STATE_CREATED) { - error_set(errp, QERR_PERMISSION_DENIED); + error_set(errp, QERR_PROPERTY_SET_AFTER_REALIZE, dev->id?:"", name); return; } @@ -98,7 +98,7 @@ static void set_int8(Object *obj, Visitor *v, void *opaque, int64_t value; if (dev->state != DEV_STATE_CREATED) { - error_set(errp, QERR_PERMISSION_DENIED); + error_set(errp, QERR_PROPERTY_SET_AFTER_REALIZE, dev->id?:"", name); return; } @@ -184,7 +184,7 @@ static void set_int16(Object *obj, Visitor *v, void *opaque, int64_t value; if (dev->state != DEV_STATE_CREATED) { - error_set(errp, QERR_PERMISSION_DENIED); + error_set(errp, QERR_PROPERTY_SET_AFTER_REALIZE, dev->id?:"", name); return; } @@ -234,7 +234,7 @@ static void set_int32(Object *obj, Visitor *v, void *opaque, int64_t value; if (dev->state != DEV_STATE_CREATED) { - error_set(errp, QERR_PERMISSION_DENIED); + error_set(errp, QERR_PROPERTY_SET_AFTER_REALIZE, dev->id?:"", name); return; } @@ -324,7 +324,7 @@ static void set_int64(Object *obj, Visitor *v, void *opaque, int64_t *ptr = qdev_get_prop_ptr(dev, prop); if (dev->state != DEV_STATE_CREATED) { - error_set(errp, QERR_PERMISSION_DENIED); + error_set(errp, QERR_PROPERTY_SET_AFTER_REALIZE, dev->id?:"", name); return; } @@ -412,7 +412,7 @@ static void set_string(Object *obj, Visitor *v, void *opaque, char *str; if (dev->state != DEV_STATE_CREATED) { - error_set(errp, QERR_PERMISSION_DENIED); + error_set(errp, QERR_PROPERTY_SET_AFTER_REALIZE, dev->id?:"", name); return; } @@ -490,7 +490,7 @@ static void set_pointer(Object *obj, Visitor *v, Property *prop, int ret; if (dev->state != DEV_STATE_CREATED) { - error_set(errp, QERR_PERMISSION_DENIED); + error_set(errp, QERR_PROPERTY_SET_AFTER_REALIZE, dev->id?:"", name); return; } @@ -659,7 +659,7 @@ static void set_vlan(Object *obj, Visitor *v, void *opaque, VLANState *vlan; if (dev->state != DEV_STATE_CREATED) { - error_set(errp, QERR_PERMISSION_DENIED); + error_set(errp, QERR_PROPERTY_SET_AFTER_REALIZE, dev->id?:"", name); return; } @@ -729,7 +729,7 @@ static void set_mac(Object *obj, Visitor *v, void *opaque, char *str, *p; if (dev->state != DEV_STATE_CREATED) { - error_set(errp, QERR_PERMISSION_DENIED); + error_set(errp, QERR_PROPERTY_SET_AFTER_REALIZE, dev->id?:"", name); return; } @@ -797,7 +797,7 @@ static void set_enum(Object *obj, Visitor *v, void *opaque, int *ptr = qdev_get_prop_ptr(dev, prop); if (dev->state != DEV_STATE_CREATED) { - error_set(errp, QERR_PERMISSION_DENIED); + error_set(errp, QERR_PROPERTY_SET_AFTER_REALIZE, dev->id?:"", name); return; } @@ -828,7 +828,7 @@ static void set_pci_devfn(Object *obj, Visitor *v, void *opaque, char *str = (char *)""; if (dev->state != DEV_STATE_CREATED) { - error_set(errp, QERR_PERMISSION_DENIED); + error_set(errp, QERR_PROPERTY_SET_AFTER_REALIZE, dev->id?:"", name); return; } diff --git a/qerror.c b/qerror.c index 41c729a..7d9aa4f 100644 --- a/qerror.c +++ b/qerror.c @@ -229,6 +229,10 @@ static const QErrorStringTable qerror_table[] = { .desc = "Property '%(device).%(property)' not found", }, { + .error_fmt = QERR_PROPERTY_SET_AFTER_REALIZE, + .desc = "Property '%(device).%(property)' cannot be set after realize", + }, + { .error_fmt = QERR_PROPERTY_VALUE_BAD, .desc = "Property '%(device).%(property)' doesn't take value '%(value)'", }, diff --git a/qerror.h b/qerror.h index e16f9c2..266a04a 100644 --- a/qerror.h +++ b/qerror.h @@ -193,6 +193,9 @@ QError *qobject_to_qerror(const QObject *obj); #define QERR_PROPERTY_NOT_FOUND \ "{ 'class': 'PropertyNotFound', 'data': { 'device': %s, 'property': %s } }" +#define QERR_PROPERTY_SET_AFTER_REALIZE \ + "{ 'class': 'PropertySetAfterRealize', 'data': { 'device': %s, 'property': %s } }" + #define QERR_PROPERTY_VALUE_BAD \ "{ 'class': 'PropertyValueBad', 'data': { 'device': %s, 'property': %s, 'value': %s } }"
Add a new QError QERR_PROPERTY_SET_AFTER_REALIZE for attempts to set a QOM or qdev property after the object/device has been realized. This allows a slightly more informative diagnostic than the previous "Insufficient permission" message. Signed-off-by: Peter Maydell <peter.maydell@linaro.org> --- We've talked about the rather unhelpful nature of the "Insufficient permission" diagnostic before: http://lists.gnu.org/archive/html/qemu-devel/2012-02/msg02368.html and I finally got round to writing a patch to improve it... hw/qdev-properties.c | 22 +++++++++++----------- qerror.c | 4 ++++ qerror.h | 3 +++ 3 files changed, 18 insertions(+), 11 deletions(-)