From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:36430) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Sc0hh-0001cd-NP for qemu-devel@nongnu.org; Tue, 05 Jun 2012 16:50:17 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Sc0hb-0000Ir-Om for qemu-devel@nongnu.org; Tue, 05 Jun 2012 16:50:13 -0400 Received: from mail-pb0-f45.google.com ([209.85.160.45]:50515) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Sc0hb-0000Do-GZ for qemu-devel@nongnu.org; Tue, 05 Jun 2012 16:50:07 -0400 Received: by pbbro12 with SMTP id ro12so8637016pbb.4 for ; Tue, 05 Jun 2012 13:50:05 -0700 (PDT) Sender: Paolo Bonzini Message-ID: <4FCE70F8.2020002@redhat.com> Date: Tue, 05 Jun 2012 22:50:00 +0200 From: Paolo Bonzini MIME-Version: 1.0 References: <1337683555-13301-1-git-send-email-lersek@redhat.com> <1337683555-13301-10-git-send-email-lersek@redhat.com> In-Reply-To: <1337683555-13301-10-git-send-email-lersek@redhat.com> Content-Type: text/plain; charset=ISO-8859-15 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH 09/16] convert net_init_nic() 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.c | 39 ++++++++++++++++++++++----------------- > 1 files changed, 22 insertions(+), 17 deletions(-) > > diff --git a/net.c b/net.c > index 5ac5cf0..bd2fd23 100644 > --- a/net.c > +++ b/net.c > @@ -748,12 +748,15 @@ int net_handle_fd_param(Monitor *mon, const char *param) > return fd; > } > > -static int net_init_nic(QemuOpts *opts, const NetClientOptions *new_opts, > +static int net_init_nic(QemuOpts *old_opts, const NetClientOptions *opts, > const char *name, VLANState *vlan) > { > int idx; > NICInfo *nd; > - const char *netdev; > + const NetLegacyNicOptions *nic; > + > + assert(opts->kind == NET_CLIENT_OPTIONS_KIND_NIC); > + nic = opts->nic; > > idx = nic_get_free_idx(); > if (idx == -1 || nb_nics >= MAX_NICS) { > @@ -765,10 +768,10 @@ static int net_init_nic(QemuOpts *opts, const NetClientOptions *new_opts, > > memset(nd, 0, sizeof(*nd)); > > - if ((netdev = qemu_opt_get(opts, "netdev"))) { > - nd->netdev = qemu_find_netdev(netdev); > + if (nic->has_netdev) { > + nd->netdev = qemu_find_netdev(nic->netdev); > if (!nd->netdev) { > - error_report("netdev '%s' not found", netdev); > + error_report("netdev '%s' not found", nic->netdev); > return -1; > } > } else { > @@ -778,26 +781,28 @@ static int net_init_nic(QemuOpts *opts, const NetClientOptions *new_opts, > if (name) { > nd->name = g_strdup(name); > } > - if (qemu_opt_get(opts, "model")) { > - nd->model = g_strdup(qemu_opt_get(opts, "model")); > + if (nic->has_model) { > + nd->model = g_strdup(nic->model); > } > - if (qemu_opt_get(opts, "addr")) { > - nd->devaddr = g_strdup(qemu_opt_get(opts, "addr")); > + if (nic->has_addr) { > + nd->devaddr = g_strdup(nic->addr); > } > > - if (qemu_opt_get(opts, "macaddr") && > - net_parse_macaddr(nd->macaddr.a, qemu_opt_get(opts, "macaddr")) < 0) { > + if (nic->has_macaddr && > + net_parse_macaddr(nd->macaddr.a, nic->macaddr) < 0) { > error_report("invalid syntax for ethernet address"); > return -1; > } > qemu_macaddr_default_if_unset(&nd->macaddr); > > - nd->nvectors = qemu_opt_get_number(opts, "vectors", > - DEV_NVECTORS_UNSPECIFIED); > - if (nd->nvectors != DEV_NVECTORS_UNSPECIFIED && > - (nd->nvectors < 0 || nd->nvectors > 0x7ffffff)) { > - error_report("invalid # of vectors: %d", nd->nvectors); > - return -1; > + if (nic->has_vectors) { > + if (nic->vectors > 0x7ffffff) { Why drop the < 0 test? Paolo > + error_report("invalid # of vectors: %"PRId64, nic->vectors); > + return -1; > + } > + nd->nvectors = nic->vectors; > + } else { > + nd->nvectors = DEV_NVECTORS_UNSPECIFIED; > } > > nd->used = 1;