From patchwork Wed Sep 23 10:24:20 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark McLoughlin X-Patchwork-Id: 34142 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 ozlabs.org (Postfix) with ESMTPS id 12CBCB7B7C for ; Wed, 23 Sep 2009 21:18:19 +1000 (EST) Received: from localhost ([127.0.0.1]:58690 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MqPrS-0002ph-0B for incoming@patchwork.ozlabs.org; Wed, 23 Sep 2009 07:18:14 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MqP2t-0003nx-Ml for qemu-devel@nongnu.org; Wed, 23 Sep 2009 06:25:59 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MqP2j-0003i7-Bf for qemu-devel@nongnu.org; Wed, 23 Sep 2009 06:25:55 -0400 Received: from [199.232.76.173] (port=37825 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MqP2i-0003hb-LD for qemu-devel@nongnu.org; Wed, 23 Sep 2009 06:25:48 -0400 Received: from mx1.redhat.com ([209.132.183.28]:55435) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1MqP2h-0001W4-Ll for qemu-devel@nongnu.org; Wed, 23 Sep 2009 06:25:48 -0400 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id n8NAPkJu003186 for ; Wed, 23 Sep 2009 06:25:46 -0400 Received: from blaa.localdomain (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id n8NAPjAB012363; Wed, 23 Sep 2009 06:25:46 -0400 Received: by blaa.localdomain (Postfix, from userid 500) id 73D0047447; Wed, 23 Sep 2009 11:24:24 +0100 (IST) From: Mark McLoughlin To: qemu-devel@nongnu.org Date: Wed, 23 Sep 2009 11:24:20 +0100 Message-Id: <1253701463-3134-22-git-send-email-markmc@redhat.com> In-Reply-To: <1253701463-3134-1-git-send-email-markmc@redhat.com> References: <1253701463-3134-1-git-send-email-markmc@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.11 X-detected-operating-system: by monty-python.gnu.org: Genre and OS details not recognized. Cc: Mark McLoughlin Subject: [Qemu-devel] [PATCH 21/24] 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 8da5eba..f66df04 100644 --- a/net.c +++ b/net.c @@ -3091,13 +3091,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); } }