qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [PATCH] machine: replace underscores in machine's prope


From: Andreas Färber
Subject: Re: [Qemu-devel] [PATCH] machine: replace underscores in machine's property names
Date: Fri, 18 Jul 2014 16:25:13 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.6.0

Am 29.06.2014 11:09, schrieb Marcel Apfelbaum:
> Replaced '_' with '-' to comply with QOM guidelines.
> Made the conversion from HMP to QMP in vl.c
> 
> Signed-off-by: Marcel Apfelbaum <address@hidden>
> ---
>  hw/core/machine.c |  8 ++++----
>  vl.c              | 12 +++++++++++-
>  2 files changed, 15 insertions(+), 5 deletions(-)
[snip]
> diff --git a/vl.c b/vl.c
> index a1686ef..7587c97 100644
> --- a/vl.c
> +++ b/vl.c
> @@ -2820,15 +2820,25 @@ static int object_set_property(const char *name, 
> const char *value, void *opaque
>      Object *obj = OBJECT(opaque);
>      StringInputVisitor *siv;
>      Error *local_err = NULL;
> +    char *c, *qom_name;
>  
>      if (strcmp(name, "qom-type") == 0 || strcmp(name, "id") == 0 ||
>          strcmp(name, "type") == 0) {
>          return 0;
>      }
>  
> +    qom_name = g_strdup(name);
> +    c = qom_name;
> +    while (*c++) {
> +        if (*c == '_') {
> +            *c = '-';
> +        }
> +    }

Actually, is this really safe? By my reading, this function handles
-object as well, which in turn allows - in theory - to instantiate any
device, where some will still have underscores in their property names.
Not sure if all non-device objects such as virtio-rng backends have been
checked?

Since it's really late, I would be more comfortable to copy this
function with a large TODO and only apply this fixup for -machine, where
we are more easily able to review and test. Opinions?

Regards,
Andreas

> +
>      siv = string_input_visitor_new(value);
> -    object_property_set(obj, string_input_get_visitor(siv), name, 
> &local_err);
> +    object_property_set(obj, string_input_get_visitor(siv), qom_name, 
> &local_err);
>      string_input_visitor_cleanup(siv);
> +    free(qom_name);
>  
>      if (local_err) {
>          qerror_report_err(local_err);
> 


-- 
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]