Skip to content

Commit

Permalink
vhost user: add support of live migration
Browse files Browse the repository at this point in the history
Some vhost user backends are able to support live migration.
To provide this service the following features must be added:
1. Add the VIRTIO_NET_F_GUEST_ANNOUNCE capability to vhost-net when netdev
   backend is vhost-user.
2. Provide a nop receive callback to vhost-user.
   This callback is called by:
    *  qemu_announce_self after a migration to send fake RARP to avoid network
       outage for peers talking to the migrated guest.
         - For guest with GUEST_ANNOUNCE capabilities, guest already sends GARP
           when the bit VIRTIO_NET_S_ANNOUNCE is set.
           => These packets must be discarded.
         - For guest without GUEST_ANNOUNCE capabilities, migration termination
           is notified when the guest sends packets.
           => These packets can be discarded.
    * virtio_net_tx_bh with a dummy boot to send fake bootp/dhcp request.
      BIOS guest manages virtio driver to send 4 bootp/dhcp request in case of
      dummy boot.
      => These packets must be discarded.

Signed-off-by: Thibaut Collet <[email protected]>
Reviewed-by: Michael S. Tsirkin <[email protected]>
Signed-off-by: Michael S. Tsirkin <[email protected]>
Tested-by: Thibaut Collet <[email protected]>
  • Loading branch information
Thibaut Collet authored and mstsirkin committed Oct 22, 2015
1 parent 69b32a6 commit f6f5629
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
2 changes: 2 additions & 0 deletions hw/net/vhost_net.c
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,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
Expand Down
12 changes: 10 additions & 2 deletions net/vhost-user.c
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,15 @@ static int vhost_user_start(int queues, NetClientState *ncs[])
return -1;
}

static ssize_t vhost_user_receive(NetClientState *nc, const uint8_t *buf,
size_t size)
{
/* Discard the request that is received and managed by backend
* by an other way.
*/
return size;
}

static void vhost_user_cleanup(NetClientState *nc)
{
VhostUserState *s = DO_UPCAST(VhostUserState, nc, nc);
Expand Down Expand Up @@ -132,6 +141,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,
Expand Down Expand Up @@ -182,8 +192,6 @@ static int net_vhost_user_init(NetClientState *peer, const char *device,
snprintf(nc->info_str, sizeof(nc->info_str), "vhost-user%d to %s",
i, chr->label);

/* We don't provide a receive callback */
nc->receive_disabled = 1;
nc->queue_index = i;

s = DO_UPCAST(VhostUserState, nc, nc);
Expand Down

0 comments on commit f6f5629

Please sign in to comment.