From patchwork Thu Oct 27 08:48:45 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Wang X-Patchwork-Id: 122086 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [140.186.70.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 05A491007DA for ; Thu, 27 Oct 2011 19:48:57 +1100 (EST) Received: from localhost ([::1]:40993 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RJLdu-0007zg-Sn for incoming@patchwork.ozlabs.org; Thu, 27 Oct 2011 04:48:54 -0400 Received: from eggs.gnu.org ([140.186.70.92]:53045) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RJLdn-0007tU-Ri for qemu-devel@nongnu.org; Thu, 27 Oct 2011 04:48:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RJLdm-0005lY-DT for qemu-devel@nongnu.org; Thu, 27 Oct 2011 04:48:47 -0400 Received: from mx1.redhat.com ([209.132.183.28]:59740) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RJLdm-0005l3-2V for qemu-devel@nongnu.org; Thu, 27 Oct 2011 04:48:46 -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 p9R8miT0031015 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Thu, 27 Oct 2011 04:48:44 -0400 Received: from dhcp-8-146.nay.redhat.com (dhcp-8-146.nay.redhat.com [10.66.8.146]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id p9R8merd003938; Thu, 27 Oct 2011 04:48:41 -0400 To: aliguori@us.ibm.com, mst@redhat.com, jan.kiszka@siemens.com, rusty@rustcorp.com.au, qemu-devel@nongnu.org, blauwirbel@gmail.com, stefanha@gmail.com From: Jason Wang Date: Thu, 27 Oct 2011 16:48:45 +0800 Message-ID: <20111027084845.15020.31881.stgit@dhcp-8-146.nay.redhat.com> In-Reply-To: <20111027084700.15020.24087.stgit@dhcp-8-146.nay.redhat.com> References: <20111027084700.15020.24087.stgit@dhcp-8-146.nay.redhat.com> User-Agent: StGit/0.15 MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-Received-From: 209.132.183.28 Cc: netdev@vger.kernel.org, kvm@vger.kernel.org Subject: [Qemu-devel] [RFC v3 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 to do the model specific announcing. The first user would be virtio-net. Signed-off-by: Jason Wang --- net.h | 2 ++ savevm.c | 8 +++++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/net.h b/net.h index 9f633f8..7654769 100644 --- a/net.h +++ b/net.h @@ -46,6 +46,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; @@ -57,6 +58,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 73ee6e2..46389b2 100644 --- a/savevm.c +++ b/savevm.c @@ -122,10 +122,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 == NULL || func(&nic->nc) != 0) { + len = announce_self_create(buf, nic->conf->macaddr.a); + qemu_send_packet_raw(&nic->nc, buf, len); + } }