All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Andreas Färber" <afaerber@suse.de>
To: qemu-devel@nongnu.org
Cc: Luiz Capitulino <lcapitulino@redhat.com>,
	Peter Maydell <peter.maydell@linaro.org>,
	Anthony Liguori <aliguori@us.ibm.com>,
	Paolo Bonzini <pbonzini@redhat.com>,
	patches@linaro.org
Subject: Re: [Qemu-devel] [PATCH] qerror: Add QERR_PROPERTY_SET_AFTER_REALIZE
Date: Mon, 26 Mar 2012 17:48:09 +0200	[thread overview]
Message-ID: <4F708FB9.6000507@suse.de> (raw)
In-Reply-To: <1332775847-29202-1-git-send-email-peter.maydell@linaro.org>

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 } }"
>  

-- 
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg

  reply	other threads:[~2012-03-26 15:48 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-03-26 15:30 [Qemu-devel] [PATCH] qerror: Add QERR_PROPERTY_SET_AFTER_REALIZE Peter Maydell
2012-03-26 15:48 ` Andreas Färber [this message]
2012-03-27  7:27   ` Paolo Bonzini

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4F708FB9.6000507@suse.de \
    --to=afaerber@suse.de \
    --cc=aliguori@us.ibm.com \
    --cc=lcapitulino@redhat.com \
    --cc=patches@linaro.org \
    --cc=pbonzini@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.