From patchwork Mon Jul 23 11:50:37 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Hajnoczi X-Patchwork-Id: 172644 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 5ACF92C0342 for ; Mon, 23 Jul 2012 22:03:30 +1000 (EST) Received: from localhost ([::1]:58432 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1StHBF-0007pK-Jo for incoming@patchwork.ozlabs.org; Mon, 23 Jul 2012 07:52:05 -0400 Received: from eggs.gnu.org ([208.118.235.92]:53971) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1StHAK-0005Pr-GG for qemu-devel@nongnu.org; Mon, 23 Jul 2012 07:51:11 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1StHAE-0000V5-LL for qemu-devel@nongnu.org; Mon, 23 Jul 2012 07:51:08 -0400 Received: from e06smtp14.uk.ibm.com ([195.75.94.110]:57275) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1StHAE-0000Uh-CY for qemu-devel@nongnu.org; Mon, 23 Jul 2012 07:51:02 -0400 Received: from /spool/local by e06smtp14.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 23 Jul 2012 12:51:01 +0100 Received: from d06nrmr1806.portsmouth.uk.ibm.com (9.149.39.193) by e06smtp14.uk.ibm.com (192.168.101.144) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Mon, 23 Jul 2012 12:50:59 +0100 Received: from d06av10.portsmouth.uk.ibm.com (d06av10.portsmouth.uk.ibm.com [9.149.37.251]) by d06nrmr1806.portsmouth.uk.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id q6NBowmL1540146 for ; Mon, 23 Jul 2012 12:50:58 +0100 Received: from d06av10.portsmouth.uk.ibm.com (loopback [127.0.0.1]) by d06av10.portsmouth.uk.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id q6NBROt5020594 for ; Mon, 23 Jul 2012 07:27:24 -0400 Received: from localhost (stefanha-thinkpad.manchester-maybrook.uk.ibm.com [9.174.219.145]) by d06av10.portsmouth.uk.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with ESMTP id q6NBRNwf020589; Mon, 23 Jul 2012 07:27:23 -0400 From: Stefan Hajnoczi To: Anthony Liguori Date: Mon, 23 Jul 2012 12:50:37 +0100 Message-Id: <1343044244-28728-13-git-send-email-stefanha@linux.vnet.ibm.com> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1343044244-28728-1-git-send-email-stefanha@linux.vnet.ibm.com> References: <1343044244-28728-1-git-send-email-stefanha@linux.vnet.ibm.com> x-cbid: 12072311-1948-0000-0000-000002788B8B X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 195.75.94.110 Cc: Laszlo Ersek , qemu-devel@nongnu.org, Stefan Hajnoczi Subject: [Qemu-devel] [PATCH 12/19] convert net_init_nic() to NetClientOptions X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Laszlo Ersek v1->v2: - NetLegacyNicOptions::vectors is of type uint32 Signed-off-by: Laszlo Ersek Signed-off-by: Stefan Hajnoczi --- net.c | 39 ++++++++++++++++++++++----------------- 1 file changed, 22 insertions(+), 17 deletions(-) diff --git a/net.c b/net.c index af544b2..a62e902 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) { + error_report("invalid # of vectors: %"PRIu32, nic->vectors); + return -1; + } + nd->nvectors = nic->vectors; + } else { + nd->nvectors = DEV_NVECTORS_UNSPECIFIED; } nd->used = 1;