From patchwork Sat Oct 22 05:38:57 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Wang X-Patchwork-Id: 121148 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id E40F11007D3 for ; Sat, 22 Oct 2011 16:39:15 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752840Ab1JVFjJ (ORCPT ); Sat, 22 Oct 2011 01:39:09 -0400 Received: from mx1.redhat.com ([209.132.183.28]:58543 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752733Ab1JVFjI (ORCPT ); Sat, 22 Oct 2011 01:39:08 -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 p9M5d2HT012867 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Sat, 22 Oct 2011 01:39:02 -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 p9M5cwFk022375; Sat, 22 Oct 2011 01:38:58 -0400 Subject: [RFC v2 PATCH 3/4] net: model specific announcing support To: aliguori@us.ibm.com, quintela@redhat.com, jan.kiszka@siemens.com, mst@redhat.com, qemu-devel@nongnu.org, blauwirbel@gmail.com From: Jason Wang Cc: pbonzini@redhat.com, rusty@rustcorp.com.au, kvm@vger.kernel.org, netdev@vger.kernel.org Date: Sat, 22 Oct 2011 13:38:57 +0800 Message-ID: <20111022053857.21526.82999.stgit@dhcp-8-146.nay.redhat.com> In-Reply-To: <20111022053540.21526.61249.stgit@dhcp-8-146.nay.redhat.com> References: <20111022053540.21526.61249.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 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org This patch introduce a function pointer in NetClientInfo which is called during self announcement to do the model specific announcement such as sending gratuitous packet. Previous method is kept when model specific announcing fails or without it. 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(-) -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/net.h b/net.h index 4943d4b..1845f01 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 8293ee6..de6a01a 100644 --- a/savevm.c +++ b/savevm.c @@ -89,10 +89,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); + } }