summaryrefslogtreecommitdiff
path: root/net/net.c
diff options
context:
space:
mode:
authorKővágó, Zoltán <dirty.ice.hu@gmail.com>2016-07-13 21:50:12 -0600
committerMarkus Armbruster <armbru@redhat.com>2016-07-19 13:21:08 +0200
commitcebea510579ed43724156cc596a8ff14ba208740 (patch)
tree36a425d96c2debd011a6d7df8867e2290b338d48 /net/net.c
parent3d344c2aabb7bc9b414321e3c52872901edebdda (diff)
net: use Netdev instead of NetClientOptions in client init
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 - which means that we still need NetClientOptions after all. Rebase to qapi changes. The bulk of the patch is mechanical, replacing 'opts' by 'netdev->opts', while net_client_init1() takes care of converting between legacy and modern types.] Signed-off-by: Eric Blake <eblake@redhat.com> Message-Id: <1468468228-27827-2-git-send-email-eblake@redhat.com> Reviewed-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Markus Armbruster <armbru@redhat.com>
Diffstat (limited to 'net/net.c')
-rw-r--r--net/net.c18
1 files changed, 11 insertions, 7 deletions
diff --git a/net/net.c b/net/net.c
index 019aaad0fc..d80fd82210 100644
--- a/net/net.c
+++ b/net/net.c
@@ -862,15 +862,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->type == NET_CLIENT_OPTIONS_KIND_NIC);
- nic = opts->u.nic.data;
+ assert(netdev->opts->type == NET_CLIENT_OPTIONS_KIND_NIC);
+ nic = netdev->opts->u.nic.data;
idx = nic_get_free_idx();
if (idx == -1 || nb_nics >= MAX_NICS) {
@@ -931,7 +931,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,
@@ -963,11 +963,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;
@@ -980,7 +982,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;
@@ -1007,7 +1011,7 @@ static int net_client_init1(const void *object, int is_netdev, Error **errp)
}
}
- if (net_client_init_fun[opts->type](opts, name, peer, errp) < 0) {
+ if (net_client_init_fun[opts->type](netdev, name, peer, errp) < 0) {
/* FIXME drop when all init functions store an Error */
if (errp && !*errp) {
error_setg(errp, QERR_DEVICE_INIT_FAILED,