From patchwork Mon Sep 27 12:51:01 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Wang X-Patchwork-Id: 65840 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 E6C4EB6EEB for ; Mon, 27 Sep 2010 22:53:29 +1000 (EST) Received: from localhost ([127.0.0.1]:34679 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1P0DCx-00081R-76 for incoming@patchwork.ozlabs.org; Mon, 27 Sep 2010 08:53:27 -0400 Received: from [140.186.70.92] (port=43443 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1P0DAo-0007ak-BJ for qemu-devel@nongnu.org; Mon, 27 Sep 2010 08:51:20 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1P0DAn-0002ZQ-2w for qemu-devel@nongnu.org; Mon, 27 Sep 2010 08:51:14 -0400 Received: from mx1.redhat.com ([209.132.183.28]:56434) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1P0DAm-0002Yw-Np for qemu-devel@nongnu.org; Mon, 27 Sep 2010 08:51:13 -0400 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o8RCpBgB026221 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Mon, 27 Sep 2010 08:51:11 -0400 Received: from dhcp-91-7.nay.redhat.com.englab.nay.redhat.com (dhcp-91-7.nay.redhat.com [10.66.91.7]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o8RCp8Lx032281; Mon, 27 Sep 2010 08:51:09 -0400 To: qemu-devel@nongnu.org, anthony@codemonkey.ws, mst@redhat.com From: Jason Wang Date: Mon, 27 Sep 2010 20:51:01 +0800 Message-ID: <20100927125101.12060.53223.stgit@dhcp-91-7.nay.redhat.com.englab.nay.redhat.com> In-Reply-To: <20100927124606.12060.66912.stgit@dhcp-91-7.nay.redhat.com.englab.nay.redhat.com> References: <20100927124606.12060.66912.stgit@dhcp-91-7.nay.redhat.com.englab.nay.redhat.com> User-Agent: StGit/0.15 MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.67 on 10.5.11.11 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. Cc: kvm@vger.kernel.org Subject: [Qemu-devel] [RFC PATCH 2/4] net: Introduce model specific nic announce function 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 This patch introduce a function pointer in NetClientInfo which is called during self announcement to do the model specific mac address announcement. Previous method were kept for the model without its own implementation. Signed-off-by: Jason Wang --- net.h | 2 ++ savevm.c | 10 ++++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/net.h b/net.h index e3f643c..4fa5603 100644 --- a/net.h +++ b/net.h @@ -42,6 +42,7 @@ typedef ssize_t (NetReceive)(VLANClientState *, const uint8_t *, size_t); typedef ssize_t (NetReceiveIOV)(VLANClientState *, const struct iovec *, int); typedef void (NetCleanup) (VLANClientState *); typedef void (LinkStatusChanged)(VLANClientState *); +typedef void (NetAnnounce)(VLANClientState *); typedef struct NetClientInfo { net_client_type type; @@ -53,6 +54,7 @@ typedef struct NetClientInfo { NetCleanup *cleanup; LinkStatusChanged *link_status_changed; NetPoll *poll; + NetAnnounce *announce; } NetClientInfo; struct VLANClientState { diff --git a/savevm.c b/savevm.c index 545d511..c16ee1b 100644 --- a/savevm.c +++ b/savevm.c @@ -90,10 +90,16 @@ static void qemu_announce_self_iter(NICState *nic, void *opaque) { uint8_t buf[60]; int len; + NetAnnounce *func = nic->nc.info->announce; - len = announce_self_create(buf, nic->conf->macaddr.a); + if (func == NULL) { + len = announce_self_create(buf, nic->conf->macaddr.a); - qemu_send_packet_raw(&nic->nc, buf, len); + qemu_send_packet_raw(&nic->nc, buf, len); + } + else { + func(&nic->nc); + } }