qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH arm-devs v3 1/9] qom/object: Make uintXX added p


From: Andreas Färber
Subject: Re: [Qemu-devel] [PATCH arm-devs v3 1/9] qom/object: Make uintXX added properties writable
Date: Tue, 03 Dec 2013 14:19:34 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.1.0

Am 03.12.2013 07:59, schrieb Peter Crosthwaite:
> Currently the uintXX property adders make a read only property. This
> is not useful for devices that want to create board (or container)
> configurable dynamic device properties. Fix by trivially adding property
> setters to object_property_add_uintXX.
> 
> Signed-off-by: Peter Crosthwaite <address@hidden>
> ---
> changed since v2:
> msg typo: "trivially"

Not sure if I've asked already, but these functions were added by mst
(so let's CC him) for accessing read-only constants in ACPI code. Your
change seems to make them writable - can anything go wrong when the
setters are used via QMP? I fear we may need two separate sets of
functions, one read-only, one read-write.

Andreas

> 
>  qom/object.c | 44 ++++++++++++++++++++++++++++++++++++++++----
>  1 file changed, 40 insertions(+), 4 deletions(-)
> 
> diff --git a/qom/object.c b/qom/object.c
> index fc19cf6..07b454b 100644
> --- a/qom/object.c
> +++ b/qom/object.c
> @@ -1353,6 +1353,15 @@ static void property_get_uint8_ptr(Object *obj, 
> Visitor *v,
>      visit_type_uint8(v, &value, name, errp);
>  }
>  
> +static void property_set_uint8_ptr(Object *obj, Visitor *v,
> +                                   void *opaque, const char *name,
> +                                   Error **errp)
> +{
> +    uint8_t value;
> +    visit_type_uint8(v, &value, name, errp);
> +    *(uint8_t *)opaque = value;
> +}
> +
>  static void property_get_uint16_ptr(Object *obj, Visitor *v,
>                                     void *opaque, const char *name,
>                                     Error **errp)
> @@ -1361,6 +1370,15 @@ static void property_get_uint16_ptr(Object *obj, 
> Visitor *v,
>      visit_type_uint16(v, &value, name, errp);
>  }
>  
> +static void property_set_uint16_ptr(Object *obj, Visitor *v,
> +                                    void *opaque, const char *name,
> +                                    Error **errp)
> +{
> +    uint16_t value;
> +    visit_type_uint16(v, &value, name, errp);
> +    *(uint16_t *)opaque = value;
> +}
> +
>  static void property_get_uint32_ptr(Object *obj, Visitor *v,
>                                     void *opaque, const char *name,
>                                     Error **errp)
> @@ -1369,6 +1387,15 @@ static void property_get_uint32_ptr(Object *obj, 
> Visitor *v,
>      visit_type_uint32(v, &value, name, errp);
>  }
>  
> +static void property_set_uint32_ptr(Object *obj, Visitor *v,
> +                                    void *opaque, const char *name,
> +                                    Error **errp)
> +{
> +    uint32_t value;
> +    visit_type_uint32(v, &value, name, errp);
> +    *(uint32_t *)opaque = value;
> +}
> +
>  static void property_get_uint64_ptr(Object *obj, Visitor *v,
>                                     void *opaque, const char *name,
>                                     Error **errp)
> @@ -1377,32 +1404,41 @@ static void property_get_uint64_ptr(Object *obj, 
> Visitor *v,
>      visit_type_uint64(v, &value, name, errp);
>  }
>  
> +static void property_set_uint64_ptr(Object *obj, Visitor *v,
> +                                    void *opaque, const char *name,
> +                                    Error **errp)
> +{
> +    uint64_t value;
> +    visit_type_uint64(v, &value, name, errp);
> +    *(uint64_t *)opaque = value;
> +}
> +
>  void object_property_add_uint8_ptr(Object *obj, const char *name,
>                                     const uint8_t *v, Error **errp)
>  {
>      object_property_add(obj, name, "uint8", property_get_uint8_ptr,
> -                        NULL, NULL, (void *)v, errp);
> +                        property_set_uint8_ptr, NULL, (void *)v, errp);
>  }
>  
>  void object_property_add_uint16_ptr(Object *obj, const char *name,
>                                      const uint16_t *v, Error **errp)
>  {
>      object_property_add(obj, name, "uint16", property_get_uint16_ptr,
> -                        NULL, NULL, (void *)v, errp);
> +                        property_set_uint16_ptr, NULL, (void *)v, errp);
>  }
>  
>  void object_property_add_uint32_ptr(Object *obj, const char *name,
>                                      const uint32_t *v, Error **errp)
>  {
>      object_property_add(obj, name, "uint32", property_get_uint32_ptr,
> -                        NULL, NULL, (void *)v, errp);
> +                        property_set_uint32_ptr, NULL, (void *)v, errp);
>  }
>  
>  void object_property_add_uint64_ptr(Object *obj, const char *name,
>                                      const uint64_t *v, Error **errp)
>  {
>      object_property_add(obj, name, "uint64", property_get_uint64_ptr,
> -                        NULL, NULL, (void *)v, errp);
> +                        property_set_uint64_ptr, NULL, (void *)v, errp);
>  }
>  
>  static void object_instance_init(Object *obj)
> 


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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]