diff options
author | Eric Blake <eblake@redhat.com> | 2016-07-13 21:50:23 -0600 |
---|---|---|
committer | Markus Armbruster <armbru@redhat.com> | 2016-07-19 20:18:02 +0200 |
commit | f394b2e20d9a666fb194fb692179a0eeaca5daea (patch) | |
tree | 4d01037fde0500c9bfa746ef852ae32e04b7dbb8 /hw/net/vhost_net.c | |
parent | faecd40a592dbd8f12d2b3b4783fa05ae22364ea (diff) |
qapi: Change Netdev into a flat union
This is a mostly-mechanical conversion that creates a new flat
union 'Netdev' QAPI type that covers all the branches of the
former 'NetClientOptions' simple union, where the branches are
now listed in a new 'NetClientDriver' enum rather than generated
from the simple union. The existence of a flat union has no
change to the command line syntax accepted for new code, and
will make it possible for a future patch to switch the QMP
command to parse a boxed union for no change to valid QMP; but
it does have some ripple effect on the C code when dealing with
the new types.
While making the conversion, note that the 'NetLegacy' type
remains unchanged: it applies only to legacy command line options,
and will not be ported to QMP, so it should remain a wrapper
around a simple union; to avoid confusion, the type named
'NetClientOptions' is now gone, and we introduce 'NetLegacyOptions'
in its place. Then, in the C code, we convert from NetLegacy to
Netdev as soon as possible, so that the bulk of the net stack
only has to deal with one QAPI type, not two. Note that since
the old legacy code always rejected 'hubport', we can just omit
that branch from the new 'NetLegacyOptions' simple union.
Based on an idea originally by Zoltán Kővágó <DirtY.iCE.hu@gmail.com>:
Message-Id: <01a527fbf1a5de880091f98cf011616a78adeeee.1441627176.git.DirtY.iCE.hu@gmail.com>
although the sed script in that patch no longer applies due to
other changes in the tree since then, and I also did some manual
cleanups (such as fixing whitespace to keep checkpatch happy).
Signed-off-by: Eric Blake <eblake@redhat.com>
Message-Id: <1468468228-27827-13-git-send-email-eblake@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
[Fixup from Eric squashed in]
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Diffstat (limited to 'hw/net/vhost_net.c')
-rw-r--r-- | hw/net/vhost_net.c | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/hw/net/vhost_net.c b/hw/net/vhost_net.c index 11fabc0b0a..f92d3f829e 100644 --- a/hw/net/vhost_net.c +++ b/hw/net/vhost_net.c @@ -88,10 +88,10 @@ static const int *vhost_net_get_feature_bits(struct vhost_net *net) const int *feature_bits = 0; switch (net->nc->info->type) { - case NET_CLIENT_OPTIONS_KIND_TAP: + case NET_CLIENT_DRIVER_TAP: feature_bits = kernel_feature_bits; break; - case NET_CLIENT_OPTIONS_KIND_VHOST_USER: + case NET_CLIENT_DRIVER_VHOST_USER: feature_bits = user_feature_bits; break; default: @@ -128,7 +128,7 @@ uint64_t vhost_net_get_acked_features(VHostNetState *net) static int vhost_net_get_fd(NetClientState *backend) { switch (backend->info->type) { - case NET_CLIENT_OPTIONS_KIND_TAP: + case NET_CLIENT_DRIVER_TAP: return tap_get_fd(backend); default: fprintf(stderr, "vhost-net requires tap backend\n"); @@ -191,7 +191,7 @@ struct vhost_net *vhost_net_init(VhostNetOptions *options) } /* Set sane init value. Override when guest acks. */ - if (net->nc->info->type == NET_CLIENT_OPTIONS_KIND_VHOST_USER) { + if (net->nc->info->type == NET_CLIENT_DRIVER_VHOST_USER) { features = vhost_user_get_acked_features(net->nc); if (~net->dev.features & features) { fprintf(stderr, "vhost lacks feature mask %" PRIu64 @@ -238,7 +238,7 @@ static int vhost_net_start_one(struct vhost_net *net, net->nc->info->poll(net->nc, false); } - if (net->nc->info->type == NET_CLIENT_OPTIONS_KIND_TAP) { + if (net->nc->info->type == NET_CLIENT_DRIVER_TAP) { qemu_set_fd_handler(net->backend, NULL, NULL, NULL); file.fd = net->backend; for (file.index = 0; file.index < net->dev.nvqs; ++file.index) { @@ -253,7 +253,7 @@ static int vhost_net_start_one(struct vhost_net *net, return 0; fail: file.fd = -1; - if (net->nc->info->type == NET_CLIENT_OPTIONS_KIND_TAP) { + if (net->nc->info->type == NET_CLIENT_DRIVER_TAP) { while (file.index-- > 0) { const VhostOps *vhost_ops = net->dev.vhost_ops; int r = vhost_ops->vhost_net_set_backend(&net->dev, &file); @@ -275,7 +275,7 @@ static void vhost_net_stop_one(struct vhost_net *net, { struct vhost_vring_file file = { .fd = -1 }; - if (net->nc->info->type == NET_CLIENT_OPTIONS_KIND_TAP) { + if (net->nc->info->type == NET_CLIENT_DRIVER_TAP) { for (file.index = 0; file.index < net->dev.nvqs; ++file.index) { const VhostOps *vhost_ops = net->dev.vhost_ops; int r = vhost_ops->vhost_net_set_backend(&net->dev, &file); @@ -312,7 +312,7 @@ int vhost_net_start(VirtIODevice *dev, NetClientState *ncs, * because vhost user doesn't interrupt masking/unmasking * properly. */ - if (net->nc->info->type == NET_CLIENT_OPTIONS_KIND_VHOST_USER) { + if (net->nc->info->type == NET_CLIENT_DRIVER_VHOST_USER) { dev->use_guest_notifier_mask = false; } } @@ -413,10 +413,10 @@ VHostNetState *get_vhost_net(NetClientState *nc) } switch (nc->info->type) { - case NET_CLIENT_OPTIONS_KIND_TAP: + case NET_CLIENT_DRIVER_TAP: vhost_net = tap_get_vhost_net(nc); break; - case NET_CLIENT_OPTIONS_KIND_VHOST_USER: + case NET_CLIENT_DRIVER_VHOST_USER: vhost_net = vhost_user_get_vhost_net(nc); break; default: |