mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-09-09 08:17:53 -06:00
hw/virtio: move vhost_set_backend_type() to vhost.c
Just a small refactor patch. vhost_set_backend_type() gets called only in vhost.c, so we can move the function there and make it static. We can then extern the visibility of kernel_ops, to match the other VhostOps in vhost-backend.h. The VhostOps constants now make more sense in vhost.h Suggested-by: Raphael Norwitz <raphael.norwitz@nutanix.com> Signed-off-by: Tiberiu Georgescu <tiberiu.georgescu@nutanix.com> Message-Id: <20210809134015.67941-1-tiberiu.georgescu@nutanix.com> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
This commit is contained in:
parent
fe8adae345
commit
9b1d929adb
4 changed files with 34 additions and 35 deletions
|
@ -293,7 +293,7 @@ static void vhost_kernel_set_iotlb_callback(struct vhost_dev *dev,
|
||||||
qemu_set_fd_handler((uintptr_t)dev->opaque, NULL, NULL, NULL);
|
qemu_set_fd_handler((uintptr_t)dev->opaque, NULL, NULL, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
static const VhostOps kernel_ops = {
|
const VhostOps kernel_ops = {
|
||||||
.backend_type = VHOST_BACKEND_TYPE_KERNEL,
|
.backend_type = VHOST_BACKEND_TYPE_KERNEL,
|
||||||
.vhost_backend_init = vhost_kernel_init,
|
.vhost_backend_init = vhost_kernel_init,
|
||||||
.vhost_backend_cleanup = vhost_kernel_cleanup,
|
.vhost_backend_cleanup = vhost_kernel_cleanup,
|
||||||
|
@ -328,34 +328,6 @@ static const VhostOps kernel_ops = {
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int vhost_set_backend_type(struct vhost_dev *dev, VhostBackendType backend_type)
|
|
||||||
{
|
|
||||||
int r = 0;
|
|
||||||
|
|
||||||
switch (backend_type) {
|
|
||||||
#ifdef CONFIG_VHOST_KERNEL
|
|
||||||
case VHOST_BACKEND_TYPE_KERNEL:
|
|
||||||
dev->vhost_ops = &kernel_ops;
|
|
||||||
break;
|
|
||||||
#endif
|
|
||||||
#ifdef CONFIG_VHOST_USER
|
|
||||||
case VHOST_BACKEND_TYPE_USER:
|
|
||||||
dev->vhost_ops = &user_ops;
|
|
||||||
break;
|
|
||||||
#endif
|
|
||||||
#ifdef CONFIG_VHOST_VDPA
|
|
||||||
case VHOST_BACKEND_TYPE_VDPA:
|
|
||||||
dev->vhost_ops = &vdpa_ops;
|
|
||||||
break;
|
|
||||||
#endif
|
|
||||||
default:
|
|
||||||
error_report("Unknown vhost backend type");
|
|
||||||
r = -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return r;
|
|
||||||
}
|
|
||||||
|
|
||||||
int vhost_backend_update_device_iotlb(struct vhost_dev *dev,
|
int vhost_backend_update_device_iotlb(struct vhost_dev *dev,
|
||||||
uint64_t iova, uint64_t uaddr,
|
uint64_t iova, uint64_t uaddr,
|
||||||
uint64_t len,
|
uint64_t len,
|
||||||
|
|
|
@ -174,6 +174,35 @@ static uint64_t vhost_get_log_size(struct vhost_dev *dev)
|
||||||
return log_size;
|
return log_size;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int vhost_set_backend_type(struct vhost_dev *dev,
|
||||||
|
VhostBackendType backend_type)
|
||||||
|
{
|
||||||
|
int r = 0;
|
||||||
|
|
||||||
|
switch (backend_type) {
|
||||||
|
#ifdef CONFIG_VHOST_KERNEL
|
||||||
|
case VHOST_BACKEND_TYPE_KERNEL:
|
||||||
|
dev->vhost_ops = &kernel_ops;
|
||||||
|
break;
|
||||||
|
#endif
|
||||||
|
#ifdef CONFIG_VHOST_USER
|
||||||
|
case VHOST_BACKEND_TYPE_USER:
|
||||||
|
dev->vhost_ops = &user_ops;
|
||||||
|
break;
|
||||||
|
#endif
|
||||||
|
#ifdef CONFIG_VHOST_VDPA
|
||||||
|
case VHOST_BACKEND_TYPE_VDPA:
|
||||||
|
dev->vhost_ops = &vdpa_ops;
|
||||||
|
break;
|
||||||
|
#endif
|
||||||
|
default:
|
||||||
|
error_report("Unknown vhost backend type");
|
||||||
|
r = -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
|
||||||
static struct vhost_log *vhost_log_alloc(uint64_t size, bool share)
|
static struct vhost_log *vhost_log_alloc(uint64_t size, bool share)
|
||||||
{
|
{
|
||||||
Error *err = NULL;
|
Error *err = NULL;
|
||||||
|
|
|
@ -173,12 +173,6 @@ typedef struct VhostOps {
|
||||||
vhost_force_iommu_op vhost_force_iommu;
|
vhost_force_iommu_op vhost_force_iommu;
|
||||||
} VhostOps;
|
} VhostOps;
|
||||||
|
|
||||||
extern const VhostOps user_ops;
|
|
||||||
extern const VhostOps vdpa_ops;
|
|
||||||
|
|
||||||
int vhost_set_backend_type(struct vhost_dev *dev,
|
|
||||||
VhostBackendType backend_type);
|
|
||||||
|
|
||||||
int vhost_backend_update_device_iotlb(struct vhost_dev *dev,
|
int vhost_backend_update_device_iotlb(struct vhost_dev *dev,
|
||||||
uint64_t iova, uint64_t uaddr,
|
uint64_t iova, uint64_t uaddr,
|
||||||
uint64_t len,
|
uint64_t len,
|
||||||
|
|
|
@ -95,6 +95,10 @@ struct vhost_dev {
|
||||||
const VhostDevConfigOps *config_ops;
|
const VhostDevConfigOps *config_ops;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
extern const VhostOps kernel_ops;
|
||||||
|
extern const VhostOps user_ops;
|
||||||
|
extern const VhostOps vdpa_ops;
|
||||||
|
|
||||||
struct vhost_net {
|
struct vhost_net {
|
||||||
struct vhost_dev dev;
|
struct vhost_dev dev;
|
||||||
struct vhost_virtqueue vqs[2];
|
struct vhost_virtqueue vqs[2];
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue