From: Jason Wang Subject: [PATCH V4 RESEND 07/22] net: introduce qemu_net_client_setup() Date: Fri, 1 Feb 2013 15:39:41 +0800 Message-ID: <1359704396-55327-8-git-send-email-jasowang@redhat.com> References: <1359704396-55327-1-git-send-email-jasowang@redhat.com> Cc: krkumar2@in.ibm.com, kvm@vger.kernel.org, mprivozn@redhat.com, rusty@rustcorp.com.au, jwhan@filewood.snu.ac.kr, gaowanlong@cn.fujitsu.com, Jason Wang To: aliguori@us.ibm.com, mst@redhat.com, qemu-devel@nongnu.org, blauwirbel@gmail.com, shajnocz@redhat.com Return-path: Received: from mx1.redhat.com ([209.132.183.28]:3378 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755129Ab3BAHta (ORCPT ); Fri, 1 Feb 2013 02:49:30 -0500 In-Reply-To: <1359704396-55327-1-git-send-email-jasowang@redhat.com> Sender: kvm-owner@vger.kernel.org List-ID: 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 Signed-off-by: Michael S. Tsirkin --- net/net.c | 29 +++++++++++++++++++---------- 1 files changed, 19 insertions(+), 10 deletions(-) diff --git a/net/net.c b/net/net.c index 16dd327..3a5bdf6 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; } -- 1.7.1