vhost: add vhost_set_log_base op
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 <marcandre.lureau@redhat.com> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com> Tested-by: Thibaut Collet <thibaut.collet@6wind.com>
This commit is contained in:
parent
636f4dddfe
commit
c2bea314f6
@ -67,6 +67,11 @@ static int vhost_kernel_memslots_limit(struct vhost_dev *dev)
|
|||||||
return limit;
|
return limit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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 = {
|
static const VhostOps kernel_ops = {
|
||||||
.backend_type = VHOST_BACKEND_TYPE_KERNEL,
|
.backend_type = VHOST_BACKEND_TYPE_KERNEL,
|
||||||
.vhost_call = vhost_kernel_call,
|
.vhost_call = vhost_kernel_call,
|
||||||
@ -74,6 +79,7 @@ static const VhostOps kernel_ops = {
|
|||||||
.vhost_backend_cleanup = vhost_kernel_cleanup,
|
.vhost_backend_cleanup = vhost_kernel_cleanup,
|
||||||
.vhost_backend_get_vq_index = vhost_kernel_get_vq_index,
|
.vhost_backend_get_vq_index = vhost_kernel_get_vq_index,
|
||||||
.vhost_backend_memslots_limit = vhost_kernel_memslots_limit,
|
.vhost_backend_memslots_limit = vhost_kernel_memslots_limit,
|
||||||
|
.vhost_set_log_base = vhost_set_log_base,
|
||||||
};
|
};
|
||||||
|
|
||||||
int vhost_set_backend_type(struct vhost_dev *dev, VhostBackendType backend_type)
|
int vhost_set_backend_type(struct vhost_dev *dev, VhostBackendType backend_type)
|
||||||
|
@ -242,7 +242,6 @@ static int vhost_user_call(struct vhost_dev *dev, unsigned long int request,
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case VHOST_USER_SET_FEATURES:
|
case VHOST_USER_SET_FEATURES:
|
||||||
case VHOST_USER_SET_LOG_BASE:
|
|
||||||
case VHOST_USER_SET_PROTOCOL_FEATURES:
|
case VHOST_USER_SET_PROTOCOL_FEATURES:
|
||||||
msg.u64 = *((__u64 *) arg);
|
msg.u64 = *((__u64 *) arg);
|
||||||
msg.size = sizeof(m.u64);
|
msg.size = sizeof(m.u64);
|
||||||
@ -367,6 +366,20 @@ static int vhost_user_call(struct vhost_dev *dev, unsigned long int request,
|
|||||||
return 0;
|
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)
|
static int vhost_user_init(struct vhost_dev *dev, void *opaque)
|
||||||
{
|
{
|
||||||
unsigned long long features;
|
unsigned long long features;
|
||||||
@ -453,4 +466,5 @@ const VhostOps user_ops = {
|
|||||||
.vhost_backend_get_vq_index = vhost_user_get_vq_index,
|
.vhost_backend_get_vq_index = vhost_user_get_vq_index,
|
||||||
.vhost_backend_set_vring_enable = vhost_user_set_vring_enable,
|
.vhost_backend_set_vring_enable = vhost_user_set_vring_enable,
|
||||||
.vhost_backend_memslots_limit = vhost_user_memslots_limit,
|
.vhost_backend_memslots_limit = vhost_user_memslots_limit,
|
||||||
|
.vhost_set_log_base = vhost_set_log_base,
|
||||||
};
|
};
|
||||||
|
@ -352,7 +352,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
|
/* inform backend of log switching, this must be done before
|
||||||
releasing the current log, to ensure no logging is lost */
|
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);
|
assert(r >= 0);
|
||||||
vhost_log_put(dev, true);
|
vhost_log_put(dev, true);
|
||||||
dev->log = log;
|
dev->log = log;
|
||||||
@ -1167,8 +1167,8 @@ int vhost_dev_start(struct vhost_dev *hdev, VirtIODevice *vdev)
|
|||||||
hdev->log_size = vhost_get_log_size(hdev);
|
hdev->log_size = vhost_get_log_size(hdev);
|
||||||
hdev->log = vhost_log_get(hdev->log_size);
|
hdev->log = vhost_log_get(hdev->log_size);
|
||||||
log_base = (uintptr_t)hdev->log->log;
|
log_base = (uintptr_t)hdev->log->log;
|
||||||
r = hdev->vhost_ops->vhost_call(hdev, VHOST_SET_LOG_BASE,
|
r = hdev->vhost_ops->vhost_set_log_base(hdev,
|
||||||
hdev->log_size ? &log_base : NULL);
|
hdev->log_size ? log_base : 0);
|
||||||
if (r < 0) {
|
if (r < 0) {
|
||||||
r = -errno;
|
r = -errno;
|
||||||
goto fail_log;
|
goto fail_log;
|
||||||
|
@ -28,6 +28,8 @@ 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_backend_set_vring_enable)(struct vhost_dev *dev, int enable);
|
||||||
typedef int (*vhost_backend_memslots_limit)(struct vhost_dev *dev);
|
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 struct VhostOps {
|
typedef struct VhostOps {
|
||||||
VhostBackendType backend_type;
|
VhostBackendType backend_type;
|
||||||
vhost_call vhost_call;
|
vhost_call vhost_call;
|
||||||
@ -36,6 +38,7 @@ typedef struct VhostOps {
|
|||||||
vhost_backend_get_vq_index vhost_backend_get_vq_index;
|
vhost_backend_get_vq_index vhost_backend_get_vq_index;
|
||||||
vhost_backend_set_vring_enable vhost_backend_set_vring_enable;
|
vhost_backend_set_vring_enable vhost_backend_set_vring_enable;
|
||||||
vhost_backend_memslots_limit vhost_backend_memslots_limit;
|
vhost_backend_memslots_limit vhost_backend_memslots_limit;
|
||||||
|
vhost_set_log_base_op vhost_set_log_base;
|
||||||
} VhostOps;
|
} VhostOps;
|
||||||
|
|
||||||
extern const VhostOps user_ops;
|
extern const VhostOps user_ops;
|
||||||
|
Loading…
Reference in New Issue
Block a user