From patchwork Wed Nov 25 18:49:02 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark McLoughlin X-Patchwork-Id: 39420 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id C263AB6EEA for ; Thu, 26 Nov 2009 06:03:54 +1100 (EST) Received: from localhost ([127.0.0.1]:33009 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NDN9Z-0002RF-09 for incoming@patchwork.ozlabs.org; Wed, 25 Nov 2009 14:03:49 -0500 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NDMyh-0007Mx-Qo for qemu-devel@nongnu.org; Wed, 25 Nov 2009 13:52:35 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1NDMyX-0007Gt-OV for qemu-devel@nongnu.org; Wed, 25 Nov 2009 13:52:30 -0500 Received: from [199.232.76.173] (port=48992 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NDMyX-0007Gk-J2 for qemu-devel@nongnu.org; Wed, 25 Nov 2009 13:52:25 -0500 Received: from mx1.redhat.com ([209.132.183.28]:4246) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1NDMyW-0000E6-RO for qemu-devel@nongnu.org; Wed, 25 Nov 2009 13:52:25 -0500 Received: from int-mx04.intmail.prod.int.phx2.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.17]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id nAPIqNDP020202 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Wed, 25 Nov 2009 13:52:24 -0500 Received: from blaa.localdomain (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by int-mx04.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id nAPIqMRd014170; Wed, 25 Nov 2009 13:52:23 -0500 Received: by blaa.localdomain (Postfix, from userid 500) id 76759B03F; Wed, 25 Nov 2009 18:49:40 +0000 (GMT) From: Mark McLoughlin To: qemu-devel@nongnu.org Date: Wed, 25 Nov 2009 18:49:02 +0000 Message-Id: <1259174977-26212-10-git-send-email-markmc@redhat.com> In-Reply-To: <1259174977-26212-1-git-send-email-markmc@redhat.com> References: <1259174977-26212-1-git-send-email-markmc@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.17 X-detected-operating-system: by monty-python.gnu.org: Genre and OS details not recognized. Cc: Mark McLoughlin Subject: [Qemu-devel] [PATCH 09/44] net: introduce qemu_new_net_client() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org A replacement for qemu_new_vlan_client(), using NetClientInfo to replace most arguments. Signed-off-by: Mark McLoughlin --- net.c | 70 +++++++++++++++++++++++++++++++++++++++++++++------------------- net.h | 5 ++++ 2 files changed, 54 insertions(+), 21 deletions(-) diff --git a/net.c b/net.c index 599e5b0..355eb87 100644 --- a/net.c +++ b/net.c @@ -248,34 +248,31 @@ static ssize_t qemu_deliver_packet_iov(VLANClientState *sender, int iovcnt, void *opaque); -VLANClientState *qemu_new_vlan_client(net_client_type type, - VLANState *vlan, - VLANClientState *peer, - const char *model, - const char *name, - NetCanReceive *can_receive, - NetReceive *receive, - NetReceive *receive_raw, - NetReceiveIOV *receive_iov, - NetCleanup *cleanup, - void *opaque) +VLANClientState *qemu_new_net_client(NetClientInfo *info, + VLANState *vlan, + VLANClientState *peer, + const char *model, + const char *name) { VLANClientState *vc; - vc = qemu_mallocz(sizeof(VLANClientState)); + assert(info->size >= sizeof(VLANClientState)); + + vc = qemu_mallocz(info->size); - vc->type = type; + vc->type = info->type; vc->model = qemu_strdup(model); - if (name) + if (name) { vc->name = qemu_strdup(name); - else + } else { vc->name = assign_name(vc, model); - vc->can_receive = can_receive; - vc->receive = receive; - vc->receive_raw = receive_raw; - vc->receive_iov = receive_iov; - vc->cleanup = cleanup; - vc->opaque = opaque; + } + vc->can_receive = info->can_receive; + vc->receive = info->receive; + vc->receive_raw = info->receive_raw; + vc->receive_iov = info->receive_iov; + vc->cleanup = info->cleanup; + vc->link_status_changed = info->link_status_changed; if (vlan) { assert(!peer); @@ -296,6 +293,37 @@ VLANClientState *qemu_new_vlan_client(net_client_type type, return vc; } +VLANClientState *qemu_new_vlan_client(net_client_type type, + VLANState *vlan, + VLANClientState *peer, + const char *model, + const char *name, + NetCanReceive *can_receive, + NetReceive *receive, + NetReceive *receive_raw, + NetReceiveIOV *receive_iov, + NetCleanup *cleanup, + void *opaque) +{ + VLANClientState *ret; + NetClientInfo info; + + info.type = type; + info.size = sizeof(VLANClientState); + info.can_receive = can_receive; + info.receive = receive; + info.receive_raw = receive_raw; + info.receive_iov = receive_iov; + info.cleanup = cleanup; + info.link_status_changed = NULL; + + ret = qemu_new_net_client(&info, vlan, peer, model, name); + + ret->opaque = opaque; + + return ret; +} + void qemu_del_vlan_client(VLANClientState *vc) { if (vc->vlan) { diff --git a/net.h b/net.h index 56c5849..71a9a44 100644 --- a/net.h +++ b/net.h @@ -85,6 +85,11 @@ struct VLANState { VLANState *qemu_find_vlan(int id, int allocate); VLANClientState *qemu_find_netdev(const char *id); +VLANClientState *qemu_new_net_client(NetClientInfo *info, + VLANState *vlan, + VLANClientState *peer, + const char *model, + const char *name); VLANClientState *qemu_new_vlan_client(net_client_type type, VLANState *vlan, VLANClientState *peer,