@@ -25,15 +25,6 @@ static int vhost_kernel_call(struct vhost_dev *dev, unsigned long int request,
return ioctl(fd, request, arg);
}
-static int vhost_kernel_init(struct vhost_dev *dev, void *opaque)
-{
- assert(dev->vhost_ops->backend_type == VHOST_BACKEND_TYPE_KERNEL);
-
- dev->opaque = opaque;
-
- return 0;
-}
-
static int vhost_kernel_cleanup(struct vhost_dev *dev)
{
int fd = (uintptr_t) dev->opaque;
@@ -172,6 +163,24 @@ static int vhost_kernel_get_vq_index(struct vhost_dev *dev, int idx)
return idx - dev->vq_index;
}
+static int vhost_kernel_init(struct vhost_dev *dev, void *opaque)
+{
+ uint64_t features;
+ int r;
+
+ assert(dev->vhost_ops->backend_type == VHOST_BACKEND_TYPE_KERNEL);
+
+ dev->opaque = opaque;
+
+ r = vhost_kernel_get_features(dev, &features);
+ if (r < 0) {
+ return r;
+ }
+ dev->features = features;
+
+ return 0;
+}
+
static const VhostOps kernel_ops = {
.backend_type = VHOST_BACKEND_TYPE_KERNEL,
.vhost_backend_init = vhost_kernel_init,
@@ -578,6 +578,7 @@ static int vhost_user_init(struct vhost_dev *dev, void *opaque)
if (err < 0) {
return err;
}
+ dev->features = features;
if (virtio_has_feature(features, VHOST_USER_F_PROTOCOL_FEATURES)) {
dev->backend_features |= 1ULL << VHOST_USER_F_PROTOCOL_FEATURES;
@@ -1037,7 +1037,6 @@ static void vhost_virtqueue_cleanup(struct vhost_virtqueue *vq)
int vhost_dev_init(struct vhost_dev *hdev, void *opaque,
VhostBackendType backend_type, uint32_t busyloop_timeout)
{
- uint64_t features;
int i, r, n_initialized_vqs = 0;
hdev->migration_blocker = NULL;
@@ -1063,12 +1062,6 @@ int vhost_dev_init(struct vhost_dev *hdev, void *opaque,
goto fail;
}
- r = hdev->vhost_ops->vhost_get_features(hdev, &features);
- if (r < 0) {
- VHOST_OPS_DEBUG("vhost_get_features failed");
- goto fail;
- }
-
for (i = 0; i < hdev->nvqs; ++i, ++n_initialized_vqs) {
r = vhost_virtqueue_init(hdev, hdev->vqs + i, hdev->vq_index + i);
if (r < 0) {
@@ -1086,8 +1079,6 @@ int vhost_dev_init(struct vhost_dev *hdev, void *opaque,
}
}
- hdev->features = features;
-
hdev->memory_listener = (MemoryListener) {
.begin = vhost_begin,
.commit = vhost_commit,