From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Mv8VE-0001ES-M7 for qemu-devel@nongnu.org; Tue, 06 Oct 2009 07:46:48 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Mv8VB-00018y-4j for qemu-devel@nongnu.org; Tue, 06 Oct 2009 07:46:48 -0400 Received: from [199.232.76.173] (port=38501 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Mv8VA-00018Y-La for qemu-devel@nongnu.org; Tue, 06 Oct 2009 07:46:44 -0400 Received: from mx1.redhat.com ([209.132.183.28]:6444) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1Mv8V9-0003ec-Mk for qemu-devel@nongnu.org; Tue, 06 Oct 2009 07:46:44 -0400 Received: from int-mx05.intmail.prod.int.phx2.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.18]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id n96BIraR028458 for ; Tue, 6 Oct 2009 07:18:53 -0400 From: Mark McLoughlin Date: Tue, 6 Oct 2009 12:17:13 +0100 Message-Id: <1254827836-11021-24-git-send-email-markmc@redhat.com> In-Reply-To: <1254827783.2720.42.camel@blaa> References: <1254827783.2720.42.camel@blaa> Subject: [Qemu-devel] [PATCH] Port host_net_add monitor command to QemuOpts List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Mark McLoughlin 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 534305c..1ebf147 100644 --- a/net.c +++ b/net.c @@ -3101,13 +3101,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); } } -- 1.6.2.5