qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Michael S. Tsirkin" <mst@redhat.com>
To: Thibaut Collet <thibaut.collet@6wind.com>
Cc: jasowang@redhat.com, qemu-devel@nongnu.org, stefanha@redhat.com
Subject: Re: [Qemu-devel] [PATCH v3 1/2] vhost user: add support of live migration
Date: Wed, 10 Jun 2015 15:52:43 +0200	[thread overview]
Message-ID: <20150610154748-mutt-send-email-mst@redhat.com> (raw)
In-Reply-To: <1433943783-20125-2-git-send-email-thibaut.collet@6wind.com>

On Wed, Jun 10, 2015 at 03:43:02PM +0200, Thibaut Collet wrote:
> Some vhost client/backend are able to support live migration.
> To provide this service the following features must be added:
> 1. GARP from guest after live migration:
>    the VIRTIO_NET_F_GUEST_ANNOUNCE capability is added to vhost-net when netdev
>    backend is vhost-user to let virtio-net NIC manages GARP after migration.
> 2. RARP on vhost-user:
>    After a live migration RARP are automatically sent to any interfaces. A
>    receive callback is added to vhost-user to catch this packet. If guest
>    supports VIRTIO_NET_F_GUEST_ANNOUNCE this packet is discarded to avoid
>    message duplication (already done by virtio-net NIC). For legacy guest
>    without VIRTIO_NET_F_GUEST_ANNOUNCE a warning message is displayed to
>    alert the user. RARP must be sent to the vhost client/backend.
> 
> Signed-off-by: Thibaut Collet <thibaut.collet@6wind.com>
> ---
>  hw/net/vhost_net.c      |   15 +++++++++++++++
>  include/net/vhost_net.h |    1 +
>  net/vhost-user.c        |   21 +++++++++++++++++++--
>  3 files changed, 35 insertions(+), 2 deletions(-)
> 
> diff --git a/hw/net/vhost_net.c b/hw/net/vhost_net.c
> index 426b23e..4a42325 100644
> --- a/hw/net/vhost_net.c
> +++ b/hw/net/vhost_net.c
> @@ -82,6 +82,8 @@ static const int user_feature_bits[] = {
>      VIRTIO_NET_F_CTRL_MAC_ADDR,
>      VIRTIO_NET_F_CTRL_GUEST_OFFLOADS,
>  
> +    VIRTIO_NET_F_GUEST_ANNOUNCE,
> +
>      VIRTIO_NET_F_MQ,
>  
>      VHOST_INVALID_FEATURE_BIT
> @@ -365,6 +367,15 @@ void vhost_net_stop(VirtIODevice *dev, NetClientState *ncs,
>      assert(r >= 0);
>  }
>  
> +void vhost_net_inject_rarp(struct vhost_net *net, const uint8_t *buf, size_t size)
> +{
> +    if ((net->dev.acked_features & (1 << VIRTIO_NET_F_GUEST_ANNOUNCE)) == 0) {
> +        fprintf(stderr,
> +                "Warning: Guest with no VIRTIO_NET_F_GUEST_ANNOUNCE support. RARP must be sent by vhost-user backend\n");
> +        fflush(stderr);

And maybe it does, then you are just filling log up with useless
warnings. Pls add some ifdef so this isn't normally compiled in.

> +    }

Can you move this out to vhost-user? It's not a generic function, is it?

> +}
> +
>  void vhost_net_cleanup(struct vhost_net *net)
>  {
>      vhost_dev_cleanup(&net->dev);
> @@ -427,6 +438,10 @@ void vhost_net_stop(VirtIODevice *dev,
>  {
>  }
>  
> +void vhost_net_inject_rarp(struct vhost_net *net, const uint8_t *buf, size_t size);
> +{
> +}
> +
>  void vhost_net_cleanup(struct vhost_net *net)
>  {
>  }
> diff --git a/include/net/vhost_net.h b/include/net/vhost_net.h
> index b1c18a3..e82a0f9 100644
> --- a/include/net/vhost_net.h
> +++ b/include/net/vhost_net.h
> @@ -20,6 +20,7 @@ bool vhost_net_query(VHostNetState *net, VirtIODevice *dev);
>  int vhost_net_start(VirtIODevice *dev, NetClientState *ncs, int total_queues);
>  void vhost_net_stop(VirtIODevice *dev, NetClientState *ncs, int total_queues);
>  
> +void vhost_net_inject_rarp(VHostNetState *net, const uint8_t *buf, size_t size);
>  void vhost_net_cleanup(VHostNetState *net);
>  
>  unsigned vhost_net_get_features(VHostNetState *net, unsigned features);
> diff --git a/net/vhost-user.c b/net/vhost-user.c
> index 8d26728..69c2313 100644
> --- a/net/vhost-user.c
> +++ b/net/vhost-user.c
> @@ -66,6 +66,24 @@ static void vhost_user_stop(VhostUserState *s)
>      s->vhost_net = 0;
>  }
>  
> +static ssize_t vhost_user_receive(NetClientState *nc, const uint8_t *buf,
> +                                  size_t size)
> +{
> +    if (size == 60) {
> +        /* Assume it is a RARP request sent automatically after a
> +         * live migration */
> +        /* The RARP must be sent if guest does not support
> +         * VIRTIO_NET_F_GUEST_ANNOUNCE */
> +        VhostUserState *s = DO_UPCAST(VhostUserState, nc, nc);
> +
> +        vhost_net_inject_rarp(s->vhost_net, buf, size);
> +    } else {
> +        fprintf(stderr,"Vhost user receives unexpected packets\n");
> +        fflush(stderr);
> +    }
> +    return size;
> +}
> +
>  static void vhost_user_cleanup(NetClientState *nc)
>  {
>      VhostUserState *s = DO_UPCAST(VhostUserState, nc, nc);
> @@ -91,6 +109,7 @@ static bool vhost_user_has_ufo(NetClientState *nc)
>  static NetClientInfo net_vhost_user_info = {
>          .type = NET_CLIENT_OPTIONS_KIND_VHOST_USER,
>          .size = sizeof(VhostUserState),
> +        .receive = vhost_user_receive,
>          .cleanup = vhost_user_cleanup,
>          .has_vnet_hdr = vhost_user_has_vnet_hdr,
>          .has_ufo = vhost_user_has_ufo,
> @@ -147,8 +166,6 @@ static int net_vhost_user_init(NetClientState *peer, const char *device,
>  
>          s = DO_UPCAST(VhostUserState, nc, nc);
>  
> -        /* We don't provide a receive callback */
> -        s->nc.receive_disabled = 1;
>          s->chr = chr;
>          s->nc.queue_index = i;
>  
> -- 
> 1.7.10.4

  reply	other threads:[~2015-06-10 13:52 UTC|newest]

Thread overview: 48+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-06-10 13:43 [Qemu-devel] [PATCH v3 0/2] Add live migration for vhost user Thibaut Collet
2015-06-10 13:43 ` [Qemu-devel] [PATCH v3 1/2] vhost user: add support of live migration Thibaut Collet
2015-06-10 13:52   ` Michael S. Tsirkin [this message]
2015-06-10 14:22     ` Thibaut Collet
2015-06-10 14:27       ` Michael S. Tsirkin
2015-06-10 15:24         ` Thibaut Collet
2015-06-10 15:34     ` Stefan Hajnoczi
2015-06-23  6:01   ` Michael S. Tsirkin
2015-06-10 13:43 ` [Qemu-devel] [PATCH v3 2/2] vhost user: Add RARP injection for legacy guest Thibaut Collet
2015-06-10 15:34   ` Michael S. Tsirkin
2015-06-10 15:48     ` Thibaut Collet
2015-06-10 16:00       ` Michael S. Tsirkin
2015-06-10 20:25         ` Thibaut Collet
2015-06-10 20:50           ` Michael S. Tsirkin
2015-06-11  5:34             ` Thibaut Collet
2015-06-11  5:39           ` Jason Wang
2015-06-11  5:49             ` Thibaut Collet
2015-06-11  5:54               ` Jason Wang
2015-06-11 10:38                 ` Michael S. Tsirkin
2015-06-11 12:10                   ` Thibaut Collet
2015-06-11 12:13                     ` Michael S. Tsirkin
2015-06-11 12:33                       ` Thibaut Collet
2015-06-12  7:55                       ` Jason Wang
2015-06-12 11:53                         ` Thibaut Collet
2015-06-12 14:28                         ` Michael S. Tsirkin
2015-06-15  7:43                           ` Jason Wang
2015-06-15  8:44                             ` Michael S. Tsirkin
2015-06-15 12:12                               ` Thibaut Collet
2015-06-15 12:45                                 ` Michael S. Tsirkin
2015-06-15 13:04                                   ` Thibaut Collet
2015-06-16  5:29                                 ` Jason Wang
2015-06-16  7:24                                   ` Thibaut Collet
2015-06-16  8:05                                     ` Jason Wang
2015-06-16  8:16                                       ` Thibaut Collet
2015-06-17  4:16                                         ` Jason Wang
2015-06-17  6:42                                           ` Michael S. Tsirkin
2015-06-17  7:05                                             ` Thibaut Collet
2015-06-18 15:16                                       ` Thibaut Collet
2015-06-23  2:12                                         ` Jason Wang
2015-06-23  5:49                                           ` Michael S. Tsirkin
2015-06-24  8:31                                             ` Jason Wang
2015-06-24 11:05                                               ` Michael S. Tsirkin
2015-06-25  9:59                                                 ` Jason Wang
2015-06-25 11:01                                                   ` Thibaut Collet
2015-06-25 12:53                                                     ` Michael S. Tsirkin
2015-06-25 14:22                                                       ` Thibaut Collet
2015-06-26  4:06                                                         ` Jason Wang
2015-06-16  3:35                               ` 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=20150610154748-mutt-send-email-mst@redhat.com \
    --to=mst@redhat.com \
    --cc=jasowang@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@redhat.com \
    --cc=thibaut.collet@6wind.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).