From 298d4f892e745cfb8a33b5ed2feaaab271f6e50c Mon Sep 17 00:00:00 2001 From: Li Feng Date: Thu, 23 Nov 2023 13:54:11 +0800 Subject: 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 Message-Id: <20231123055431.217792-2-fengli@smartx.com> Reviewed-by: Raphael Norwitz Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/virtio/vhost-user-gpio.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'hw/virtio/vhost-user-gpio.c') diff --git a/hw/virtio/vhost-user-gpio.c b/hw/virtio/vhost-user-gpio.c index aff2d7e..a83437a 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); -- cgit v1.1