[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v5 07/21] vhost: add vhost_set_log_base op
From: |
marcandre . lureau |
Subject: |
[Qemu-devel] [PATCH v5 07/21] vhost: add vhost_set_log_base op |
Date: |
Thu, 24 Sep 2015 18:22:07 +0200 |
From: Marc-André Lureau <address@hidden>
Split VHOST_SET_LOG_BASE call in a seperate function callback, so that
type safety works and more arguments can be added in the next patches.
Signed-off-by: Marc-André Lureau <address@hidden>
---
hw/virtio/vhost-backend.c | 8 ++++++++
hw/virtio/vhost-user.c | 17 ++++++++++++++++-
hw/virtio/vhost.c | 6 +++---
include/hw/virtio/vhost-backend.h | 5 +++++
4 files changed, 32 insertions(+), 4 deletions(-)
diff --git a/hw/virtio/vhost-backend.c b/hw/virtio/vhost-backend.c
index 72d1392..88d33fd 100644
--- a/hw/virtio/vhost-backend.c
+++ b/hw/virtio/vhost-backend.c
@@ -11,6 +11,7 @@
#include "hw/virtio/vhost.h"
#include "hw/virtio/vhost-backend.h"
#include "qemu/error-report.h"
+#include "linux/vhost.h"
#include <sys/ioctl.h>
@@ -49,12 +50,19 @@ static int vhost_kernel_get_vq_index(struct vhost_dev *dev,
int idx)
return idx - dev->vq_index;
}
+static int vhost_set_log_base(struct vhost_dev *dev, uint64_t base)
+{
+ return vhost_kernel_call(dev, VHOST_SET_LOG_BASE, &base);
+}
+
static const VhostOps kernel_ops = {
.backend_type = VHOST_BACKEND_TYPE_KERNEL,
.vhost_call = vhost_kernel_call,
.vhost_backend_init = vhost_kernel_init,
.vhost_backend_cleanup = vhost_kernel_cleanup,
.vhost_backend_get_vq_index = vhost_kernel_get_vq_index,
+
+ .vhost_set_log_base = vhost_set_log_base,
};
int vhost_set_backend_type(struct vhost_dev *dev, VhostBackendType
backend_type)
diff --git a/hw/virtio/vhost-user.c b/hw/virtio/vhost-user.c
index b11c0d2..fd4fcbf 100644
--- a/hw/virtio/vhost-user.c
+++ b/hw/virtio/vhost-user.c
@@ -242,7 +242,6 @@ static int vhost_user_call(struct vhost_dev *dev, unsigned
long int request,
break;
case VHOST_USER_SET_FEATURES:
- case VHOST_USER_SET_LOG_BASE:
case VHOST_USER_SET_PROTOCOL_FEATURES:
msg.u64 = *((__u64 *) arg);
msg.size = sizeof(m.u64);
@@ -367,6 +366,20 @@ static int vhost_user_call(struct vhost_dev *dev, unsigned
long int request,
return 0;
}
+static int vhost_set_log_base(struct vhost_dev *dev, uint64_t base)
+{
+ VhostUserMsg msg = {
+ .request = VHOST_USER_SET_LOG_BASE,
+ .flags = VHOST_USER_VERSION,
+ .u64 = base,
+ .size = sizeof(m.u64),
+ };
+
+ vhost_user_write(dev, &msg, NULL, 0);
+
+ return 0;
+}
+
static int vhost_user_init(struct vhost_dev *dev, void *opaque)
{
unsigned long long features;
@@ -447,4 +460,6 @@ const VhostOps user_ops = {
.vhost_backend_cleanup = vhost_user_cleanup,
.vhost_backend_get_vq_index = vhost_user_get_vq_index,
.vhost_backend_set_vring_enable = vhost_user_set_vring_enable,
+
+ .vhost_set_log_base = vhost_set_log_base,
};
diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c
index 7bc3862..7f01cd6 100644
--- a/hw/virtio/vhost.c
+++ b/hw/virtio/vhost.c
@@ -366,7 +366,7 @@ static inline void vhost_dev_log_resize(struct vhost_dev*
dev, uint64_t size)
/* inform backend of log switching, this must be done before
releasing the current log, to ensure no logging is lost */
- r = dev->vhost_ops->vhost_call(dev, VHOST_SET_LOG_BASE, &log_base);
+ r = dev->vhost_ops->vhost_set_log_base(dev, log_base);
assert(r >= 0);
vhost_log_put(dev, true);
dev->log = log;
@@ -1171,8 +1171,8 @@ int vhost_dev_start(struct vhost_dev *hdev, VirtIODevice
*vdev)
hdev->log_size = vhost_get_log_size(hdev);
hdev->log = vhost_log_get(hdev->log_size, share);
log_base = (uintptr_t)hdev->log->log;
- r = hdev->vhost_ops->vhost_call(hdev, VHOST_SET_LOG_BASE,
- hdev->log_size ? &log_base : NULL);
+ r = hdev->vhost_ops->vhost_set_log_base(hdev,
+ hdev->log_size ? log_base : 0);
if (r < 0) {
r = -errno;
goto fail_log;
diff --git a/include/hw/virtio/vhost-backend.h
b/include/hw/virtio/vhost-backend.h
index 3a0f6e2..c6b688a 100644
--- a/include/hw/virtio/vhost-backend.h
+++ b/include/hw/virtio/vhost-backend.h
@@ -27,13 +27,18 @@ typedef int (*vhost_backend_cleanup)(struct vhost_dev *dev);
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 struct VhostOps {
VhostBackendType backend_type;
vhost_call vhost_call;
+
vhost_backend_init vhost_backend_init;
vhost_backend_cleanup vhost_backend_cleanup;
vhost_backend_get_vq_index vhost_backend_get_vq_index;
vhost_backend_set_vring_enable vhost_backend_set_vring_enable;
+
+ vhost_set_log_base_op vhost_set_log_base;
} VhostOps;
extern const VhostOps user_ops;
--
2.4.3
- [Qemu-devel] [PATCH v5 00/21] vhost-user: add migration support, marcandre . lureau, 2015/09/24
- [Qemu-devel] [PATCH v5 01/21] vhost-user: unit test for new messages, marcandre . lureau, 2015/09/24
- [Qemu-devel] [PATCH v5 02/21] configure: probe for memfd, marcandre . lureau, 2015/09/24
- [Qemu-devel] [PATCH v5 03/21] util: add linux-only memfd fallback, marcandre . lureau, 2015/09/24
- [Qemu-devel] [PATCH v5 04/21] util: add memfd helpers, marcandre . lureau, 2015/09/24
- [Qemu-devel] [PATCH v5 05/21] vhost: alloc shareable log, marcandre . lureau, 2015/09/24
- [Qemu-devel] [PATCH v5 06/21] vhost: document log resizing, marcandre . lureau, 2015/09/24
- [Qemu-devel] [PATCH v5 07/21] vhost: add vhost_set_log_base op,
marcandre . lureau <=
- [Qemu-devel] [PATCH v5 09/21] vhost-user: add a migration blocker, marcandre . lureau, 2015/09/24
- [Qemu-devel] [PATCH v5 08/21] vhost-user: send log shm fd along with log_base, marcandre . lureau, 2015/09/24
- [Qemu-devel] [PATCH v5 11/21] vhost: only use shared log if in use by backend, marcandre . lureau, 2015/09/24
- [Qemu-devel] [PATCH v5 12/21] vhost-user: document migration log, marcandre . lureau, 2015/09/24
- [Qemu-devel] [PATCH v5 13/21] net: add trace_vhost_user_event, marcandre . lureau, 2015/09/24
- [Qemu-devel] [PATCH v5 10/21] vhost: use a function for each call, marcandre . lureau, 2015/09/24
- [Qemu-devel] [PATCH v5 14/21] vhost user: add support of live migration, marcandre . lureau, 2015/09/24