If the error occurs in vhost_dev_init, the value of s->connected is set to true
in advance, and there is no chance to enter this function execution again
in the future.
Signed-off-by: Li Feng <fengli@smartx.com>
Message-Id: <
20231123055431.217792-2-fengli@smartx.com>
Reviewed-by: Raphael Norwitz <raphael.norwitz@nutanix.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
if (s->connected) {
return 0;
}
- s->connected = true;
s->dev.num_queues = s->num_queues;
s->dev.nvqs = s->num_queues;
return ret;
}
+ s->connected = true;
+
/* restore vhost state */
if (virtio_device_started(vdev, vdev->status)) {
ret = vhost_user_blk_start(vdev, errp);
- if (ret < 0) {
- return ret;
- }
}
- return 0;
+ return ret;
}
static void vhost_user_blk_disconnect(DeviceState *dev)
if (s->connected) {
return 0;
}
- s->connected = true;
vsc->dev.num_queues = vs->conf.num_queues;
vsc->dev.nvqs = VIRTIO_SCSI_VQ_NUM_FIXED + vs->conf.num_queues;
return ret;
}
+ s->connected = true;
+
/* restore vhost state */
if (virtio_device_started(vdev, vdev->status)) {
ret = vhost_user_scsi_start(s, errp);
if (gpio->connected) {
return 0;
}
- gpio->connected = true;
vhost_dev_set_config_notifier(vhost_dev, &gpio_ops);
gpio->vhost_user.supports_config = true;
return ret;
}
+ gpio->connected = true;
+
/* restore vhost state */
if (virtio_device_started(vdev, vdev->status)) {
vu_gpio_start(vdev);