Skip to content

Commit

Permalink
net: introduce qemu_net_client_setup()
Browse files Browse the repository at this point in the history
This patch separates the setup of NetClientState from its allocation, this will
allow allocating an arrays of NetClientState and does the initialization one by
one which is what multiqueue needs.

Signed-off-by: Jason Wang <jasowang@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
  • Loading branch information
jasowang authored and Anthony Liguori committed Feb 1, 2013
1 parent 6c51ae7 commit 18a1541
Showing 1 changed file with 19 additions and 10 deletions.
29 changes: 19 additions & 10 deletions net/net.c
Original file line number Diff line number Diff line change
Expand Up @@ -182,17 +182,12 @@ static char *assign_name(NetClientState *nc1, const char *model)
return g_strdup(buf);
}

NetClientState *qemu_new_net_client(NetClientInfo *info,
NetClientState *peer,
const char *model,
const char *name)
static void qemu_net_client_setup(NetClientState *nc,
NetClientInfo *info,
NetClientState *peer,
const char *model,
const char *name)
{
NetClientState *nc;

assert(info->size >= sizeof(NetClientState));

nc = g_malloc0(info->size);

nc->info = info;
nc->model = g_strdup(model);
if (name) {
Expand All @@ -210,6 +205,20 @@ NetClientState *qemu_new_net_client(NetClientInfo *info,

nc->send_queue = qemu_new_net_queue(nc);

}

NetClientState *qemu_new_net_client(NetClientInfo *info,
NetClientState *peer,
const char *model,
const char *name)
{
NetClientState *nc;

assert(info->size >= sizeof(NetClientState));

nc = g_malloc0(info->size);
qemu_net_client_setup(nc, info, peer, model, name);

return nc;
}

Expand Down

0 comments on commit 18a1541

Please sign in to comment.