From patchwork Fri Feb 1 07:39:41 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Wang X-Patchwork-Id: 217356 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id B59132C0296 for ; Fri, 1 Feb 2013 18:50:01 +1100 (EST) Received: from localhost ([::1]:44139 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U1BNn-0006Il-Td for incoming@patchwork.ozlabs.org; Fri, 01 Feb 2013 02:49:59 -0500 Received: from eggs.gnu.org ([208.118.235.92]:54685) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U1BNI-0005h4-1n for qemu-devel@nongnu.org; Fri, 01 Feb 2013 02:49:30 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1U1BNG-0005dv-Ur for qemu-devel@nongnu.org; Fri, 01 Feb 2013 02:49:27 -0500 Received: from mx1.redhat.com ([209.132.183.28]:61740) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U1BNG-0005dm-M2 for qemu-devel@nongnu.org; Fri, 01 Feb 2013 02:49:26 -0500 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r117nDWN011532 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Fri, 1 Feb 2013 02:49:13 -0500 Received: from amd-6168-8-1.englab.nay.redhat.com (amd-6168-8-1.englab.nay.redhat.com [10.66.104.52]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id r117ma5R001786; Fri, 1 Feb 2013 02:49:09 -0500 From: Jason Wang To: aliguori@us.ibm.com, mst@redhat.com, qemu-devel@nongnu.org, blauwirbel@gmail.com, shajnocz@redhat.com Date: Fri, 1 Feb 2013 15:39:41 +0800 Message-Id: <1359704396-55327-8-git-send-email-jasowang@redhat.com> In-Reply-To: <1359704396-55327-1-git-send-email-jasowang@redhat.com> References: <1359704396-55327-1-git-send-email-jasowang@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.12 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: krkumar2@in.ibm.com, kvm@vger.kernel.org, mprivozn@redhat.com, Jason Wang , rusty@rustcorp.com.au, jwhan@filewood.snu.ac.kr, gaowanlong@cn.fujitsu.com Subject: [Qemu-devel] [PATCH V4 RESEND 07/22] net: introduce qemu_net_client_setup() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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; }