summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJason Wang2013-01-30 12:12:26 +0100
committerAnthony Liguori2013-02-01 18:03:01 +0100
commit18a1541a8da40271056aab99100bdc38283c42ac (patch)
tree6a2eb03dffea7e5fefdd3eabf4faae77eb5477c7
parentnet: introduce qemu_find_net_clients_except() (diff)
downloadqemu-18a1541a8da40271056aab99100bdc38283c42ac.tar.gz
qemu-18a1541a8da40271056aab99100bdc38283c42ac.tar.xz
qemu-18a1541a8da40271056aab99100bdc38283c42ac.zip
net: introduce qemu_net_client_setup()
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>
-rw-r--r--net/net.c29
1 files changed, 19 insertions, 10 deletions
diff --git a/net/net.c b/net/net.c
index 16dd327782..3a5bdf6b3f 100644
--- a/net/net.c
+++ b/net/net.c
@@ -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) {
@@ -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;
}