From patchwork Wed Sep 23 10:24:17 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark McLoughlin X-Patchwork-Id: 34145 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 C6989B7B7D for ; Wed, 23 Sep 2009 21:24:06 +1000 (EST) Received: from localhost ([127.0.0.1]:42854 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MqPx5-0005Uj-Ng for incoming@patchwork.ozlabs.org; Wed, 23 Sep 2009 07:24:03 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MqP2x-0003qQ-3g for qemu-devel@nongnu.org; Wed, 23 Sep 2009 06:26:03 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MqP2k-0003iB-HH for qemu-devel@nongnu.org; Wed, 23 Sep 2009 06:25:54 -0400 Received: from [199.232.76.173] (port=37820 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MqP2i-0003hW-Jt for qemu-devel@nongnu.org; Wed, 23 Sep 2009 06:25:48 -0400 Received: from mx1.redhat.com ([209.132.183.28]:14971) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1MqP2h-0001Vs-B9 for qemu-devel@nongnu.org; Wed, 23 Sep 2009 06:25:47 -0400 Received: from int-mx03.intmail.prod.int.phx2.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id n8NAPk0Z020497 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-mx03.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id n8NAPhEn011072; Wed, 23 Sep 2009 06:25:45 -0400 Received: by blaa.localdomain (Postfix, from userid 500) id 50BE847444; Wed, 23 Sep 2009 11:24:24 +0100 (IST) From: Mark McLoughlin To: qemu-devel@nongnu.org Date: Wed, 23 Sep 2009 11:24:17 +0100 Message-Id: <1253701463-3134-19-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.16 X-detected-operating-system: by monty-python.gnu.org: Genre and OS details not recognized. Cc: Mark McLoughlin Subject: [Qemu-devel] [PATCH 18/24] Port -net vde 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 The net_vde_init() change is needed because we now pass NULL pointers instead of empty strings for group/sock if they're not set. Signed-off-by: Mark McLoughlin --- net.c | 94 ++++++++++++++++++++++++++++++++++++++++------------------------- 1 files changed, 58 insertions(+), 36 deletions(-) diff --git a/net.c b/net.c index f2bc9f8..e439b59 100644 --- a/net.c +++ b/net.c @@ -1744,8 +1744,8 @@ static int net_vde_init(VLANState *vlan, const char *model, int port, const char *group, int mode) { VDEState *s; - char *init_group = strlen(group) ? (char *)group : NULL; - char *init_sock = strlen(sock) ? (char *)sock : NULL; + char *init_group = (char *)group; + char *init_sock = (char *)sock; struct vde_open_args args = { .port = port, @@ -2712,6 +2712,34 @@ static int net_init_socket(QemuOpts *opts, Monitor *mon) return 0; } +#ifdef CONFIG_VDE +static int net_init_vde(QemuOpts *opts, Monitor *mon) +{ + VLANState *vlan; + const char *name; + const char *sock; + const char *group; + int port, mode; + + vlan = qemu_find_vlan(qemu_opt_get_number(opts, "vlan", 0), 1); + + name = qemu_opt_get(opts, "name"); + sock = qemu_opt_get(opts, "sock"); + group = qemu_opt_get(opts, "group"); + + port = qemu_opt_get_number(opts, "port", 0); + mode = qemu_opt_get_number(opts, "mode", 0700); + + if (net_vde_init(vlan, "vde", name, sock, port, group, mode) == -1) { + return -1; + } + + vlan->nb_host_devs++; + + return 0; +} +#endif + #define NET_COMMON_PARAMS_DESC \ { \ .name = "type", \ @@ -2898,6 +2926,32 @@ static struct { }, { /* end of list */ } }, +#ifdef CONFIG_VDE + }, { + .type = "vde", + .init = net_init_vde, + .desc = { + NET_COMMON_PARAMS_DESC, + { + .name = "sock", + .type = QEMU_OPT_STRING, + .help = "socket path", + }, { + .name = "port", + .type = QEMU_OPT_NUMBER, + .help = "port number", + }, { + .name = "group", + .type = QEMU_OPT_STRING, + .help = "group owner of socket", + }, { + .name = "mode", + .type = QEMU_OPT_NUMBER, + .help = "permissions for socket", + }, + { /* end of list */ } + }, +#endif }, { /* end of list */ } }; @@ -2942,7 +2996,8 @@ int net_client_init(Monitor *mon, const char *device, const char *p) !strcmp(device, "nic") || !strcmp(device, "user") || !strcmp(device, "tap") || - !strcmp(device, "socket")) { + !strcmp(device, "socket") || + !strcmp(device, "vde")) { QemuOpts *opts; opts = qemu_opts_parse(&qemu_net_opts, p, NULL); @@ -2981,39 +3036,6 @@ int net_client_init(Monitor *mon, const char *device, const char *p) ret = 0; } else #endif -#ifdef CONFIG_VDE - if (!strcmp(device, "vde")) { - static const char * const vde_params[] = { - "vlan", "name", "sock", "port", "group", "mode", NULL - }; - char vde_sock[1024], vde_group[512]; - int vde_port, vde_mode; - - if (check_params(buf, sizeof(buf), vde_params, p) < 0) { - config_error(mon, "invalid parameter '%s' in '%s'\n", buf, p); - ret = -1; - goto out; - } - vlan->nb_host_devs++; - if (get_param_value(vde_sock, sizeof(vde_sock), "sock", p) <= 0) { - vde_sock[0] = '\0'; - } - if (get_param_value(buf, sizeof(buf), "port", p) > 0) { - vde_port = strtol(buf, NULL, 10); - } else { - vde_port = 0; - } - if (get_param_value(vde_group, sizeof(vde_group), "group", p) <= 0) { - vde_group[0] = '\0'; - } - if (get_param_value(buf, sizeof(buf), "mode", p) > 0) { - vde_mode = strtol(buf, NULL, 8); - } else { - vde_mode = 0700; - } - ret = net_vde_init(vlan, device, name, vde_sock, vde_port, vde_group, vde_mode); - } else -#endif if (!strcmp(device, "dump")) { int len = 65536;