From patchwork Fri Aug 21 15:37:01 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?UTF-8?B?Wm9sdMOhbiBLxZF2w6Fnw7M=?= X-Patchwork-Id: 509530 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 004C3140772 for ; Sat, 22 Aug 2015 01:43:45 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b=InXM6Ns3; dkim-atps=neutral Received: from localhost ([::1]:42186 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZSoTm-0002sd-Gx for incoming@patchwork.ozlabs.org; Fri, 21 Aug 2015 11:43:42 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50601) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZSoO3-00027F-EQ for qemu-devel@nongnu.org; Fri, 21 Aug 2015 11:37:49 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZSoO1-000208-BM for qemu-devel@nongnu.org; Fri, 21 Aug 2015 11:37:47 -0400 Received: from mail-wi0-x229.google.com ([2a00:1450:400c:c05::229]:37597) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZSoO1-0001zx-0I for qemu-devel@nongnu.org; Fri, 21 Aug 2015 11:37:45 -0400 Received: by widdq5 with SMTP id dq5so19211570wid.0 for ; Fri, 21 Aug 2015 08:37:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-type:content-transfer-encoding; bh=SmU6Z7LcJXtAXn74NtOFmYX4PdeTyqupAasRn/1twqg=; b=InXM6Ns31dPXd32WkLgzBNpmZ61BFfwOKWw+KcAEVZLSXxB9LAI65ZiBex2qIuyGZn 85PYsyAfE9edXUqhF68zuVuarfeQTmHg0I8/8wlE8n14LN7n+csnazPYMoaglP77QWFx VynN/vf5rqLWSSfP61e6B/VZzn7kkGLMzrB4L83UQv6jAQS2V+HIhdxqd+6y5jmaCAg1 veNaeFM+ewCGp4cZ9lATyioTpSH3bfBJ8+R6N9aMW30wKTVhBntDP5ZgFfIL4ZldUWLz rESxf/ZWRscaODTUF5s1yl3y0jthgzC/GV4k5Hfzi/0sZ06lahBNA8WhAEz5oKD7DIYp 4f0Q== X-Received: by 10.180.211.10 with SMTP id my10mr6717703wic.41.1440171464286; Fri, 21 Aug 2015 08:37:44 -0700 (PDT) Received: from nullptr.home.dirty-ice.org (178-164-172-216.pool.digikabel.hu. [178.164.172.216]) by smtp.gmail.com with ESMTPSA id v8sm10479895wjr.15.2015.08.21.08.37.43 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 21 Aug 2015 08:37:43 -0700 (PDT) From: "=?UTF-8?q?K=C5=91v=C3=A1g=C3=B3=2C=20Zolt=C3=A1n?=" X-Google-Original-From: =?UTF-8?q?K=C5=91v=C3=A1g=C3=B3=2C=20Zolt=C3=A1n?= To: qemu-devel@nongnu.org Date: Fri, 21 Aug 2015 17:37:01 +0200 Message-Id: X-Mailer: git-send-email 2.5.0 In-Reply-To: References: MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2a00:1450:400c:c05::229 Cc: "Michael S. Tsirkin" , Jason Wang , Vincenzo Maffione , Gerd Hoffmann , Stefan Hajnoczi , Giuseppe Lettieri , Luigi Rizzo Subject: [Qemu-devel] [PATCH v2 05/49] net: use Netdev instead of NetClientOptions in client init X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org This way we no longer need NetClientOptions and can convert Netdev into a flat union. Signed-off-by: Kővágó, Zoltán Reviewed-by: Eric Blake --- net/clients.h | 20 ++++++++++---------- net/dump.c | 6 +++--- net/hub.c | 6 +++--- net/l2tpv3.c | 6 +++--- net/net.c | 29 ++++++++++++++--------------- net/netmap.c | 4 ++-- net/slirp.c | 6 +++--- net/socket.c | 6 +++--- net/tap-win32.c | 6 +++--- net/tap.c | 12 ++++++------ net/vde.c | 6 +++--- net/vhost-user.c | 6 +++--- 12 files changed, 56 insertions(+), 57 deletions(-) diff --git a/net/clients.h b/net/clients.h index d47530e..5cae479 100644 --- a/net/clients.h +++ b/net/clients.h @@ -27,39 +27,39 @@ #include "net/net.h" #include "qapi-types.h" -int net_init_dump(const NetClientOptions *opts, const char *name, +int net_init_dump(const Netdev *netdev, const char *name, NetClientState *peer, Error **errp); #ifdef CONFIG_SLIRP -int net_init_slirp(const NetClientOptions *opts, const char *name, +int net_init_slirp(const Netdev *netdev, const char *name, NetClientState *peer, Error **errp); #endif -int net_init_hubport(const NetClientOptions *opts, const char *name, +int net_init_hubport(const Netdev *netdev, const char *name, NetClientState *peer, Error **errp); -int net_init_socket(const NetClientOptions *opts, const char *name, +int net_init_socket(const Netdev *netdev, const char *name, NetClientState *peer, Error **errp); -int net_init_tap(const NetClientOptions *opts, const char *name, +int net_init_tap(const Netdev *netdev, const char *name, NetClientState *peer, Error **errp); -int net_init_bridge(const NetClientOptions *opts, const char *name, +int net_init_bridge(const Netdev *netdev, const char *name, NetClientState *peer, Error **errp); -int net_init_l2tpv3(const NetClientOptions *opts, const char *name, +int net_init_l2tpv3(const Netdev *netdev, const char *name, NetClientState *peer, Error **errp); #ifdef CONFIG_VDE -int net_init_vde(const NetClientOptions *opts, const char *name, +int net_init_vde(const Netdev *netdev, const char *name, NetClientState *peer, Error **errp); #endif #ifdef CONFIG_NETMAP -int net_init_netmap(const NetClientOptions *opts, const char *name, +int net_init_netmap(const Netdev *netdev, const char *name, NetClientState *peer, Error **errp); #endif -int net_init_vhost_user(const NetClientOptions *opts, const char *name, +int net_init_vhost_user(const Netdev *netdev, const char *name, NetClientState *peer, Error **errp); #endif /* QEMU_NET_CLIENTS_H */ diff --git a/net/dump.c b/net/dump.c index 02c8064..d80fa94 100644 --- a/net/dump.c +++ b/net/dump.c @@ -146,7 +146,7 @@ static int net_dump_init(NetClientState *peer, const char *device, return 0; } -int net_init_dump(const NetClientOptions *opts, const char *name, +int net_init_dump(const Netdev *netdev, const char *name, NetClientState *peer, Error **errp) { int len; @@ -154,8 +154,8 @@ int net_init_dump(const NetClientOptions *opts, const char *name, char def_file[128]; const NetdevDumpOptions *dump; - assert(opts->kind == NET_CLIENT_OPTIONS_KIND_DUMP); - dump = opts->dump; + assert(netdev->opts->kind == NET_CLIENT_OPTIONS_KIND_DUMP); + dump = netdev->opts->dump; assert(peer); diff --git a/net/hub.c b/net/hub.c index 3047f12..29f65b2 100644 --- a/net/hub.c +++ b/net/hub.c @@ -280,14 +280,14 @@ int net_hub_id_for_client(NetClientState *nc, int *id) return 0; } -int net_init_hubport(const NetClientOptions *opts, const char *name, +int net_init_hubport(const Netdev *netdev, const char *name, NetClientState *peer, Error **errp) { const NetdevHubPortOptions *hubport; - assert(opts->kind == NET_CLIENT_OPTIONS_KIND_HUBPORT); + assert(netdev->opts->kind == NET_CLIENT_OPTIONS_KIND_HUBPORT); assert(!peer); - hubport = opts->hubport; + hubport = netdev->opts->hubport; net_hub_add_port(hubport->hubid, name); return 0; diff --git a/net/l2tpv3.c b/net/l2tpv3.c index 4f9bcee..d2f8431 100644 --- a/net/l2tpv3.c +++ b/net/l2tpv3.c @@ -524,7 +524,7 @@ static NetClientInfo net_l2tpv3_info = { .cleanup = net_l2tpv3_cleanup, }; -int net_init_l2tpv3(const NetClientOptions *opts, +int net_init_l2tpv3(const Netdev *netdev, const char *name, NetClientState *peer, Error **errp) { @@ -545,8 +545,8 @@ int net_init_l2tpv3(const NetClientOptions *opts, s->queue_tail = 0; s->header_mismatch = false; - assert(opts->kind == NET_CLIENT_OPTIONS_KIND_L2TPV3); - l2tpv3 = opts->l2tpv3; + assert(netdev->opts->kind == NET_CLIENT_OPTIONS_KIND_L2TPV3); + l2tpv3 = netdev->opts->l2tpv3; if (l2tpv3->has_ipv6 && l2tpv3->ipv6) { s->ipv6 = l2tpv3->ipv6; diff --git a/net/net.c b/net/net.c index 10fbaca..339f188 100644 --- a/net/net.c +++ b/net/net.c @@ -813,15 +813,15 @@ int qemu_find_nic_model(NICInfo *nd, const char * const *models, return -1; } -static int net_init_nic(const NetClientOptions *opts, const char *name, +static int net_init_nic(const Netdev *netdev, const char *name, NetClientState *peer, Error **errp) { int idx; NICInfo *nd; const NetLegacyNicOptions *nic; - assert(opts->kind == NET_CLIENT_OPTIONS_KIND_NIC); - nic = opts->nic; + assert(netdev->opts->kind == NET_CLIENT_OPTIONS_KIND_NIC); + nic = netdev->opts->nic; idx = nic_get_free_idx(); if (idx == -1 || nb_nics >= MAX_NICS) { @@ -882,7 +882,7 @@ static int net_init_nic(const NetClientOptions *opts, const char *name, static int (* const net_client_init_fun[NET_CLIENT_OPTIONS_KIND_MAX])( - const NetClientOptions *opts, + const Netdev *netdev, const char *name, NetClientState *peer, Error **errp) = { [NET_CLIENT_OPTIONS_KIND_NIC] = net_init_nic, @@ -913,7 +913,6 @@ static int (* const net_client_init_fun[NET_CLIENT_OPTIONS_KIND_MAX])( static int net_client_init1(const Netdev *netdev, int is_netdev, Error **errp) { - const NetClientOptions *opts = netdev->opts; const char *name; NetClientState *peer = NULL; @@ -934,9 +933,9 @@ static int net_client_init1(const Netdev *netdev, int is_netdev, Error **errp) return -1; } - if (opts->kind == NET_CLIENT_OPTIONS_KIND_DUMP || - opts->kind == NET_CLIENT_OPTIONS_KIND_NIC || - !net_client_init_fun[opts->kind]) { + if (netdev->opts->kind == NET_CLIENT_OPTIONS_KIND_DUMP || + netdev->opts->kind == NET_CLIENT_OPTIONS_KIND_NIC || + !net_client_init_fun[netdev->opts->kind]) { error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "type", "a netdev backend type"); return -1; @@ -945,16 +944,16 @@ static int net_client_init1(const Netdev *netdev, int is_netdev, Error **errp) /* missing optional values have been initialized to "all bits zero" */ name = netdev->has_id ? netdev->id : netdev->name; - if (opts->kind == NET_CLIENT_OPTIONS_KIND_NONE) { + if (netdev->opts->kind == NET_CLIENT_OPTIONS_KIND_NONE) { return 0; /* nothing to do */ } - if (opts->kind == NET_CLIENT_OPTIONS_KIND_HUBPORT) { + if (netdev->opts->kind == NET_CLIENT_OPTIONS_KIND_HUBPORT) { error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "type", "a net type"); return -1; } - if (!net_client_init_fun[opts->kind]) { + if (!net_client_init_fun[netdev->opts->kind]) { error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "type", "a net backend type (maybe it is not compiled " "into this binary)"); @@ -962,17 +961,17 @@ static int net_client_init1(const Netdev *netdev, int is_netdev, Error **errp) } /* Do not add to a vlan if it's a nic with a netdev= parameter. */ - if (opts->kind != NET_CLIENT_OPTIONS_KIND_NIC || - !opts->nic->has_netdev) { + if (netdev->opts->kind != NET_CLIENT_OPTIONS_KIND_NIC || + !netdev->opts->nic->has_netdev) { peer = net_hub_add_port(netdev->has_vlan ? netdev->vlan : 0, NULL); } } - if (net_client_init_fun[opts->kind](opts, name, peer, errp) < 0) { + if (net_client_init_fun[netdev->opts->kind](netdev, name, peer, errp) < 0) { /* FIXME drop when all init functions store an Error */ if (errp && !*errp) { error_setg(errp, QERR_DEVICE_INIT_FAILED, - NetClientOptionsKind_lookup[opts->kind]); + NetClientOptionsKind_lookup[netdev->opts->kind]); } return -1; } diff --git a/net/netmap.c b/net/netmap.c index 508b829..a464618 100644 --- a/net/netmap.c +++ b/net/netmap.c @@ -435,11 +435,11 @@ static NetClientInfo net_netmap_info = { * * ... -net netmap,ifname="..." */ -int net_init_netmap(const NetClientOptions *opts, +int net_init_netmap(const Netdev *netdev, const char *name, NetClientState *peer, Error **errp) { /* FIXME error_setg(errp, ...) on failure */ - const NetdevNetmapOptions *netmap_opts = opts->netmap; + const NetdevNetmapOptions *netmap_opts = netdev->opts->netmap; NetClientState *nc; NetmapPriv me; NetmapState *s; diff --git a/net/slirp.c b/net/slirp.c index 7657b38..0fc2c52 100644 --- a/net/slirp.c +++ b/net/slirp.c @@ -736,7 +736,7 @@ static const char **slirp_dnssearch(const StringList *dnsname) return ret; } -int net_init_slirp(const NetClientOptions *opts, const char *name, +int net_init_slirp(const Netdev *netdev, const char *name, NetClientState *peer, Error **errp) { /* FIXME error_setg(errp, ...) on failure */ @@ -746,8 +746,8 @@ int net_init_slirp(const NetClientOptions *opts, const char *name, const NetdevUserOptions *user; const char **dnssearch; - assert(opts->kind == NET_CLIENT_OPTIONS_KIND_USER); - user = opts->user; + assert(netdev->opts->kind == NET_CLIENT_OPTIONS_KIND_USER); + user = netdev->opts->user; vnet = user->has_net ? g_strdup(user->net) : user->has_ip ? g_strdup_printf("%s/24", user->ip) : diff --git a/net/socket.c b/net/socket.c index b1e3b1c..75f693c 100644 --- a/net/socket.c +++ b/net/socket.c @@ -699,15 +699,15 @@ static int net_socket_udp_init(NetClientState *peer, return 0; } -int net_init_socket(const NetClientOptions *opts, const char *name, +int net_init_socket(const Netdev *netdev, const char *name, NetClientState *peer, Error **errp) { /* FIXME error_setg(errp, ...) on failure */ Error *err = NULL; const NetdevSocketOptions *sock; - assert(opts->kind == NET_CLIENT_OPTIONS_KIND_SOCKET); - sock = opts->socket; + assert(netdev->opts->kind == NET_CLIENT_OPTIONS_KIND_SOCKET); + sock = netdev->opts->socket; if (sock->has_fd + sock->has_listen + sock->has_connect + sock->has_mcast + sock->has_udp != 1) { diff --git a/net/tap-win32.c b/net/tap-win32.c index 625d53c..acce480 100644 --- a/net/tap-win32.c +++ b/net/tap-win32.c @@ -761,14 +761,14 @@ static int tap_win32_init(NetClientState *peer, const char *model, return 0; } -int net_init_tap(const NetClientOptions *opts, const char *name, +int net_init_tap(const Netdev *netdev, const char *name, NetClientState *peer, Error **errp) { /* FIXME error_setg(errp, ...) on failure */ const NetdevTapOptions *tap; - assert(opts->kind == NET_CLIENT_OPTIONS_KIND_TAP); - tap = opts->tap; + assert(netdev->opts->kind == NET_CLIENT_OPTIONS_KIND_TAP); + tap = netdev->opts->tap; if (!tap->has_ifname) { error_report("tap: no interface name"); diff --git a/net/tap.c b/net/tap.c index bd01590..263f807 100644 --- a/net/tap.c +++ b/net/tap.c @@ -557,7 +557,7 @@ static int net_bridge_run_helper(const char *helper, const char *bridge, } } -int net_init_bridge(const NetClientOptions *opts, const char *name, +int net_init_bridge(const Netdev *netdev, const char *name, NetClientState *peer, Error **errp) { const NetdevBridgeOptions *bridge; @@ -565,8 +565,8 @@ int net_init_bridge(const NetClientOptions *opts, const char *name, TAPState *s; int fd, vnet_hdr; - assert(opts->kind == NET_CLIENT_OPTIONS_KIND_BRIDGE); - bridge = opts->bridge; + assert(netdev->opts->kind == NET_CLIENT_OPTIONS_KIND_BRIDGE); + bridge = netdev->opts->bridge; helper = bridge->has_helper ? bridge->helper : DEFAULT_BRIDGE_HELPER; br = bridge->has_br ? bridge->br : DEFAULT_BRIDGE_INTERFACE; @@ -716,7 +716,7 @@ static int get_fds(char *str, char *fds[], int max) return i; } -int net_init_tap(const NetClientOptions *opts, const char *name, +int net_init_tap(const Netdev *netdev, const char *name, NetClientState *peer, Error **errp) { const NetdevTapOptions *tap; @@ -728,8 +728,8 @@ int net_init_tap(const NetClientOptions *opts, const char *name, const char *vhostfdname; char ifname[128]; - assert(opts->kind == NET_CLIENT_OPTIONS_KIND_TAP); - tap = opts->tap; + assert(netdev->opts->kind == NET_CLIENT_OPTIONS_KIND_TAP); + tap = netdev->opts->tap; queues = tap->has_queues ? tap->queues : 1; vhostfdname = tap->has_vhostfd ? tap->vhostfd : NULL; diff --git a/net/vde.c b/net/vde.c index dacaa64..0ac2525 100644 --- a/net/vde.c +++ b/net/vde.c @@ -109,14 +109,14 @@ static int net_vde_init(NetClientState *peer, const char *model, return 0; } -int net_init_vde(const NetClientOptions *opts, const char *name, +int net_init_vde(const Netdev *netdev, const char *name, NetClientState *peer, Error **errp) { /* FIXME error_setg(errp, ...) on failure */ const NetdevVdeOptions *vde; - assert(opts->kind == NET_CLIENT_OPTIONS_KIND_VDE); - vde = opts->vde; + assert(netdev->opts->kind == NET_CLIENT_OPTIONS_KIND_VDE); + vde = netdev->opts->vde; /* missing optional values have been initialized to "all bits zero" */ if (net_vde_init(peer, "vde", name, vde->sock, vde->port, vde->group, diff --git a/net/vhost-user.c b/net/vhost-user.c index 93dcecd..20981a9 100644 --- a/net/vhost-user.c +++ b/net/vhost-user.c @@ -223,14 +223,14 @@ static int net_vhost_check_net(void *opaque, QemuOpts *opts, Error **errp) return 0; } -int net_init_vhost_user(const NetClientOptions *opts, const char *name, +int net_init_vhost_user(const Netdev *netdev, const char *name, NetClientState *peer, Error **errp) { const NetdevVhostUserOptions *vhost_user_opts; CharDriverState *chr; - assert(opts->kind == NET_CLIENT_OPTIONS_KIND_VHOST_USER); - vhost_user_opts = opts->vhost_user; + assert(netdev->opts->kind == NET_CLIENT_OPTIONS_KIND_VHOST_USER); + vhost_user_opts = netdev->opts->vhost_user; chr = net_vhost_parse_chardev(vhost_user_opts, errp); if (!chr) {