summary refs log tree commit diff stats
path: root/hw/scsi/vhost-user-scsi.c
diff options
context:
space:
mode:
authorLi Feng <fengli@smartx.com>2023-11-23 13:54:11 +0800
committerMichael S. Tsirkin <mst@redhat.com>2023-12-02 15:56:49 -0500
commit298d4f892e745cfb8a33b5ed2feaaab271f6e50c (patch)
tree751f4bff111a6cc8223ddd64f9d2e87dbe74baac /hw/scsi/vhost-user-scsi.c
parent2d37fe9e5e61b04bddbed00dbb7436e61a01c115 (diff)
downloadfocaccia-qemu-298d4f892e745cfb8a33b5ed2feaaab271f6e50c.tar.gz
focaccia-qemu-298d4f892e745cfb8a33b5ed2feaaab271f6e50c.zip
vhost-user: fix the reconnect error
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>
Diffstat (limited to 'hw/scsi/vhost-user-scsi.c')
-rw-r--r--hw/scsi/vhost-user-scsi.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/hw/scsi/vhost-user-scsi.c b/hw/scsi/vhost-user-scsi.c
index 4486500cac..2060f9f94b 100644
--- a/hw/scsi/vhost-user-scsi.c
+++ b/hw/scsi/vhost-user-scsi.c
@@ -147,7 +147,6 @@ static int vhost_user_scsi_connect(DeviceState *dev, Error **errp)
     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;
@@ -161,6 +160,8 @@ static int vhost_user_scsi_connect(DeviceState *dev, Error **errp)
         return ret;
     }
 
+    s->connected = true;
+
     /* restore vhost state */
     if (virtio_device_started(vdev, vdev->status)) {
         ret = vhost_user_scsi_start(s, errp);