[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 17/38] vhost-user: add vhost_user_requires_shm_log()
From: |
Michael S. Tsirkin |
Subject: |
[Qemu-devel] [PULL 17/38] vhost-user: add vhost_user_requires_shm_log() |
Date: |
Wed, 21 Oct 2015 13:27:27 +0300 |
From: Marc-André Lureau <address@hidden>
Check if the backend has VHOST_USER_PROTOCOL_F_LOG_SHMFD feature and
require a shared log.
Signed-off-by: Marc-André Lureau <address@hidden>
Reviewed-by: Michael S. Tsirkin <address@hidden>
Signed-off-by: Michael S. Tsirkin <address@hidden>
Tested-by: Thibaut Collet <address@hidden>
---
include/hw/virtio/vhost-backend.h | 4 ++++
hw/virtio/vhost-user.c | 14 ++++++++++++--
2 files changed, 16 insertions(+), 2 deletions(-)
diff --git a/include/hw/virtio/vhost-backend.h
b/include/hw/virtio/vhost-backend.h
index c903573..c33570a 100644
--- a/include/hw/virtio/vhost-backend.h
+++ b/include/hw/virtio/vhost-backend.h
@@ -11,6 +11,8 @@
#ifndef VHOST_BACKEND_H_
#define VHOST_BACKEND_H_
+#include <stdbool.h>
+
typedef enum VhostBackendType {
VHOST_BACKEND_TYPE_NONE = 0,
VHOST_BACKEND_TYPE_KERNEL = 1,
@@ -29,6 +31,7 @@ typedef int (*vhost_backend_set_vring_enable)(struct
vhost_dev *dev, int enable)
typedef int (*vhost_backend_memslots_limit)(struct vhost_dev *dev);
typedef int (*vhost_set_log_base_op)(struct vhost_dev *dev, uint64_t base);
+typedef bool (*vhost_requires_shm_log_op)(struct vhost_dev *dev);
typedef struct VhostOps {
VhostBackendType backend_type;
@@ -39,6 +42,7 @@ typedef struct VhostOps {
vhost_backend_set_vring_enable vhost_backend_set_vring_enable;
vhost_backend_memslots_limit vhost_backend_memslots_limit;
vhost_set_log_base_op vhost_set_log_base;
+ vhost_requires_shm_log_op vhost_requires_shm_log;
} VhostOps;
extern const VhostOps user_ops;
diff --git a/hw/virtio/vhost-user.c b/hw/virtio/vhost-user.c
index 5d51289..e10ce87 100644
--- a/hw/virtio/vhost-user.c
+++ b/hw/virtio/vhost-user.c
@@ -25,9 +25,10 @@
#define VHOST_MEMORY_MAX_NREGIONS 8
#define VHOST_USER_F_PROTOCOL_FEATURES 30
-#define VHOST_USER_PROTOCOL_FEATURE_MASK 0x1ULL
-#define VHOST_USER_PROTOCOL_F_MQ 0
+#define VHOST_USER_PROTOCOL_FEATURE_MASK 0x3ULL
+#define VHOST_USER_PROTOCOL_F_MQ 0
+#define VHOST_USER_PROTOCOL_F_LOG_SHMFD 1
typedef enum VhostUserRequest {
VHOST_USER_NONE = 0,
@@ -458,6 +459,14 @@ static int vhost_user_memslots_limit(struct vhost_dev *dev)
return VHOST_MEMORY_MAX_NREGIONS;
}
+static bool vhost_user_requires_shm_log(struct vhost_dev *dev)
+{
+ assert(dev->vhost_ops->backend_type == VHOST_BACKEND_TYPE_USER);
+
+ return virtio_has_feature(dev->protocol_features,
+ VHOST_USER_PROTOCOL_F_LOG_SHMFD);
+}
+
const VhostOps user_ops = {
.backend_type = VHOST_BACKEND_TYPE_USER,
.vhost_call = vhost_user_call,
@@ -467,4 +476,5 @@ const VhostOps user_ops = {
.vhost_backend_set_vring_enable = vhost_user_set_vring_enable,
.vhost_backend_memslots_limit = vhost_user_memslots_limit,
.vhost_set_log_base = vhost_set_log_base,
+ .vhost_requires_shm_log = vhost_user_requires_shm_log,
};
--
MST
- [Qemu-devel] [PULL 05/38] vhost: add vhost_has_free_slot() interface, (continued)
- [Qemu-devel] [PULL 05/38] vhost: add vhost_has_free_slot() interface, Michael S. Tsirkin, 2015/10/21
- [Qemu-devel] [PULL 08/38] virtio: add some migration doc, Michael S. Tsirkin, 2015/10/21
- [Qemu-devel] [PULL 09/38] configure: probe for memfd, Michael S. Tsirkin, 2015/10/21
- [Qemu-devel] [PULL 11/38] build-sys: split util-obj- on multi-lines, Michael S. Tsirkin, 2015/10/21
- [Qemu-devel] [PULL 12/38] util: add linux-only memfd fallback, Michael S. Tsirkin, 2015/10/21
- [Qemu-devel] [PULL 13/38] util: add memfd helpers, Michael S. Tsirkin, 2015/10/21
- [Qemu-devel] [PULL 14/38] util: add fallback for qemu_memfd_alloc(), Michael S. Tsirkin, 2015/10/21
- [Qemu-devel] [PULL 15/38] vhost: document log resizing, Michael S. Tsirkin, 2015/10/21
- [Qemu-devel] [PULL 16/38] vhost: add vhost_set_log_base op, Michael S. Tsirkin, 2015/10/21
- [Qemu-devel] [PULL 10/38] linux-headers: add unistd.h, Michael S. Tsirkin, 2015/10/21
- [Qemu-devel] [PULL 17/38] vhost-user: add vhost_user_requires_shm_log(),
Michael S. Tsirkin <=
- [Qemu-devel] [PULL 18/38] vhost: alloc shareable log, Michael S. Tsirkin, 2015/10/21
- [Qemu-devel] [PULL 19/38] vhost-user: send log shm fd along with log_base, Michael S. Tsirkin, 2015/10/21
- [Qemu-devel] [PULL 20/38] vhost-user: add a migration blocker, Michael S. Tsirkin, 2015/10/21
- [Qemu-devel] [PULL 22/38] vhost-user: document migration log, Michael S. Tsirkin, 2015/10/21
- [Qemu-devel] [PULL 21/38] vhost: use a function for each call, Michael S. Tsirkin, 2015/10/21
- [Qemu-devel] [PULL 23/38] net: add trace_vhost_user_event, Michael S. Tsirkin, 2015/10/21
- [Qemu-devel] [PULL 24/38] vhost user: add support of live migration, Michael S. Tsirkin, 2015/10/21
- [Qemu-devel] [PULL 25/38] vhost user: add rarp sending after live migration for legacy guest, Michael S. Tsirkin, 2015/10/21