From: Eric Blake <eblake@redhat.com>
To: qemu-devel@nongnu.org
Cc: "Michael S. Tsirkin" <mst@redhat.com>,
"Jason Wang" <jasowang@redhat.com>,
armbru@redhat.com, "Vincenzo Maffione" <v.maffione@gmail.com>,
"Stefan Hajnoczi" <stefanha@redhat.com>,
"Kővágó, Zoltán" <dirty.ice.hu@gmail.com>,
marcandre.lureau@redhat.com,
"Giuseppe Lettieri" <g.lettieri@iet.unipi.it>,
"Luigi Rizzo" <rizzo@iet.unipi.it>
Subject: [Qemu-devel] [PATCH RFC v4 02/29] net: use Netdev instead of NetClientOptions in client init
Date: Wed, 9 Sep 2015 22:06:04 -0600 [thread overview]
Message-ID: <1441857991-7309-3-git-send-email-eblake@redhat.com> (raw)
In-Reply-To: <1441857991-7309-1-git-send-email-eblake@redhat.com>
From: Kővágó, Zoltán <dirty.ice.hu@gmail.com>
This way we no longer need NetClientOptions and can convert Netdev
into a flat union.
Signed-off-by: Kővágó, Zoltán <DirtY.iCE.hu@gmail.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Message-Id: <93ffdfed7054529635e6acb935150d95dc173a12.1441627176.git.DirtY.iCE.hu@gmail.com>
[rework net_client_init1() to pass Netdev by copying from NetdevLegacy,
rather than merging the two types.]
Signed-off-by: Eric Blake <eblake@redhat.com>
---
net/clients.h | 20 ++++++++++----------
net/dump.c | 6 +++---
net/hub.c | 6 +++---
net/l2tpv3.c | 6 +++---
net/net.c | 18 +++++++++++-------
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, 53 insertions(+), 49 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 28a5597..4d99b48 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,
@@ -914,11 +914,13 @@ static int (* const net_client_init_fun[NET_CLIENT_OPTIONS_KIND_MAX])(
static int net_client_init1(const void *object, int is_netdev, Error **errp)
{
const NetClientOptions *opts;
+ Netdev legacy = {0};
+ const Netdev *netdev;
const char *name;
NetClientState *peer = NULL;
if (is_netdev) {
- const Netdev *netdev = object;
+ netdev = object;
opts = netdev->opts;
name = netdev->id;
@@ -931,7 +933,9 @@ static int net_client_init1(const void *object, int is_netdev, Error **errp)
}
} else {
const NetLegacy *net = object;
- opts = net->opts;
+ legacy.id = net->id;
+ opts = legacy.opts = net->opts;
+ netdev = &legacy;
/* missing optional values have been initialized to "all bits zero" */
name = net->has_id ? net->id : net->name;
@@ -958,7 +962,7 @@ static int net_client_init1(const void *object, int is_netdev, Error **errp)
}
}
- if (net_client_init_fun[opts->kind](opts, name, peer, errp) < 0) {
+ if (net_client_init_fun[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,
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) {
--
2.4.3
next prev parent reply other threads:[~2015-09-10 4:06 UTC|newest]
Thread overview: 40+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-09-10 4:06 [Qemu-devel] [PATCH RFC v4 00/29] qapi-ify netdev_add, and other post-introspection cleanups Eric Blake
2015-09-10 4:06 ` [Qemu-devel] [PATCH RFC v4 01/29] qapi: Provide nicer array names in introspection Eric Blake
2015-09-10 4:06 ` Eric Blake [this message]
2015-09-10 4:06 ` [Qemu-devel] [PATCH RFC v4 03/29] qapi: use 'type' in generated C code to match QMP union wire form Eric Blake
2015-09-10 4:06 ` [Qemu-devel] [PATCH RFC v4 04/29] vnc: hoist allocation of VncBasicInfo to callers Eric Blake
2015-09-10 4:06 ` [Qemu-devel] [PATCH RFC v4 05/29] qapi: Unbox base members Eric Blake
2015-09-10 4:06 ` [Qemu-devel] [PATCH RFC v4 06/29] qapi-visit: Remove redundant functions for flat union base Eric Blake
2015-09-10 4:06 ` [Qemu-devel] [PATCH RFC v4 07/29] qapi: Test use of 'number' within alternates Eric Blake
2015-09-10 4:06 ` [Qemu-devel] [PATCH RFC v4 08/29] qapi: Simplify visiting of alternate types Eric Blake
2015-09-10 4:06 ` [Qemu-devel] [PATCH RFC v4 09/29] qapi: Hide tag_name data member of variants Eric Blake
2015-09-10 4:06 ` [Qemu-devel] [PATCH RFC v4 10/29] qapi: Fix alternates that accept 'number' but not 'int' Eric Blake
2015-09-10 4:06 ` [Qemu-devel] [PATCH RFC v4 11/29] qapi: Don't pass pre-existing error to later call Eric Blake
2015-09-10 4:06 ` [Qemu-devel] [PATCH RFC v4 12/29] qapi: Use consistent generated code patterns Eric Blake
2015-09-10 4:06 ` [Qemu-devel] [PATCH RFC v4 13/29] qapi: Add tests for empty unions Eric Blake
2015-09-10 4:06 ` [Qemu-devel] [PATCH RFC v4 14/29] qapi: Rework deallocation of partial struct Eric Blake
2015-09-10 4:06 ` [Qemu-devel] [PATCH RFC v4 15/29] qapi: Avoid use of 'data' member of qapi unions Eric Blake
2015-09-10 4:06 ` [Qemu-devel] [PATCH RFC v4 16/29] qapi: Forbid empty unions and useless alternates Eric Blake
2015-09-10 4:06 ` [Qemu-devel] [PATCH RFC v4 17/29] qapi: Drop useless 'data' member of unions Eric Blake
2015-09-10 4:06 ` [Qemu-devel] [PATCH RFC v4 18/29] qapi: Remove dead visitor code Eric Blake
2015-09-10 4:06 ` [Qemu-devel] [PATCH RFC v4 19/29] qapi: Document visitor interfaces Eric Blake
2015-09-10 4:06 ` [Qemu-devel] [PATCH RFC v4 20/29] qapi: Plug leaks in test-qmp-input-visitor Eric Blake
2015-09-10 4:06 ` [Qemu-devel] [PATCH RFC v4 21/29] qapi: Test failure in middle of array parse Eric Blake
2015-09-10 4:06 ` [Qemu-devel] [PATCH RFC v4 22/29] qapi: Change visit_type_FOO() to no longer return partial objects Eric Blake
2015-09-10 4:06 ` [Qemu-devel] [PATCH RFC v4 23/29] qapi: Plumb in 'box' to qapi generator lower levels Eric Blake
2015-09-10 4:06 ` [Qemu-devel] [PATCH RFC v4 24/29] qapi: Implement boxed structs for commands/events Eric Blake
2015-09-10 4:06 ` [Qemu-devel] [PATCH RFC v4 25/29] qapi: Support boxed unions Eric Blake
2015-09-10 4:06 ` [Qemu-devel] [PATCH RFC v4 26/29] qapi: Clean up qapi.py per pep8 Eric Blake
2015-09-10 4:06 ` [Qemu-devel] [PATCH RFC v4 27/29] qapi: Change Netdev into a flat union Eric Blake
2015-09-17 9:15 ` Wen Congyang
2015-09-17 14:34 ` Eric Blake
2015-09-17 20:11 ` Eric Blake
2015-09-18 0:52 ` Wen Congyang
2015-09-18 6:56 ` Markus Armbruster
2015-09-18 8:36 ` Wen Congyang
2015-09-18 12:37 ` Eric Blake
2015-09-18 12:36 ` Eric Blake
2015-09-18 9:03 ` Yang Hongyang
2015-09-18 12:29 ` Eric Blake
2015-09-10 4:06 ` [Qemu-devel] [PATCH RFC v4 28/29] net: Use correct type for bool flag Eric Blake
2015-09-10 4:06 ` [Qemu-devel] [PATCH RFC v4 29/29] net: Complete qapi-fication of netdev_add Eric Blake
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1441857991-7309-3-git-send-email-eblake@redhat.com \
--to=eblake@redhat.com \
--cc=armbru@redhat.com \
--cc=dirty.ice.hu@gmail.com \
--cc=g.lettieri@iet.unipi.it \
--cc=jasowang@redhat.com \
--cc=marcandre.lureau@redhat.com \
--cc=mst@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=rizzo@iet.unipi.it \
--cc=stefanha@redhat.com \
--cc=v.maffione@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).