On 09/04/2015 03:36 PM, Eric Blake wrote: > On 08/21/2015 09:37 AM, Kővágó, Zoltán wrote: >> 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...@gmail.com> >> --- >> 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(-) > > Nice; you've already done some of the work that I saw as needing to be > done for my plans to convert QMP netdev_add to use a flat union instead > of 'gen':false. > > Conflicts with my s/kind/type/ in > https://lists.gnu.org/archive/html/qemu-devel/2015-08/msg02061.html, so > whoever goes in first gets to avoid the obvious merge conflict > resolution. :) > > Reviewed-by: Eric Blake <ebl...@redhat.com>
By the way, I was able to get this patch to work without using 4/49 by changing the diff to net_client_init1() to be just the following: diff --git i/net/net.c w/net/net.c index 28a5597..4d99b48 100644 --- i/net/net.c +++ w/net/net.c @@ -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, I may end up using a modified version of your patch in my submission for QMP netdev_add, while still avoiding the merge of NetdevLegacy (I'm not sold on that one yet, because it exists only for the command line and not for QMP, while we want to make QMP become typesafe). -- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
signature.asc
Description: OpenPGP digital signature