Commit f394b2e2 authored by Eric Blake's avatar Eric Blake Committed by Markus Armbruster
Browse files

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: default avatarEric Blake <eblake@redhat.com>
Message-Id: <1468468228-27827-13-git-send-email-eblake@redhat.com>
Reviewed-by: default avatarMarkus Armbruster <armbru@redhat.com>
[Fixup from Eric squashed in]
Signed-off-by: default avatarMarkus Armbruster <armbru@redhat.com>
parent faecd40a
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -378,7 +378,7 @@ static void eth_cleanup(NetClientState *nc)
}

static NetClientInfo net_mv88w8618_info = {
    .type = NET_CLIENT_OPTIONS_KIND_NIC,
    .type = NET_CLIENT_DRIVER_NIC,
    .size = sizeof(NICState),
    .receive = eth_receive,
    .cleanup = eth_cleanup,
+1 −1
Original line number Diff line number Diff line
@@ -247,7 +247,7 @@ static void set_netdev(Object *obj, Visitor *v, const char *name,
    }

    queues = qemu_find_net_clients_except(str, peers,
                                          NET_CLIENT_OPTIONS_KIND_NIC,
                                          NET_CLIENT_DRIVER_NIC,
                                          MAX_QUEUE_NUM);
    if (queues == 0) {
        err = -ENOENT;
+1 −1
Original line number Diff line number Diff line
@@ -424,7 +424,7 @@ static const MemoryRegionOps aw_emac_mem_ops = {
};

static NetClientInfo net_aw_emac_info = {
    .type = NET_CLIENT_OPTIONS_KIND_NIC,
    .type = NET_CLIENT_DRIVER_NIC,
    .size = sizeof(NICState),
    .can_receive = aw_emac_can_receive,
    .receive = aw_emac_receive,
+1 −1
Original line number Diff line number Diff line
@@ -1207,7 +1207,7 @@ static void gem_set_link(NetClientState *nc)
}

static NetClientInfo net_gem_info = {
    .type = NET_CLIENT_OPTIONS_KIND_NIC,
    .type = NET_CLIENT_DRIVER_NIC,
    .size = sizeof(NICState),
    .can_receive = gem_can_receive,
    .receive = gem_receive,
+1 −1
Original line number Diff line number Diff line
@@ -812,7 +812,7 @@ static void dp8393x_reset(DeviceState *dev)
}

static NetClientInfo net_dp83932_info = {
    .type = NET_CLIENT_OPTIONS_KIND_NIC,
    .type = NET_CLIENT_DRIVER_NIC,
    .size = sizeof(NICState),
    .can_receive = dp8393x_can_receive,
    .receive = dp8393x_receive,
Loading