qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Michael S. Tsirkin" <mst@redhat.com>
To: Jason Wang <jasowang@redhat.com>
Cc: quintela@redhat.com, aliguori@us.ibm.com, rusty@rustcorp.com.au,
	stefanha@linux.vnet.ibm.com, qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [V4 PATCH 3/5] net: model specific announcing support
Date: Tue, 13 Mar 2012 16:20:11 +0200	[thread overview]
Message-ID: <20120313142011.GB14931@redhat.com> (raw)
In-Reply-To: <20120313085631.10958.53341.stgit@amd-6168-8-1.englab.nay.redhat.com>

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 <jasowang@redhat.com>
> ---
>  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);
> +    }
>  }
>  
>  

  reply	other threads:[~2012-03-13 14:20 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-03-13  8:56 [Qemu-devel] [V4 PATCH 0/5] Send the gratuitous packets by guest Jason Wang
2012-03-13  8:56 ` [Qemu-devel] [V4 PATCH 1/5] net: reset the count after rounds of announcing Jason Wang
2012-03-13  8:56 ` [Qemu-devel] [V4 PATCH 2/5] net: announce self after vm start Jason Wang
2012-03-13  9:18   ` Paolo Bonzini
2012-03-15  6:08     ` Jason Wang
2012-03-13 14:23   ` Michael S. Tsirkin
2012-03-15  6:11     ` Jason Wang
2012-03-13  8:56 ` [Qemu-devel] [V4 PATCH 3/5] net: model specific announcing support Jason Wang
2012-03-13 14:20   ` Michael S. Tsirkin [this message]
2012-03-13  8:56 ` [Qemu-devel] [V4 PATCH 4/5] virtio-net: notify guest to annouce itself Jason Wang
2012-03-13 14:18   ` Michael S. Tsirkin
2012-03-13 14:20   ` Michael S. Tsirkin
2012-03-13  8:56 ` [Qemu-devel] [V4 PATCH 5/5] virtio-net: compat guest announce support Jason Wang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20120313142011.GB14931@redhat.com \
    --to=mst@redhat.com \
    --cc=aliguori@us.ibm.com \
    --cc=jasowang@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=quintela@redhat.com \
    --cc=rusty@rustcorp.com.au \
    --cc=stefanha@linux.vnet.ibm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).