qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [PATCH 13/16] convert net_init_vde() to NetClientOption


From: Paolo Bonzini
Subject: Re: [Qemu-devel] [PATCH 13/16] convert net_init_vde() to NetClientOptions
Date: Tue, 05 Jun 2012 23:04:04 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:12.0) Gecko/20120430 Thunderbird/12.0.1

Il 22/05/2012 12:45, Laszlo Ersek ha scritto:
> Signed-off-by: Laszlo Ersek <address@hidden>
> ---
>  net/vde.c |   37 +++++++++++++++++++++++++++++--------
>  1 files changed, 29 insertions(+), 8 deletions(-)
> 
> diff --git a/net/vde.c b/net/vde.c
> index 8e60f68..35e8113 100644
> --- a/net/vde.c
> +++ b/net/vde.c
> @@ -110,20 +110,41 @@ static int net_vde_init(VLANState *vlan, const char 
> *model,
>      return 0;
>  }
>  
> -int net_init_vde(QemuOpts *opts, const NetClientOptions *new_opts,
> +int net_init_vde(QemuOpts *old_opts, const NetClientOptions *opts,
>                   const char *name, VLANState *vlan)
>  {
> -    const char *sock;
> -    const char *group;
>      int port, mode;
>  
> -    sock  = qemu_opt_get(opts, "sock");
> -    group = qemu_opt_get(opts, "group");
> +    const NetdevVdeOptions *vde;
>  
> -    port = qemu_opt_get_number(opts, "port", 0);
> -    mode = qemu_opt_get_number(opts, "mode", 0700);
> +    assert(opts->kind == NET_CLIENT_OPTIONS_KIND_VDE);
> +    vde = opts->vde;
>  
> -    if (net_vde_init(vlan, "vde", name, sock, port, group, mode) == -1) {
> +    if (vde->has_port) {
> +        if (vde->port > INT_MAX) {
> +            error_report("invalid port: %"PRId64, vde->port);
> +            return -1;
> +        }
> +        port = vde->port;
> +    }
> +    else {
> +        port = 0;
> +    }
> +
> +    if (vde->has_mode) {
> +        if (vde->mode > INT_MAX) {
> +            error_report("invalid mode: %"PRId64, vde->mode);
> +            return -1;
> +        }
> +        mode = vde->mode;
> +    }
> +    else {
> +        mode = 0700;
> +    }
> +
> +    /* missing optional values have been initialized to "all bits zero" */
> +    if (net_vde_init(vlan, "vde", name, vde->sock, port, vde->group, mode) ==
> +         -1) {
>          return -1;
>      }
>  

Same observation about checking < 0.

I wonder if it works to declare all these fields to be int32 in the
schema?  That would simplify the series nicely.

Paolo



reply via email to

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