From patchwork Wed Mar 28 05:40:21 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Wang X-Patchwork-Id: 149143 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 EC973B6EEB for ; Wed, 28 Mar 2012 16:45:24 +1100 (EST) Received: from localhost ([::1]:38905 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SClhC-0003zH-K6 for incoming@patchwork.ozlabs.org; Wed, 28 Mar 2012 01:45:22 -0400 Received: from eggs.gnu.org ([208.118.235.92]:57404) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SClgz-0003jh-BF for qemu-devel@nongnu.org; Wed, 28 Mar 2012 01:45:10 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SClgx-0005Lr-J3 for qemu-devel@nongnu.org; Wed, 28 Mar 2012 01:45:08 -0400 Received: from mx1.redhat.com ([209.132.183.28]:44492) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SClgx-0005LF-Bh for qemu-devel@nongnu.org; Wed, 28 Mar 2012 01:45:07 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q2S5j4d5023785 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Wed, 28 Mar 2012 01:45:04 -0400 Received: from amd-6168-8-1.englab.nay.redhat.com (amd-6168-8-1.englab.nay.redhat.com [10.66.104.52]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id q2S5j1wd026111; Wed, 28 Mar 2012 01:45:02 -0400 To: aliguori@us.ibm.com, stefanha@linux.vnet.ibm.com, quintela@redhat.com, rusty@rustcorp.com.au, qemu-devel@nongnu.org, mst@redhat.com, pbonzini@redhat.com From: Jason Wang Date: Wed, 28 Mar 2012 13:40:21 +0800 Message-ID: <20120328054021.34135.47880.stgit@amd-6168-8-1.englab.nay.redhat.com> In-Reply-To: <20120328053356.34135.42669.stgit@amd-6168-8-1.englab.nay.redhat.com> References: <20120328053356.34135.42669.stgit@amd-6168-8-1.englab.nay.redhat.com> User-Agent: StGit/0.16-1-g60c4 MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [V6 PATCH 2/4] net: model specific announcing support 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 introduces a function pointer in NetClientInfo which is called during self announcement. With this, each kind of card can announce the link with a specific way. The old method is still kept for cards that have not implemented this or old guest. The first user would be virtio-net. Signed-off-by: Jason Wang Reviewed-by: Paolo Bonzini --- net.h | 2 ++ savevm.c | 8 +++++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/net.h b/net.h index 75a8c15..7195bfc 100644 --- a/net.h +++ b/net.h @@ -48,6 +48,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 int (NetAnnounce)(VLANClientState *); typedef struct NetClientInfo { net_client_type type; @@ -59,6 +60,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 80be1ff..7558c1d 100644 --- a/savevm.c +++ b/savevm.c @@ -123,10 +123,12 @@ 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); - - qemu_send_packet_raw(&nic->nc, buf, len); + if (!func || func(&nic->nc) != 0) { + len = announce_self_create(buf, nic->conf->macaddr.a); + qemu_send_packet_raw(&nic->nc, buf, len); + } }