aboutsummaryrefslogtreecommitdiffstats
path: root/vnet/vnet/devices/virtio/vhost-user.h
diff options
context:
space:
mode:
authorYoann Desmouceaux <ydesmouc@cisco.com>2016-02-24 22:51:00 +0100
committerGerrit Code Review <gerrit@fd.io>2016-02-25 13:53:14 +0000
commit4667c229a05458eb7558cf927a44df3d5f585c11 (patch)
treed2fac70af78c9948aa302546d9512a149a45e87b /vnet/vnet/devices/virtio/vhost-user.h
parent1f49ed666af8b9cb889f9ea61f084341d0b6c4f4 (diff)
Add live migration support to (non-dpdk) vhost-user driver
This patch adds live migration support to vhost interfaces, by supporting the VHOST_F_LOG_ALL feature. When qemu starts a migration, it will negotiate this feature, and provide a fd for a "dirty log" shared mem space. This log is a bitmap representing pages in the device memory. Whenever we touch memory pointed by a "desc" vring, or modify a "used" vring, we log the corresponding page in the bitmap. This allows qemu to send the dirty page to the destination host. See https://github.com/qemu/qemu/blob/master/docs/specs/vhost-user.txt, ยง "Live migration" for more details. In addition to this, this code provides support for the VHOST_USER_F_PROTOCOL_FEATURES feature, and to VHOST_USER_{GET,SET}_PROTOCOL_FEATURES and VHOST_USER_SET_VRING_ENABLE messages, required for live migration. Change-Id: I7577efce8bd67653218f4291af1d651de451e552 Signed-off-by: Yoann Desmouceaux <ydesmouc@cisco.com>
Diffstat (limited to 'vnet/vnet/devices/virtio/vhost-user.h')
-rw-r--r--vnet/vnet/devices/virtio/vhost-user.h26
1 files changed, 22 insertions, 4 deletions
diff --git a/vnet/vnet/devices/virtio/vhost-user.h b/vnet/vnet/devices/virtio/vhost-user.h
index bf3f6d5352b..83dbf3e3b22 100644
--- a/vnet/vnet/devices/virtio/vhost-user.h
+++ b/vnet/vnet/devices/virtio/vhost-user.h
@@ -26,9 +26,11 @@
#define VIRTQ_DESC_F_NEXT 1
#define VHOST_USER_REPLY_MASK (0x1 << 2)
+#define VHOST_USER_PROTOCOL_F_MQ 0
+#define VHOST_USER_PROTOCOL_F_LOG_SHMFD 1
+
#if RTE_VERSION >= RTE_VERSION_NUM(2, 2, 0, 0)
#define VHOST_USER_F_PROTOCOL_FEATURES 30
-#define VHOST_USER_PROTOCOL_F_MQ 0
#define VHOST_USER_PROTOCOL_FEATURES (1ULL << VHOST_USER_PROTOCOL_F_MQ)
/* If multiqueue is provided by host, then we suppport it. */
@@ -40,7 +42,11 @@
#define foreach_virtio_net_feature \
_ (VIRTIO_NET_F_MRG_RXBUF, 15) \
- _ (VIRTIO_F_ANY_LAYOUT, 27)
+ _ (VIRTIO_F_ANY_LAYOUT, 27) \
+ _ (VHOST_F_LOG_ALL, 26) \
+ _ (VIRTIO_NET_F_GUEST_ANNOUNCE, 21) \
+ _ (VHOST_USER_F_PROTOCOL_FEATURES, 30)
+
typedef enum {
#define _(f,n) FEAT_##f = (n),
@@ -80,6 +86,11 @@ typedef struct vhost_vring_addr {
u64 desc_user_addr, used_user_addr, avail_user_addr, log_guest_addr;
} vhost_vring_addr_t;
+typedef struct vhost_user_log {
+ u64 size;
+ u64 offset;
+} vhost_user_log_t;
+
typedef enum vhost_user_req {
VHOST_USER_NONE = 0,
VHOST_USER_GET_FEATURES = 1,
@@ -96,12 +107,12 @@ typedef enum vhost_user_req {
VHOST_USER_SET_VRING_KICK = 12,
VHOST_USER_SET_VRING_CALL = 13,
VHOST_USER_SET_VRING_ERR = 14,
-#if RTE_VERSION >= RTE_VERSION_NUM(2, 2, 0, 0)
VHOST_USER_GET_PROTOCOL_FEATURES = 15,
VHOST_USER_SET_PROTOCOL_FEATURES = 16,
+#if RTE_VERSION >= RTE_VERSION_NUM(2, 2, 0, 0)
VHOST_USER_GET_QUEUE_NUM = 17,
- VHOST_USER_SET_VRING_ENABLE = 18,
#endif
+ VHOST_USER_SET_VRING_ENABLE = 18,
VHOST_USER_MAX
} vhost_user_req_t;
@@ -151,6 +162,7 @@ typedef struct vhost_user_msg {
vhost_vring_state_t state;
vhost_vring_addr_t addr;
vhost_user_memory_t memory;
+ vhost_user_log_t log;
};
} __attribute ((packed)) vhost_user_msg_t;
@@ -161,9 +173,11 @@ typedef struct {
vring_desc_t *desc;
vring_avail_t *avail;
vring_used_t *used;
+ u64 log_guest_addr;
int callfd;
int kickfd;
int errfd;
+ u32 enabled;
u32 callfd_idx;
u32 n_since_last_int;
f64 int_deadline;
@@ -186,6 +200,7 @@ typedef struct {
u32 nregions;
u64 features;
u64 feature_mask;
+ u64 protocol_features;
u32 num_vrings;
vhost_user_memory_region_t regions[VHOST_MEMORY_MAX_NREGIONS];
void * region_mmap_addr[VHOST_MEMORY_MAX_NREGIONS];
@@ -194,6 +209,9 @@ typedef struct {
int virtio_net_hdr_sz;
int is_any_layout;
u32 * d_trace_buffers;
+
+ void * log_base_addr;
+ u64 log_size;
} vhost_user_intf_t;
typedef struct {