qerror: Add QERR_PROPERTY_SET_AFTER_REALIZE
PATCH v2 1/1 qerror: Add QERR_PROPERTY_SET_AFTER_REALIZE
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 "permission denied" message.
---
Changes since the v1 (which was sent way back in March...):
* rebased on master now a pile of qdev/qom changesd have landed
* fixed some overlong lines
* avoid gcc '?:' extension
* a couple of set_ functions in qdev-properties.c are new since v1 and needed their QERR_PERMISSION_DENIED checks changing
hw/qdev-properties.c | 42 ++++++++++++++++++++++++++++-------------- qerror.c | 5 +++++ qerror.h | 3 +++ 3 files changed, 36 insertions(+), 14 deletions(-)
hw/qdev-properties.c +28 -14
@@ -54,7 +54,8 @@ 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 ? dev->id :"" , name);return ; }
@@ -94,7 +95,8 @@ static void set_uint8(Object *obj, Visitor *v, void *opaque,uint8_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 ? dev->id :"" , name);return ; }
@@ -161,7 +163,8 @@ static void set_uint16(Object *obj, Visitor *v, void *opaque,uint16_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 ? dev->id :"" , name);return ; }
@@ -194,7 +197,8 @@ static void set_uint32(Object *obj, Visitor *v, void *opaque,uint32_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 ? dev->id :"" , name);return ; }
@@ -219,7 +223,8 @@ static void set_int32(Object *obj, Visitor *v, void *opaque,int32_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 ? dev->id :"" , name);return ; }
@@ -292,7 +297,8 @@ static void set_uint64(Object *obj, Visitor *v, void *opaque,uint64_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 ? dev->id :"" , name);return ; }
@@ -380,7 +386,8 @@ 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 ? dev->id :"" , name);return ; }
@@ -458,7 +465,8 @@ 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 ? dev->id :"" , name);return ; }
@@ -627,7 +635,8 @@ 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 ? dev->id :"" , name);return ; }
@@ -697,7 +706,8 @@ 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 ? dev->id :"" , name);return ; }
@@ -767,7 +777,8 @@ 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 ? dev->id :"" , name);return ; }
@@ -798,7 +809,8 @@ static void set_pci_devfn(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 ? dev->id :"" , name);return ; }
@@ -868,7 +880,8 @@ static void set_blocksize(Object *obj, Visitor *v, void *opaque,const int64_t max =32768 ;if (dev->state !=DEV_STATE_CREATED ) { -error_set (errp,QERR_PERMISSION_DENIED ); +error_set (errp,QERR_PROPERTY_SET_AFTER_REALIZE , + dev->id ? dev->id :"" , name);return ; }
@@ -936,7 +949,8 @@ static void set_pci_host_devaddr(Object *obj, Visitor *v, void *opaque,unsigned int slot =0 , func =0 ;if (dev->state !=DEV_STATE_CREATED ) { -error_set (errp,QERR_PERMISSION_DENIED ); +error_set (errp,QERR_PROPERTY_SET_AFTER_REALIZE , + dev->id ? dev->id :"" , name);return ; }
qerror.c +5 -0
@@ -233,6 +233,11 @@ 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)'", },
qerror.h +3 -0
@@ -196,6 +196,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 } }"
Signature · 1 line
1.7.5.4
Am 16.07.2012 17:25, schrieb Peter Maydell:
Quoted 5 lines
Add a new QError
QERR_PROPERTY_SET_AFTER_REALIZEfor 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 "permission denied" message.
Quoted 8 lines
Signed-off-by Peter Maydell <[email protected]>---
Changes since the v1 (which was sent way back in March...):
* rebased on master now a pile of qdev/qom changesd have landed
* fixed some overlong lines
* avoid gcc '?:' extension
* a couple ofset_functions inqdev-properties.care new since v1 and needed theirQERR_PERMISSION_DENIEDchecks changing
This does not yet seem to take into account the discussion with libvirt and Anthony on what parameters to pass. The ID generalization was nack'ed by Anthony and a QOM path was suggested as alternative. Could you please look into that?
Thanks,
Andreas
Quoted 181 lines
hw/qdev-properties.c | 42 ++++++++++++++++++++++++++++-------------- qerror.c | 5 +++++ qerror.h | 3 +++ 3 files changed, 36 insertions(+), 14 deletions(-)hw/qdev-properties.c +28
-14@@ -54,7 +54,8 @@ 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 ? dev->id :"" , name);return ; }@@ -94,7 +95,8 @@ static void set_uint8(Object *obj, Visitor *v, void *opaque,uint8_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 ? dev->id :"" , name);return ; }@@ -161,7 +163,8 @@ static void set_uint16(Object *obj, Visitor *v, void *opaque,uint16_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 ? dev->id :"" , name);return ; }@@ -194,7 +197,8 @@ static void set_uint32(Object *obj, Visitor *v, void *opaque,uint32_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 ? dev->id :"" , name);return ; }@@ -219,7 +223,8 @@ static void set_int32(Object *obj, Visitor *v, void *opaque,int32_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 ? dev->id :"" , name);return ; }@@ -292,7 +297,8 @@ static void set_uint64(Object *obj, Visitor *v, void *opaque,uint64_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 ? dev->id :"" , name);return ; }@@ -380,7 +386,8 @@ 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 ? dev->id :"" , name);return ; }@@ -458,7 +465,8 @@ 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 ? dev->id :"" , name);return ; }@@ -627,7 +635,8 @@ 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 ? dev->id :"" , name);return ; }@@ -697,7 +706,8 @@ 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 ? dev->id :"" , name);return ; }@@ -767,7 +777,8 @@ 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 ? dev->id :"" , name);return ; }@@ -798,7 +809,8 @@ static void set_pci_devfn(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 ? dev->id :"" , name);return ; }@@ -868,7 +880,8 @@ static void set_blocksize(Object *obj, Visitor *v, void *opaque,const int64_t max =32768 ;if (dev->state !=DEV_STATE_CREATED ) { -error_set (errp,QERR_PERMISSION_DENIED ); +error_set (errp,QERR_PROPERTY_SET_AFTER_REALIZE , + dev->id ? dev->id :"" , name);return ; }@@ -936,7 +949,8 @@ static void set_pci_host_devaddr(Object *obj, Visitor *v, void *opaque,unsigned int slot =0 , func =0 ;if (dev->state !=DEV_STATE_CREATED ) { -error_set (errp,QERR_PERMISSION_DENIED ); +error_set (errp,QERR_PROPERTY_SET_AFTER_REALIZE , + dev->id ? dev->id :"" , name);return ; }qerror.c +5
-0@@ -233,6 +233,11 @@ 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)'", },qerror.h +3
-0@@ -196,6 +196,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 } }"
Signature · 2 lines
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
Quoted 15 lines · Andreas Färber
Am 16.07.2012 17:25, schrieb Peter Maydell:
Quoted 5 lines
Add a new QError
QERR_PROPERTY_SET_AFTER_REALIZEfor 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 "permission denied" message.Quoted 8 lines
Signed-off-by Peter Maydell <[email protected]>---
Changes since the v1 (which was sent way back in March...):
* rebased on master now a pile of qdev/qom changesd have landed
* fixed some overlong lines
* avoid gcc '?:' extension
* a couple ofset_functions inqdev-properties.care new since v1 and needed theirQERR_PERMISSION_DENIEDchecks changing
Quoted 4 lines
This does not yet seem to take into account the discussion with libvirt and Anthony on what parameters to pass. The ID generalization was nack'ed by Anthony and a QOM path was suggested as alternative. Could you please look into that?
I'm afraid I'm not really sure what you're referring to here -- do you have a link to a discussion?
All I want is for errors printed to the user to be a bit more helpful; the whole qerror infrastructure seems to make it somewhere between difficult and impossible to do that :-(
-- PMM
Quoted 21 lines · Peter Maydell
Quoted 15 lines · Andreas Färber
Am 16.07.2012 17:25, schrieb Peter Maydell:
Quoted 5 lines
Add a new QError
QERR_PROPERTY_SET_AFTER_REALIZEfor 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 "permission denied" message.Quoted 8 lines
Signed-off-by Peter Maydell <[email protected]>---
Changes since the v1 (which was sent way back in March...):
* rebased on master now a pile of qdev/qom changesd have landed
* fixed some overlong lines
* avoid gcc '?:' extension
* a couple ofset_functions inqdev-properties.care new since v1 and needed theirQERR_PERMISSION_DENIEDchecks changingQuoted 4 lines
This does not yet seem to take into account the discussion with libvirt and Anthony on what parameters to pass. The ID generalization was nack'ed by Anthony and a QOM path was suggested as alternative. Could you please look into that?
Quoted 6 lines
I'm afraid I'm not really sure what you're referring to here -- do you have a link to a discussion?
All I want is for errors printed to the user to be a bit more helpful; the whole qerror infrastructure seems to make it somewhere between difficult and impossible to do that :-(
Yup. One of the reasons why I detest it.
A recent thread on how to recover from this disaster:
http://lists.nongnu.org/archive/html/qemu-devel/2012-06/msg03469.html
Quoted 26 lines · Markus Armbruster
Quoted 24 lines · Peter Maydell
Quoted 15 lines · Andreas Färber
Am 16.07.2012 17:25, schrieb Peter Maydell:
Quoted 5 lines
Add a new QError
QERR_PROPERTY_SET_AFTER_REALIZEfor 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 "permission denied" message.Quoted 8 lines
Signed-off-by Peter Maydell <[email protected]>---
Changes since the v1 (which was sent way back in March...):
* rebased on master now a pile of qdev/qom changesd have landed
* fixed some overlong lines
* avoid gcc '?:' extension
* a couple ofset_functions inqdev-properties.care new since v1 and needed theirQERR_PERMISSION_DENIEDchecks changingQuoted 4 lines
This does not yet seem to take into account the discussion with libvirt and Anthony on what parameters to pass. The ID generalization was nack'ed by Anthony and a QOM path was suggested as alternative. Could you please look into that?
I'm afraid I'm not really sure what you're referring to here -- do you have a link to a discussion?
Quoted 8 lines
Quoted 3 lines
All I want is for errors printed to the user to be a bit more helpful; the whole qerror infrastructure seems to make it somewhere between difficult and impossible to do that :-(
Yup. One of the reasons why I detest it.
A recent thread on how to recover from this disaster:
http://lists.nongnu.org/archive/html/qemu-devel/2012-06/msg03469.html
That's interesting but I'm not sure how it's relevant. We already have QERR_PROPERTY values just this new one, so I don't see why this is any worse than the ones we have. If we come up with some new scheme we can convert this with all the rest. And I don't really want to block "improve this error message" on getting agreement for some big redesign effort...
-- PMM
Quoted 3 lines · Peter Maydell
That's interesting but I'm not sure how it's relevant. We already have
QERR_PROPERTYvalues just this new one, so I don't see why this is any worse than the ones we have.
"just like".
-- PMM
Quoted 36 lines · Peter Maydell
Quoted 26 lines · Markus Armbruster
Quoted 24 lines · Peter Maydell
Quoted 15 lines · Andreas Färber
Am 16.07.2012 17:25, schrieb Peter Maydell:
Quoted 5 lines
Add a new QError
QERR_PROPERTY_SET_AFTER_REALIZEfor 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 "permission denied" message.Quoted 8 lines
Signed-off-by Peter Maydell <[email protected]>---
Changes since the v1 (which was sent way back in March...):
* rebased on master now a pile of qdev/qom changesd have landed
* fixed some overlong lines
* avoid gcc '?:' extension
* a couple ofset_functions inqdev-properties.care new since v1 and needed theirQERR_PERMISSION_DENIEDchecks changingQuoted 4 lines
This does not yet seem to take into account the discussion with libvirt and Anthony on what parameters to pass. The ID generalization was nack'ed by Anthony and a QOM path was suggested as alternative. Could you please look into that?
I'm afraid I'm not really sure what you're referring to here -- do you have a link to a discussion?
Quoted 8 lines
Quoted 3 lines
All I want is for errors printed to the user to be a bit more helpful; the whole qerror infrastructure seems to make it somewhere between difficult and impossible to do that :-(
Yup. One of the reasons why I detest it.
A recent thread on how to recover from this disaster:
http://lists.nongnu.org/archive/html/qemu-devel/2012-06/msg03469.html
Quoted 6 lines
That's interesting but I'm not sure how it's relevant. We already have
QERR_PROPERTYvalues just this new one, so I don't see why this is any worse than the ones we have. If we come up with some new scheme we can convert this with all the rest. And I don't really want to block "improve this error message" on getting agreement for some big redesign effort...
I'm not objecting to your patch (I didn't even review it), just pointing out there's a glimmer of hope on the "emitting error messages fit for humans is somewhere between difficult and impossible" front.
Quoted 45 lines · On Wed, 18 Jul 2012 13:59:06 +0200 Markus Armbruster <[email protected]> wrote:
Quoted 36 lines · Peter Maydell
Quoted 26 lines · Markus Armbruster
Quoted 24 lines · Peter Maydell
Quoted 15 lines · Andreas Färber
Am 16.07.2012 17:25, schrieb Peter Maydell:
Quoted 5 lines
Add a new QError
QERR_PROPERTY_SET_AFTER_REALIZEfor 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 "permission denied" message.Quoted 8 lines
Signed-off-by Peter Maydell <[email protected]>---
Changes since the v1 (which was sent way back in March...):
* rebased on master now a pile of qdev/qom changesd have landed
* fixed some overlong lines
* avoid gcc '?:' extension
* a couple ofset_functions inqdev-properties.care new since v1 and needed theirQERR_PERMISSION_DENIEDchecks changingQuoted 4 lines
This does not yet seem to take into account the discussion with libvirt and Anthony on what parameters to pass. The ID generalization was nack'ed by Anthony and a QOM path was suggested as alternative. Could you please look into that?
I'm afraid I'm not really sure what you're referring to here -- do you have a link to a discussion?
Quoted 8 lines
Quoted 3 lines
All I want is for errors printed to the user to be a bit more helpful; the whole qerror infrastructure seems to make it somewhere between difficult and impossible to do that :-(
Yup. One of the reasons why I detest it.
A recent thread on how to recover from this disaster:
http://lists.nongnu.org/archive/html/qemu-devel/2012-06/msg03469.htmlQuoted 6 lines
That's interesting but I'm not sure how it's relevant. We already have
QERR_PROPERTYvalues just this new one, so I don't see why this is any worse than the ones we have. If we come up with some new scheme we can convert this with all the rest. And I don't really want to block "improve this error message" on getting agreement for some big redesign effort...
Quoted 3 lines
I'm not objecting to your patch (I didn't even review it), just pointing out there's a glimmer of hope on the "emitting error messages fit for humans is somewhere between difficult and impossible" front.
Yeah, I plan to fix that soon.