From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:49408) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S7SaX-0007x8-NY for qemu-devel@nongnu.org; Tue, 13 Mar 2012 10:20:39 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1S7Sa2-0005RC-BV for qemu-devel@nongnu.org; Tue, 13 Mar 2012 10:20:33 -0400 Received: from mx1.redhat.com ([209.132.183.28]:48635) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S7Sa2-0005Q1-3b for qemu-devel@nongnu.org; Tue, 13 Mar 2012 10:20:02 -0400 Date: Tue, 13 Mar 2012 16:20:11 +0200 From: "Michael S. Tsirkin" Message-ID: <20120313142011.GB14931@redhat.com> References: <20120313085500.10958.92659.stgit@amd-6168-8-1.englab.nay.redhat.com> <20120313085631.10958.53341.stgit@amd-6168-8-1.englab.nay.redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20120313085631.10958.53341.stgit@amd-6168-8-1.englab.nay.redhat.com> Subject: Re: [Qemu-devel] [V4 PATCH 3/5] net: model specific announcing support List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Jason Wang Cc: quintela@redhat.com, aliguori@us.ibm.com, rusty@rustcorp.com.au, stefanha@linux.vnet.ibm.com, qemu-devel@nongnu.org On Tue, Mar 13, 2012 at 04:56:31PM +0800, Jason Wang wrote: > 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 > --- > 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 82b9d3a..0a901dc 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 == NULL || func(&nic->nc) != 0) { Shorter as !func || func(&nic->nc) > + len = announce_self_create(buf, nic->conf->macaddr.a); > + qemu_send_packet_raw(&nic->nc, buf, len); > + } > } > >