aboutsummaryrefslogtreecommitdiffstats
path: root/vnet
diff options
context:
space:
mode:
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;