|
@@ -253,7 +253,6 @@ static void vhost_user_blk_device_realize(DeviceState *dev, Error **errp)
|
|
{
|
|
{
|
|
VirtIODevice *vdev = VIRTIO_DEVICE(dev);
|
|
VirtIODevice *vdev = VIRTIO_DEVICE(dev);
|
|
VHostUserBlk *s = VHOST_USER_BLK(vdev);
|
|
VHostUserBlk *s = VHOST_USER_BLK(vdev);
|
|
- VhostUserState *user;
|
|
|
|
struct vhost_virtqueue *vqs = NULL;
|
|
struct vhost_virtqueue *vqs = NULL;
|
|
int i, ret;
|
|
int i, ret;
|
|
|
|
|
|
@@ -272,15 +271,10 @@ static void vhost_user_blk_device_realize(DeviceState *dev, Error **errp)
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
|
|
|
|
- user = vhost_user_init();
|
|
|
|
- if (!user) {
|
|
|
|
- error_setg(errp, "vhost-user-blk: failed to init vhost_user");
|
|
|
|
|
|
+ if (!vhost_user_init(&s->vhost_user, &s->chardev, errp)) {
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
|
|
|
|
- user->chr = &s->chardev;
|
|
|
|
- s->vhost_user = user;
|
|
|
|
-
|
|
|
|
virtio_init(vdev, "virtio-blk", VIRTIO_ID_BLOCK,
|
|
virtio_init(vdev, "virtio-blk", VIRTIO_ID_BLOCK,
|
|
sizeof(struct virtio_blk_config));
|
|
sizeof(struct virtio_blk_config));
|
|
|
|
|
|
@@ -297,7 +291,7 @@ static void vhost_user_blk_device_realize(DeviceState *dev, Error **errp)
|
|
|
|
|
|
vhost_dev_set_config_notifier(&s->dev, &blk_ops);
|
|
vhost_dev_set_config_notifier(&s->dev, &blk_ops);
|
|
|
|
|
|
- ret = vhost_dev_init(&s->dev, s->vhost_user, VHOST_BACKEND_TYPE_USER, 0);
|
|
|
|
|
|
+ ret = vhost_dev_init(&s->dev, &s->vhost_user, VHOST_BACKEND_TYPE_USER, 0);
|
|
if (ret < 0) {
|
|
if (ret < 0) {
|
|
error_setg(errp, "vhost-user-blk: vhost initialization failed: %s",
|
|
error_setg(errp, "vhost-user-blk: vhost initialization failed: %s",
|
|
strerror(-ret));
|
|
strerror(-ret));
|
|
@@ -322,10 +316,7 @@ vhost_err:
|
|
virtio_err:
|
|
virtio_err:
|
|
g_free(vqs);
|
|
g_free(vqs);
|
|
virtio_cleanup(vdev);
|
|
virtio_cleanup(vdev);
|
|
-
|
|
|
|
- vhost_user_cleanup(user);
|
|
|
|
- g_free(user);
|
|
|
|
- s->vhost_user = NULL;
|
|
|
|
|
|
+ vhost_user_cleanup(&s->vhost_user);
|
|
}
|
|
}
|
|
|
|
|
|
static void vhost_user_blk_device_unrealize(DeviceState *dev, Error **errp)
|
|
static void vhost_user_blk_device_unrealize(DeviceState *dev, Error **errp)
|
|
@@ -338,12 +329,7 @@ static void vhost_user_blk_device_unrealize(DeviceState *dev, Error **errp)
|
|
vhost_dev_cleanup(&s->dev);
|
|
vhost_dev_cleanup(&s->dev);
|
|
g_free(vqs);
|
|
g_free(vqs);
|
|
virtio_cleanup(vdev);
|
|
virtio_cleanup(vdev);
|
|
-
|
|
|
|
- if (s->vhost_user) {
|
|
|
|
- vhost_user_cleanup(s->vhost_user);
|
|
|
|
- g_free(s->vhost_user);
|
|
|
|
- s->vhost_user = NULL;
|
|
|
|
- }
|
|
|
|
|
|
+ vhost_user_cleanup(&s->vhost_user);
|
|
}
|
|
}
|
|
|
|
|
|
static void vhost_user_blk_instance_init(Object *obj)
|
|
static void vhost_user_blk_instance_init(Object *obj)
|