From patchwork Thu Mar 7 08:23:49 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Wang X-Patchwork-Id: 225765 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 DEBEE2C0367 for ; Thu, 7 Mar 2013 19:34:56 +1100 (EST) Received: from localhost ([::1]:44901 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UDWHv-0002dr-2Y for incoming@patchwork.ozlabs.org; Thu, 07 Mar 2013 03:34:55 -0500 Received: from eggs.gnu.org ([208.118.235.92]:49195) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UDWGH-0008U2-92 for qemu-devel@nongnu.org; Thu, 07 Mar 2013 03:33:14 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UDWGF-0007kN-Rc for qemu-devel@nongnu.org; Thu, 07 Mar 2013 03:33:13 -0500 Received: from mx1.redhat.com ([209.132.183.28]:63075) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UDWGF-0007kH-K0 for qemu-devel@nongnu.org; Thu, 07 Mar 2013 03:33:11 -0500 Received: from int-mx12.intmail.prod.int.phx2.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.25]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r278XArL025176 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Thu, 7 Mar 2013 03:33:11 -0500 Received: from amd-6168-8-1.englab.nay.redhat.com (amd-6168-8-1.englab.nay.redhat.com [10.66.104.52]) by int-mx12.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id r278WoIA007225; Thu, 7 Mar 2013 03:33:05 -0500 From: Jason Wang To: aliguori@us.ibm.com, pbonzini@redhat.com, owasserm@redhat.com, qemu-devel@nongnu.org Date: Thu, 7 Mar 2013 16:23:49 +0800 Message-Id: <1362644631-23113-4-git-send-email-jasowang@redhat.com> In-Reply-To: <1362644631-23113-1-git-send-email-jasowang@redhat.com> References: <1362644631-23113-1-git-send-email-jasowang@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.25 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Jason Wang , mst@redhat.com Subject: [Qemu-devel] [PATCH V7 3/5] 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 model 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 --- include/net/net.h | 2 ++ savevm.c | 8 ++++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/include/net/net.h b/include/net/net.h index cb049a1..49031b4 100644 --- a/include/net/net.h +++ b/include/net/net.h @@ -44,6 +44,7 @@ typedef ssize_t (NetReceiveIOV)(NetClientState *, const struct iovec *, int); typedef void (NetCleanup) (NetClientState *); typedef void (LinkStatusChanged)(NetClientState *); typedef void (NetClientDestructor)(NetClientState *); +typedef int (NetAnnounce)(NetClientState *); typedef struct NetClientInfo { NetClientOptionsKind type; @@ -55,6 +56,7 @@ typedef struct NetClientInfo { NetCleanup *cleanup; LinkStatusChanged *link_status_changed; NetPoll *poll; + NetAnnounce *announce; } NetClientInfo; struct NetClientState { diff --git a/savevm.c b/savevm.c index a8a53ef..fd69e32 100644 --- a/savevm.c +++ b/savevm.c @@ -76,12 +76,16 @@ static int announce_self_create(uint8_t *buf, static void qemu_announce_self_iter(NICState *nic, void *opaque) { + NetClientState *nc = qemu_get_queue(nic); + NetAnnounce *announce = nc->info->announce; uint8_t buf[60]; int len; - len = announce_self_create(buf, nic->conf->macaddr.a); + if (!announce || announce(nc)) { + len = announce_self_create(buf, nic->conf->macaddr.a); - qemu_send_packet_raw(qemu_get_queue(nic), buf, len); + qemu_send_packet_raw(qemu_get_queue(nic), buf, len); + } }