From patchwork Wed Nov 25 18:49:10 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark McLoughlin X-Patchwork-Id: 39421 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 AFB31B7B69 for ; Thu, 26 Nov 2009 06:05:31 +1100 (EST) Received: from localhost ([127.0.0.1]:33695 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NDNBA-00031l-Uc for incoming@patchwork.ozlabs.org; Wed, 25 Nov 2009 14:05:28 -0500 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NDMyi-0007Nr-6Q for qemu-devel@nongnu.org; Wed, 25 Nov 2009 13:52:36 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1NDMyY-0007Hf-KJ for qemu-devel@nongnu.org; Wed, 25 Nov 2009 13:52:32 -0500 Received: from [199.232.76.173] (port=49000 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NDMyY-0007HC-9y for qemu-devel@nongnu.org; Wed, 25 Nov 2009 13:52:26 -0500 Received: from mx1.redhat.com ([209.132.183.28]:39169) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1NDMyX-0000ET-LP for qemu-devel@nongnu.org; Wed, 25 Nov 2009 13:52:26 -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 nAPIqOfe015245 (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 nAPIqNCR014174; Wed, 25 Nov 2009 13:52:24 -0500 Received: by blaa.localdomain (Postfix, from userid 500) id 3C92CB0B7; Wed, 25 Nov 2009 18:49:41 +0000 (GMT) From: Mark McLoughlin To: qemu-devel@nongnu.org Date: Wed, 25 Nov 2009 18:49:10 +0000 Message-Id: <1259174977-26212-18-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 17/44] net: introduce NICState and qemu_new_nic() 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 Common state for all NICs. The opaque member will replace the opaque member in VLANClientState since only NICs need it. The conf member will allow us to iterate over NICs, access the MAC addr for the NIC and send a packet from each NIC in qemu_announce_self(). Signed-off-by: Mark McLoughlin --- net.c | 21 +++++++++++++++++++++ net.h | 11 +++++++++++ 2 files changed, 32 insertions(+), 0 deletions(-) diff --git a/net.c b/net.c index 355eb87..7195827 100644 --- a/net.c +++ b/net.c @@ -293,6 +293,27 @@ VLANClientState *qemu_new_net_client(NetClientInfo *info, return vc; } +NICState *qemu_new_nic(NetClientInfo *info, + NICConf *conf, + const char *model, + const char *name, + void *opaque) +{ + VLANClientState *nc; + NICState *nic; + + assert(info->type == NET_CLIENT_TYPE_NIC); + assert(info->size >= sizeof(NICState)); + + nc = qemu_new_net_client(info, conf->vlan, conf->peer, model, name); + + nic = DO_UPCAST(NICState, nc, nc); + nic->conf = conf; + nic->opaque = opaque; + + return nic; +} + VLANClientState *qemu_new_vlan_client(net_client_type type, VLANState *vlan, VLANClientState *peer, diff --git a/net.h b/net.h index 71a9a44..4de20de 100644 --- a/net.h +++ b/net.h @@ -75,6 +75,12 @@ struct VLANClientState { unsigned receive_disabled : 1; }; +typedef struct NICState { + VLANClientState nc; + NICConf *conf; + void *opaque; +} NICState; + struct VLANState { int id; QTAILQ_HEAD(, VLANClientState) clients; @@ -90,6 +96,11 @@ VLANClientState *qemu_new_net_client(NetClientInfo *info, VLANClientState *peer, const char *model, const char *name); +NICState *qemu_new_nic(NetClientInfo *info, + NICConf *conf, + const char *model, + const char *name, + void *opaque); VLANClientState *qemu_new_vlan_client(net_client_type type, VLANState *vlan, VLANClientState *peer,