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

Re: [PATCH v7 44/65] hw/nvdimm: convert UUID property to QAPI-aware registration



Marc-André Lureau <marcandre.lureau@xxxxxxxxxx> writes:

> Add a QemuUUID_type_info and use object_property_add_qapi() instead of
> object_property_add() for the nvdimm UUID property.
>
> The type info is defined manually in uuid.c rather than generated,
> since QAPI does not yet support string typedefs. An alternative would
> be to extend the QAPI schema language with a 'typedef' construct
> (e.g. { 'typedef': 'UUID', 'data': 'str' }), which would let the
> generator produce the type info, C typedef, and introspection entry
> automatically.
>
> Alternatively, the exposed type being a string, we could change the
> property to be str_type_info.
>
> Signed-off-by: Markus Armbruster <armbru@xxxxxxxxxx>
> Signed-off-by: Marc-André Lureau <marcandre.lureau@xxxxxxxxxx>
> ---
>  hw/mem/nvdimm.c     | 4 ++--
>  include/qemu/uuid.h | 4 ++++
>  util/uuid.c         | 5 +++++
>  3 files changed, 11 insertions(+), 2 deletions(-)
>
> diff --git a/hw/mem/nvdimm.c b/hw/mem/nvdimm.c
> index 123ddc938546..b7ccb5c93678 100644
> --- a/hw/mem/nvdimm.c
> +++ b/hw/mem/nvdimm.c
> @@ -104,8 +104,8 @@ static void nvdimm_init(Object *obj)
>                               nvdimm_get_label_size, nvdimm_set_label_size, 
> NULL,
>                               NULL);
>  
> -    object_property_add(obj, NVDIMM_UUID_PROP, "QemuUUID", nvdimm_get_uuid,
> -                        nvdimm_set_uuid, NULL, NULL);
> +    object_property_add_qapi(obj, NVDIMM_UUID_PROP, &QemuUUID_type_info,
> +                             nvdimm_get_uuid, nvdimm_set_uuid, NULL, NULL);
>  }
>  

Let's pass &str_type_info, like the next patch does, because ...

>  static void nvdimm_finalize(Object *obj)
> diff --git a/include/qemu/uuid.h b/include/qemu/uuid.h
> index 869f84af09dd..ed0c62327d4d 100644
> --- a/include/qemu/uuid.h
> +++ b/include/qemu/uuid.h
> @@ -16,6 +16,8 @@
>  #ifndef QEMU_UUID_H
>  #define QEMU_UUID_H
>  
> +#include "qapi/qapi-type-info.h"
> +
>  
>  /* Version 4 UUID (pseudo random numbers), RFC4122 4.4. */
>  
> @@ -99,4 +101,6 @@ QemuUUID qemu_uuid_bswap(QemuUUID uuid);
>  
>  uint32_t qemu_uuid_hash(const void *uuid);
>  
> +extern const QAPITypeInfo QemuUUID_type_info;
> +
>  #endif
> diff --git a/util/uuid.c b/util/uuid.c
> index 234619dd5e69..363a03051aba 100644
> --- a/util/uuid.c
> +++ b/util/uuid.c
> @@ -17,6 +17,11 @@
>  #include "qemu/uuid.h"
>  #include "qemu/bswap.h"
>  
> +const QAPITypeInfo QemuUUID_type_info = {
> +    .name = "QemuUUID",
> +    .masked_name = "str",
> +};
> +

... the only difference to str_type_info is @name.

In v7, @name is used as value of ObjectPropertyInfo /
ObjectPropertyValue member @type.  Your manual QAPITypeInfo lets you
preserve the value of @type.

It isn't used that way v8 (which I'll post real soon now).  It preserves
@type values differently.  The problem discussed in the commit message
doesn't exist then, so I'll cut it some.

>  void qemu_uuid_generate(QemuUUID *uuid)
>  {
>      int i;




 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.