From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Mv8QM-0005ln-VQ for qemu-devel@nongnu.org; Tue, 06 Oct 2009 07:41:47 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Mv8QG-0005iq-Ka for qemu-devel@nongnu.org; Tue, 06 Oct 2009 07:41:45 -0400 Received: from [199.232.76.173] (port=52562 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Mv8QF-0005iX-Tb for qemu-devel@nongnu.org; Tue, 06 Oct 2009 07:41:40 -0400 Received: from mx1.redhat.com ([209.132.183.28]:23316) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1Mv8QF-0002rX-DY for qemu-devel@nongnu.org; Tue, 06 Oct 2009 07:41:39 -0400 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id n96BIrgZ017681 for ; Tue, 6 Oct 2009 07:18:53 -0400 From: Mark McLoughlin Date: Tue, 6 Oct 2009 12:17:14 +0100 Message-Id: <1254827836-11021-25-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 usb net 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 We need net_client_init_from_opts() exported for this Signed-off-by: Mark McLoughlin --- net.c | 2 +- net.h | 2 ++ vl.c | 19 +++++++++++++++---- 3 files changed, 18 insertions(+), 5 deletions(-) diff --git a/net.c b/net.c index 1ebf147..c8c8c78 100644 --- a/net.c +++ b/net.c @@ -3001,7 +3001,7 @@ static struct { { /* end of list */ } }; -static int net_client_init_from_opts(Monitor *mon, QemuOpts *opts) +int net_client_init_from_opts(Monitor *mon, QemuOpts *opts) { const char *type; int i; diff --git a/net.h b/net.h index a2d5b3c..27a1c50 100644 --- a/net.h +++ b/net.h @@ -4,6 +4,7 @@ #include "qemu-queue.h" #include "qemu-common.h" #include "qdict.h" +#include "qemu-option.h" /* VLANs support */ @@ -136,6 +137,7 @@ extern const char *legacy_tftp_prefix; extern const char *legacy_bootp_filename; int net_client_init(Monitor *mon, const char *device, const char *p); +int net_client_init_from_opts(Monitor *mon, QemuOpts *opts); void net_client_uninit(NICInfo *nd); int net_client_parse(const char *str); int net_slirp_smb(const char *exported_dir); diff --git a/vl.c b/vl.c index 811f26d..70d1aed 100644 --- a/vl.c +++ b/vl.c @@ -2593,12 +2593,23 @@ static int usb_device_add(const char *devname, int is_hotplug) dev = usb_baum_init(); #endif } else if (strstart(devname, "net:", &p)) { - int nic = nb_nics; + QemuOpts *opts; + int idx; - if (net_client_init(NULL, "nic", p) < 0) + opts = qemu_opts_parse(&qemu_net_opts, p, NULL); + if (!opts) { return -1; - nd_table[nic].model = qemu_strdup("usb"); - dev = usb_net_init(&nd_table[nic]); + } + + qemu_opt_set(opts, "type", "nic"); + qemu_opt_set(opts, "model", "usb"); + + idx = net_client_init_from_opts(NULL, opts); + if (idx == -1) { + return -1; + } + + dev = usb_net_init(&nd_table[idx]); } else if (!strcmp(devname, "bt") || strstart(devname, "bt:", &p)) { dev = usb_bt_init(devname[2] ? hci_init(p) : bt_new_hci(qemu_find_bt_vlan(0))); -- 1.6.2.5