mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-03 07:43:54 -06:00
vhost user: add rarp sending after live migration for legacy guest
A new vhost user message is added to allow QEMU to ask to vhost user backend to broadcast a fake RARP after live migration for guest without GUEST_ANNOUNCE capability. This new message is sent only if the backend supports the new VHOST_USER_PROTOCOL_F_RARP protocol feature. The payload of this new message is the MAC address of the guest (not known by the backend). The MAC address is copied in the first 6 bytes of a u64 to avoid to create a new payload message type. This new message has no equivalent ioctl so a new callback is added in the userOps structure to send the request. Upon reception of this new message the vhost user backend must generate and broadcast a fake RARP request to notify the migration is terminated. Signed-off-by: Thibaut Collet <thibaut.collet@6wind.com> [Rebased and fixed checkpatch errors - Marc-André] Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com> Tested-by: Thibaut Collet <thibaut.collet@6wind.com>
This commit is contained in:
parent
f6f56291de
commit
3e866365e1
6 changed files with 89 additions and 3 deletions
|
@ -10,6 +10,7 @@
|
|||
|
||||
#include "hw/virtio/vhost.h"
|
||||
#include "hw/virtio/vhost-backend.h"
|
||||
#include "hw/virtio/virtio-net.h"
|
||||
#include "sysemu/char.h"
|
||||
#include "sysemu/kvm.h"
|
||||
#include "qemu/error-report.h"
|
||||
|
@ -27,9 +28,10 @@
|
|||
#define VHOST_MEMORY_MAX_NREGIONS 8
|
||||
#define VHOST_USER_F_PROTOCOL_FEATURES 30
|
||||
|
||||
#define VHOST_USER_PROTOCOL_FEATURE_MASK 0x3ULL
|
||||
#define VHOST_USER_PROTOCOL_FEATURE_MASK 0x7ULL
|
||||
#define VHOST_USER_PROTOCOL_F_MQ 0
|
||||
#define VHOST_USER_PROTOCOL_F_LOG_SHMFD 1
|
||||
#define VHOST_USER_PROTOCOL_F_RARP 2
|
||||
|
||||
typedef enum VhostUserRequest {
|
||||
VHOST_USER_NONE = 0,
|
||||
|
@ -51,6 +53,7 @@ typedef enum VhostUserRequest {
|
|||
VHOST_USER_SET_PROTOCOL_FEATURES = 16,
|
||||
VHOST_USER_GET_QUEUE_NUM = 17,
|
||||
VHOST_USER_SET_VRING_ENABLE = 18,
|
||||
VHOST_USER_SEND_RARP = 19,
|
||||
VHOST_USER_MAX
|
||||
} VhostUserRequest;
|
||||
|
||||
|
@ -566,6 +569,32 @@ static bool vhost_user_requires_shm_log(struct vhost_dev *dev)
|
|||
VHOST_USER_PROTOCOL_F_LOG_SHMFD);
|
||||
}
|
||||
|
||||
static int vhost_user_migration_done(struct vhost_dev *dev, char* mac_addr)
|
||||
{
|
||||
VhostUserMsg msg = { 0 };
|
||||
int err;
|
||||
|
||||
assert(dev->vhost_ops->backend_type == VHOST_BACKEND_TYPE_USER);
|
||||
|
||||
/* If guest supports GUEST_ANNOUNCE do nothing */
|
||||
if (virtio_has_feature(dev->acked_features, VIRTIO_NET_F_GUEST_ANNOUNCE)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* if backend supports VHOST_USER_PROTOCOL_F_RARP ask it to send the RARP */
|
||||
if (virtio_has_feature(dev->protocol_features,
|
||||
VHOST_USER_PROTOCOL_F_RARP)) {
|
||||
msg.request = VHOST_USER_SEND_RARP;
|
||||
msg.flags = VHOST_USER_VERSION;
|
||||
memcpy((char *)&msg.u64, mac_addr, 6);
|
||||
msg.size = sizeof(m.u64);
|
||||
|
||||
err = vhost_user_write(dev, &msg, NULL, 0);
|
||||
return err;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
const VhostOps user_ops = {
|
||||
.backend_type = VHOST_BACKEND_TYPE_USER,
|
||||
.vhost_backend_init = vhost_user_init,
|
||||
|
@ -587,4 +616,5 @@ const VhostOps user_ops = {
|
|||
.vhost_get_vq_index = vhost_user_get_vq_index,
|
||||
.vhost_set_vring_enable = vhost_user_set_vring_enable,
|
||||
.vhost_requires_shm_log = vhost_user_requires_shm_log,
|
||||
.vhost_migration_done = vhost_user_migration_done,
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue