From patchwork Thu Sep 10 15:18:58 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark McLoughlin X-Patchwork-Id: 33333 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by bilbo.ozlabs.org (Postfix) with ESMTPS id 589EEB7080 for ; Fri, 11 Sep 2009 01:48:48 +1000 (EST) Received: from localhost ([127.0.0.1]:57636 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Mllt7-0008A6-GH for incoming@patchwork.ozlabs.org; Thu, 10 Sep 2009 11:48:45 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MllY2-0006JN-S2 for qemu-devel@nongnu.org; Thu, 10 Sep 2009 11:26:58 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MllXv-0006EN-5L for qemu-devel@nongnu.org; Thu, 10 Sep 2009 11:26:55 -0400 Received: from [199.232.76.173] (port=40189 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MllXt-0006DS-Fc for qemu-devel@nongnu.org; Thu, 10 Sep 2009 11:26:50 -0400 Received: from mail12.svc.cra.dublin.eircom.net ([159.134.118.28]:42370) by monty-python.gnu.org with smtp (Exim 4.60) (envelope-from ) id 1MllXs-00008L-8r for qemu-devel@nongnu.org; Thu, 10 Sep 2009 11:26:48 -0400 Received: (qmail 74333 messnum 1806240 invoked from network[83.71.108.236/83-71-108-236-dynamic.b-ras1.srl.dublin.eircom.net]); 10 Sep 2009 15:20:06 -0000 Received: from 83-71-108-236-dynamic.b-ras1.srl.dublin.eircom.net (HELO blaa.localdomain) (83.71.108.236) by mail12.svc.cra.dublin.eircom.net (qp 74333) with SMTP; 10 Sep 2009 15:20:06 -0000 Received: by blaa.localdomain (Postfix, from userid 500) id DEFEE41AC6; Thu, 10 Sep 2009 16:19:01 +0100 (IST) From: Mark McLoughlin To: qemu-devel@nongnu.org Date: Thu, 10 Sep 2009 16:18:58 +0100 Message-Id: <1252595941-15196-17-git-send-email-markmc@redhat.com> X-Mailer: git-send-email 1.6.2.5 In-Reply-To: <1252595941-15196-1-git-send-email-markmc@redhat.com> References: <1252595941-15196-1-git-send-email-markmc@redhat.com> X-detected-operating-system: by monty-python.gnu.org: Genre and OS details not recognized. Cc: Mark McLoughlin Subject: [Qemu-devel] [PATCH 16/19] Port host_net_add monitor command to QemuOpts X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Here is where we rely on qemu_opts_parse() to handle an empty string. We could alternatively explicitly handle this here by using qemu_opts_create() when we're not supplied any parameters, but its cleaner this way. Signed-off-by: Mark McLoughlin --- net.c | 15 +++++++++++++-- 1 files changed, 13 insertions(+), 2 deletions(-) diff --git a/net.c b/net.c index 14271ff..7812018 100644 --- a/net.c +++ b/net.c @@ -3064,13 +3064,24 @@ static int net_host_check_device(const char *device) void net_host_device_add(Monitor *mon, const QDict *qdict) { const char *device = qdict_get_str(qdict, "device"); - const char *opts = qdict_get_try_str(qdict, "opts"); + const char *opts_str = qdict_get_try_str(qdict, "opts"); + QemuOpts *opts; if (!net_host_check_device(device)) { monitor_printf(mon, "invalid host network device %s\n", device); return; } - if (net_client_init(mon, device, opts ? opts : "") < 0) { + + opts = qemu_opts_parse(&qemu_net_opts, opts_str ? opts_str : "", NULL); + if (!opts) { + monitor_printf(mon, "parsing network options '%s' failed\n", + opts_str ? opts_str : ""); + return; + } + + qemu_opt_set(opts, "type", device); + + if (net_client_init_from_opts(mon, opts) < 0) { monitor_printf(mon, "adding host network device %s failed\n", device); } }