From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:36206) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Sc0vK-0005Ea-RI for qemu-devel@nongnu.org; Tue, 05 Jun 2012 17:04:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Sc0vE-00038D-45 for qemu-devel@nongnu.org; Tue, 05 Jun 2012 17:04:18 -0400 Received: from mail-pb0-f45.google.com ([209.85.160.45]:58772) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Sc0vD-00037y-Rk for qemu-devel@nongnu.org; Tue, 05 Jun 2012 17:04:12 -0400 Received: by pbbro12 with SMTP id ro12so8652423pbb.4 for ; Tue, 05 Jun 2012 14:04:10 -0700 (PDT) Sender: Paolo Bonzini Message-ID: <4FCE7444.3040908@redhat.com> Date: Tue, 05 Jun 2012 23:04:04 +0200 From: Paolo Bonzini MIME-Version: 1.0 References: <1337683555-13301-1-git-send-email-lersek@redhat.com> <1337683555-13301-14-git-send-email-lersek@redhat.com> In-Reply-To: <1337683555-13301-14-git-send-email-lersek@redhat.com> Content-Type: text/plain; charset=ISO-8859-15 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH 13/16] convert net_init_vde() to NetClientOptions List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Laszlo Ersek Cc: qemu-devel@nongnu.org Il 22/05/2012 12:45, Laszlo Ersek ha scritto: > Signed-off-by: Laszlo Ersek > --- > 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