qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Michael S. Tsirkin" <mst@redhat.com>
To: qemu-devel@nongnu.org
Cc: "Peter Maydell" <peter.maydell@linaro.org>,
	"Li Feng" <fengli@smartx.com>,
	"Raphael Norwitz" <raphael.norwitz@nutanix.com>,
	"Kevin Wolf" <kwolf@redhat.com>,
	"Hanna Reitz" <hreitz@redhat.com>,
	"Paolo Bonzini" <pbonzini@redhat.com>,
	"Fam Zheng" <fam@euphon.net>,
	"Alex Bennée" <alex.bennee@linaro.org>,
	"Viresh Kumar" <viresh.kumar@linaro.org>,
	qemu-block@nongnu.org
Subject: [PULL 14/15] vhost-user: fix the reconnect error
Date: Fri, 1 Dec 2023 12:15:43 -0500	[thread overview]
Message-ID: <cf1afed5e60ac560b093722fdc94fa08de22dc28.1701450838.git.mst@redhat.com> (raw)
In-Reply-To: <cover.1701450838.git.mst@redhat.com>

From: Li Feng <fengli@smartx.com>

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>
---
 hw/block/vhost-user-blk.c   | 8 +++-----
 hw/scsi/vhost-user-scsi.c   | 3 ++-
 hw/virtio/vhost-user-gpio.c | 3 ++-
 3 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/hw/block/vhost-user-blk.c b/hw/block/vhost-user-blk.c
index 818b833108..2863d80d15 100644
--- a/hw/block/vhost-user-blk.c
+++ b/hw/block/vhost-user-blk.c
@@ -326,7 +326,6 @@ static int vhost_user_blk_connect(DeviceState *dev, Error **errp)
     if (s->connected) {
         return 0;
     }
-    s->connected = true;
 
     s->dev.num_queues = s->num_queues;
     s->dev.nvqs = s->num_queues;
@@ -343,15 +342,14 @@ static int vhost_user_blk_connect(DeviceState *dev, Error **errp)
         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)
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);
diff --git a/hw/virtio/vhost-user-gpio.c b/hw/virtio/vhost-user-gpio.c
index aff2d7eff6..a83437a5da 100644
--- a/hw/virtio/vhost-user-gpio.c
+++ b/hw/virtio/vhost-user-gpio.c
@@ -229,7 +229,6 @@ static int vu_gpio_connect(DeviceState *dev, Error **errp)
     if (gpio->connected) {
         return 0;
     }
-    gpio->connected = true;
 
     vhost_dev_set_config_notifier(vhost_dev, &gpio_ops);
     gpio->vhost_user.supports_config = true;
@@ -243,6 +242,8 @@ static int vu_gpio_connect(DeviceState *dev, Error **errp)
         return ret;
     }
 
+    gpio->connected = true;
+
     /* restore vhost state */
     if (virtio_device_started(vdev, vdev->status)) {
         vu_gpio_start(vdev);
-- 
MST



  parent reply	other threads:[~2023-12-01 17:18 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-12-01 17:15 [PULL 00/15] virtio,pc,pci: fixes Michael S. Tsirkin
2023-12-01 17:15 ` [PULL 01/15] osdep: add getloadavg Michael S. Tsirkin
2023-12-01 17:15 ` [PULL 02/15] netdev: set timeout depending on loadavg Michael S. Tsirkin
2023-12-01 17:15 ` [PULL 03/15] tests/acpi/bios-tables-test: do not write new blobs unless there are changes Michael S. Tsirkin
2023-12-01 17:27   ` Ani Sinha
2023-12-02 20:59     ` Michael S. Tsirkin
2024-01-24  8:58   ` Igor Mammedov
2024-01-24  9:47     ` Ani Sinha
2023-12-01 17:15 ` [PULL 04/15] hw/audio/virtio-snd-pci: fix the PCI class code Michael S. Tsirkin
2023-12-01 17:15 ` [PULL 05/15] hw/audio/hda-codec: fix multiplication overflow Michael S. Tsirkin
2023-12-01 17:15 ` [PULL 06/15] hw/audio/hda-codec: reenable the audio mixer Michael S. Tsirkin
2023-12-01 17:15 ` [PULL 07/15] virtio-snd: check AUD_register_card return value Michael S. Tsirkin
2023-12-01 17:15 ` [PULL 08/15] virtio-sound: add realize() error cleanup path Michael S. Tsirkin
2023-12-01 17:15 ` [PULL 09/15] pcie_sriov: Remove g_new assertion Michael S. Tsirkin
2023-12-01 17:15 ` [PULL 10/15] hw/acpi/erst: Do not ignore Error* in realize handler Michael S. Tsirkin
2023-12-01 17:15 ` [PULL 11/15] hw/i386: fix short-circuit logic with non-optimizing builds Michael S. Tsirkin
2023-12-01 17:15 ` [PULL 12/15] virtio-iommu: Remove useless !sdev check in virtio_iommu_probe() Michael S. Tsirkin
2023-12-01 17:15 ` [PULL 13/15] msix: unset PCIDevice::msix_vector_poll_notifier in rollback Michael S. Tsirkin
2023-12-01 17:15 ` Michael S. Tsirkin [this message]
2023-12-01 17:15 ` [PULL 15/15] vhost-user-scsi: free the inflight area when reset Michael S. Tsirkin
2023-12-02 20:58 ` [PULL 00/15] virtio,pc,pci: fixes Michael S. Tsirkin
2023-12-04 14:45 ` Stefan Hajnoczi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=cf1afed5e60ac560b093722fdc94fa08de22dc28.1701450838.git.mst@redhat.com \
    --to=mst@redhat.com \
    --cc=alex.bennee@linaro.org \
    --cc=fam@euphon.net \
    --cc=fengli@smartx.com \
    --cc=hreitz@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=raphael.norwitz@nutanix.com \
    --cc=viresh.kumar@linaro.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).