aboutsummaryrefslogtreecommitdiffstats
path: root/vnet
diff options
context:
space:
mode:
authorYoann Desmouceaux <ydesmouc@cisco.com>2016-03-08 14:54:28 +0100
committerGerrit Code Review <gerrit@fd.io>2016-03-14 09:13:02 +0000
commitfe2da0e01a8873c2aa586cf170d276c81174b28e (patch)
tree566bd90b10741af01223d18e598aee995fdff6ef /vnet
parent526b5e85468a7f4becd6c006bcba251ae6da35e2 (diff)
Better match vhost-user specification for live migration
The specification requires logging of used vring writes to only happen when VHOST_VRING_F_LOG flag is present in VHOST_USER_SET_VRING_ADDR message; take that into account. Change-Id: I9bf4b9eb43a1783b39909b1a3ea1a3bdf50d91a8 Signed-off-by: Yoann Desmouceaux <ydesmouc@cisco.com>
Diffstat (limited to 'vnet')
-rw-r--r--vnet/vnet/devices/virtio/vhost-user.c10
-rw-r--r--vnet/vnet/devices/virtio/vhost-user.h2
2 files changed, 10 insertions, 2 deletions
diff --git a/vnet/vnet/devices/virtio/vhost-user.c b/vnet/vnet/devices/virtio/vhost-user.c
index 945f03a1eea..13a8fe1b654 100644
--- a/vnet/vnet/devices/virtio/vhost-user.c
+++ b/vnet/vnet/devices/virtio/vhost-user.c
@@ -231,6 +231,7 @@ static inline void vhost_user_if_disconnect(vhost_user_intf_t * vui)
vui->vrings[q].avail = NULL;
vui->vrings[q].used = NULL;
vui->vrings[q].log_guest_addr = 0;
+ vui->vrings[q].log_used = 0;
}
unmap_all_mem_regions(vui);
@@ -259,8 +260,10 @@ always_inline void vhost_user_log_dirty_pages(vhost_user_intf_t * vui,
}
#define vhost_user_log_dirty_ring(vui, vq, member) \
- vhost_user_log_dirty_pages(vui, vq->log_guest_addr + offsetof(vring_used_t, member), \
- sizeof(vq->used->member))
+ if (PREDICT_FALSE(vq->log_used)) { \
+ vhost_user_log_dirty_pages(vui, vq->log_guest_addr + offsetof(vring_used_t, member), \
+ sizeof(vq->used->member)); \
+ }
static clib_error_t * vhost_user_socket_read (unix_file_t * uf)
{
@@ -370,6 +373,7 @@ static clib_error_t * vhost_user_socket_read (unix_file_t * uf)
vui->vrings[q].avail = 0;
vui->vrings[q].used = 0;
vui->vrings[q].log_guest_addr = 0;
+ vui->vrings[q].log_used = 0;
}
DBG_SOCK("interface %d disconnected", vui->sw_if_index);
@@ -451,6 +455,8 @@ static clib_error_t * vhost_user_socket_read (unix_file_t * uf)
}
vui->vrings[msg.state.index].log_guest_addr = msg.addr.log_guest_addr;
+ vui->vrings[msg.state.index].log_used =
+ (msg.addr.flags & (1 << VHOST_VRING_F_LOG)) ? 1 : 0;
/* Spec says: If VHOST_USER_F_PROTOCOL_FEATURES has not been negotiated,
the ring is initialized in an enabled state. */
diff --git a/vnet/vnet/devices/virtio/vhost-user.h b/vnet/vnet/devices/virtio/vhost-user.h
index 83dbf3e3b22..be011165b1f 100644
--- a/vnet/vnet/devices/virtio/vhost-user.h
+++ b/vnet/vnet/devices/virtio/vhost-user.h
@@ -28,6 +28,7 @@
#define VHOST_USER_PROTOCOL_F_MQ 0
#define VHOST_USER_PROTOCOL_F_LOG_SHMFD 1
+#define VHOST_VRING_F_LOG 0
#if RTE_VERSION >= RTE_VERSION_NUM(2, 2, 0, 0)
#define VHOST_USER_F_PROTOCOL_FEATURES 30
@@ -178,6 +179,7 @@ typedef struct {
int kickfd;
int errfd;
u32 enabled;
+ u32 log_used;
u32 callfd_idx;
u32 n_since_last_int;
f64 int_deadline;