[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v7 08/24] vhost-user: add vhost_user_requires_shm_lo
From: |
marcandre . lureau |
Subject: |
[Qemu-devel] [PATCH v7 08/24] vhost-user: add vhost_user_requires_shm_log() |
Date: |
Thu, 1 Oct 2015 19:23:52 +0200 |
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>
---
hw/virtio/vhost-user.c | 14 ++++++++++++--
include/hw/virtio/vhost-backend.h | 4 ++++
2 files changed, 16 insertions(+), 2 deletions(-)
diff --git a/hw/virtio/vhost-user.c b/hw/virtio/vhost-user.c
index fd4fcbf..01e51a0 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,
@@ -453,6 +454,14 @@ static int vhost_user_get_vq_index(struct vhost_dev *dev,
int idx)
return idx;
}
+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,
@@ -462,4 +471,5 @@ const VhostOps user_ops = {
.vhost_backend_set_vring_enable = vhost_user_set_vring_enable,
.vhost_set_log_base = vhost_set_log_base,
+ .vhost_requires_shm_log = vhost_user_requires_shm_log,
};
diff --git a/include/hw/virtio/vhost-backend.h
b/include/hw/virtio/vhost-backend.h
index c6b688a..649766a 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,
@@ -28,6 +30,7 @@ typedef int (*vhost_backend_get_vq_index)(struct vhost_dev
*dev, int idx);
typedef int (*vhost_backend_set_vring_enable)(struct vhost_dev *dev, int
enable);
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_set_log_base_op vhost_set_log_base;
+ vhost_requires_shm_log_op vhost_requires_shm_log;
} VhostOps;
extern const VhostOps user_ops;
--
2.4.3
- Re: [Qemu-devel] [PATCH v7 03/24] util: add linux-only memfd fallback, (continued)
- [Qemu-devel] [PATCH v7 02/24] linux-headers: add unistd.h, marcandre . lureau, 2015/10/08
- [Qemu-devel] [PATCH v7 21/24] vhost-user-test: wrap server in TestServer struct, marcandre . lureau, 2015/10/08
- [Qemu-devel] [PATCH v7 22/24] vhost-user-test: learn to tweak various qemu arguments, marcandre . lureau, 2015/10/08
- [Qemu-devel] [PATCH v7 19/24] vhost-user-test: move wait_for_fds() out, marcandre . lureau, 2015/10/08
- [Qemu-devel] [PATCH v7 09/24] vhost: alloc shareable log, marcandre . lureau, 2015/10/08
- [Qemu-devel] [PATCH v7 14/24] net: add trace_vhost_user_event, marcandre . lureau, 2015/10/08
- [Qemu-devel] [PATCH v7 23/24] vhost-user-test: add live-migration test, marcandre . lureau, 2015/10/08
- [Qemu-devel] [PATCH v7 05/24] util: add fallback for qemu_memfd_alloc(), marcandre . lureau, 2015/10/08
- [Qemu-devel] [PATCH v7 06/24] vhost: document log resizing, marcandre . lureau, 2015/10/08
- [Qemu-devel] [PATCH v7 08/24] vhost-user: add vhost_user_requires_shm_log(),
marcandre . lureau <=
- [Qemu-devel] [PATCH v7 11/24] vhost-user: add a migration blocker, marcandre . lureau, 2015/10/08
- [Qemu-devel] [PATCH v7 10/24] vhost-user: send log shm fd along with log_base, marcandre . lureau, 2015/10/08
- [Qemu-devel] [PATCH v7 13/24] vhost-user: document migration log, marcandre . lureau, 2015/10/08
- [Qemu-devel] [PATCH v7 12/24] vhost: use a function for each call, marcandre . lureau, 2015/10/08
[Qemu-devel] [PATCH v7 15/24] vhost user: add support of live migration, marcandre . lureau, 2015/10/08
[Qemu-devel] [PATCH v7 18/24] vhost: add migration block if memfd failed, marcandre . lureau, 2015/10/08