qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/2] fix some vhost-user issues
@ 2023-11-23  5:54 Li Feng
  2023-11-23  5:54 ` [PATCH 1/2] vhost-user: fix the reconnect error Li Feng
  2023-11-23  5:54 ` [PATCH 2/2] vhost-user-scsi: free the inflight area when reset Li Feng
  0 siblings, 2 replies; 5+ messages in thread
From: Li Feng @ 2023-11-23  5:54 UTC (permalink / raw)
  To: Raphael Norwitz, Michael S. Tsirkin, Kevin Wolf, Hanna Reitz,
	Paolo Bonzini, Fam Zheng, Alex Bennée, Viresh Kumar,
	open list:Block layer core, open list:All patches CC here
  Cc: Li Feng


Li Feng (2):
  vhost-user: fix the reconnect error
  vhost-user-scsi: free the inflight area when reset

 hw/block/vhost-user-blk.c   |  8 +++-----
 hw/scsi/vhost-user-scsi.c   | 19 ++++++++++++++++++-
 hw/virtio/vhost-user-gpio.c |  3 ++-
 hw/virtio/virtio.c          |  2 +-
 4 files changed, 24 insertions(+), 8 deletions(-)

-- 
2.42.0



^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH 1/2] vhost-user: fix the reconnect error
  2023-11-23  5:54 [PATCH 0/2] fix some vhost-user issues Li Feng
@ 2023-11-23  5:54 ` Li Feng
  2023-11-28  5:57   ` Raphael Norwitz
  2023-11-23  5:54 ` [PATCH 2/2] vhost-user-scsi: free the inflight area when reset Li Feng
  1 sibling, 1 reply; 5+ messages in thread
From: Li Feng @ 2023-11-23  5:54 UTC (permalink / raw)
  To: Raphael Norwitz, Michael S. Tsirkin, Kevin Wolf, Hanna Reitz,
	Paolo Bonzini, Fam Zheng, Alex Bennée, Viresh Kumar,
	open list:Block layer core, open list:All patches CC here
  Cc: Li Feng

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>
---
 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);
-- 
2.42.0



^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 2/2] vhost-user-scsi: free the inflight area when reset
  2023-11-23  5:54 [PATCH 0/2] fix some vhost-user issues Li Feng
  2023-11-23  5:54 ` [PATCH 1/2] vhost-user: fix the reconnect error Li Feng
@ 2023-11-23  5:54 ` Li Feng
  2023-11-28  5:57   ` Raphael Norwitz
  1 sibling, 1 reply; 5+ messages in thread
From: Li Feng @ 2023-11-23  5:54 UTC (permalink / raw)
  To: Raphael Norwitz, Michael S. Tsirkin, Kevin Wolf, Hanna Reitz,
	Paolo Bonzini, Fam Zheng, Alex Bennée, Viresh Kumar,
	open list:Block layer core, open list:All patches CC here
  Cc: Li Feng

Keep it the same to vhost-user-blk.
At the same time, fix the vhost_reset_device.

Signed-off-by: Li Feng <fengli@smartx.com>
---
 hw/scsi/vhost-user-scsi.c | 16 ++++++++++++++++
 hw/virtio/virtio.c        |  2 +-
 2 files changed, 17 insertions(+), 1 deletion(-)

diff --git a/hw/scsi/vhost-user-scsi.c b/hw/scsi/vhost-user-scsi.c
index 2060f9f94b..780f10559d 100644
--- a/hw/scsi/vhost-user-scsi.c
+++ b/hw/scsi/vhost-user-scsi.c
@@ -360,6 +360,20 @@ static Property vhost_user_scsi_properties[] = {
     DEFINE_PROP_END_OF_LIST(),
 };
 
+static void vhost_user_scsi_reset(VirtIODevice *vdev)
+{
+    VHostUserSCSI *s = VHOST_USER_SCSI(vdev);
+    VHostSCSICommon *vsc = VHOST_SCSI_COMMON(s);
+
+    vhost_dev_free_inflight(vsc->inflight);
+}
+
+static struct vhost_dev *vhost_user_scsi_get_vhost(VirtIODevice *vdev)
+{
+    VHostSCSICommon *vsc = VHOST_SCSI_COMMON(vdev);
+    return &vsc->dev;
+}
+
 static const VMStateDescription vmstate_vhost_scsi = {
     .name = "virtio-scsi",
     .minimum_version_id = 1,
@@ -385,6 +399,8 @@ static void vhost_user_scsi_class_init(ObjectClass *klass, void *data)
     vdc->set_config = vhost_scsi_common_set_config;
     vdc->set_status = vhost_user_scsi_set_status;
     fwc->get_dev_path = vhost_scsi_common_get_fw_dev_path;
+    vdc->reset = vhost_user_scsi_reset;
+    vdc->get_vhost = vhost_user_scsi_get_vhost;
 }
 
 static void vhost_user_scsi_instance_init(Object *obj)
diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c
index 4259fefeb6..d0a640af63 100644
--- a/hw/virtio/virtio.c
+++ b/hw/virtio/virtio.c
@@ -2137,7 +2137,7 @@ void virtio_reset(void *opaque)
         vdev->device_endian = virtio_default_endian();
     }
 
-    if (vdev->vhost_started) {
+    if (vdev->vhost_started && k->get_vhost) {
         vhost_reset_device(k->get_vhost(vdev));
     }
 
-- 
2.42.0



^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH 1/2] vhost-user: fix the reconnect error
  2023-11-23  5:54 ` [PATCH 1/2] vhost-user: fix the reconnect error Li Feng
@ 2023-11-28  5:57   ` Raphael Norwitz
  0 siblings, 0 replies; 5+ messages in thread
From: Raphael Norwitz @ 2023-11-28  5:57 UTC (permalink / raw)
  To: Li Feng
  Cc: Michael S. Tsirkin, Kevin Wolf, Hanna Reitz, Paolo Bonzini,
	Fam Zheng, Alex Bennée, Viresh Kumar,
	open list:Block layer core, open list:All patches CC here


> On Nov 23, 2023, at 12:54 AM, Li Feng <fengli@smartx.com> wrote:
> 
> 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>

Reviewed-by: Raphael Norwitz <raphael.norwitz@nutanix.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);
> -- 
> 2.42.0
> 



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 2/2] vhost-user-scsi: free the inflight area when reset
  2023-11-23  5:54 ` [PATCH 2/2] vhost-user-scsi: free the inflight area when reset Li Feng
@ 2023-11-28  5:57   ` Raphael Norwitz
  0 siblings, 0 replies; 5+ messages in thread
From: Raphael Norwitz @ 2023-11-28  5:57 UTC (permalink / raw)
  To: Li Feng
  Cc: Michael S. Tsirkin, Kevin Wolf, Hanna Reitz, Paolo Bonzini,
	Fam Zheng, Alex Bennée, Viresh Kumar,
	open list:Block layer core, open list:All patches CC here



> On Nov 23, 2023, at 12:54 AM, Li Feng <fengli@smartx.com> wrote:
> 
> Keep it the same to vhost-user-blk.
> At the same time, fix the vhost_reset_device.
> 
> Signed-off-by: Li Feng <fengli@smartx.com>

Reviewed-by: Raphael Norwitz <raphael.norwitz@nutanix.com>

> ---
> hw/scsi/vhost-user-scsi.c | 16 ++++++++++++++++
> hw/virtio/virtio.c        |  2 +-
> 2 files changed, 17 insertions(+), 1 deletion(-)
> 
> diff --git a/hw/scsi/vhost-user-scsi.c b/hw/scsi/vhost-user-scsi.c
> index 2060f9f94b..780f10559d 100644
> --- a/hw/scsi/vhost-user-scsi.c
> +++ b/hw/scsi/vhost-user-scsi.c
> @@ -360,6 +360,20 @@ static Property vhost_user_scsi_properties[] = {
>     DEFINE_PROP_END_OF_LIST(),
> };
> 
> +static void vhost_user_scsi_reset(VirtIODevice *vdev)
> +{
> +    VHostUserSCSI *s = VHOST_USER_SCSI(vdev);
> +    VHostSCSICommon *vsc = VHOST_SCSI_COMMON(s);
> +
> +    vhost_dev_free_inflight(vsc->inflight);
> +}
> +
> +static struct vhost_dev *vhost_user_scsi_get_vhost(VirtIODevice *vdev)
> +{
> +    VHostSCSICommon *vsc = VHOST_SCSI_COMMON(vdev);
> +    return &vsc->dev;
> +}
> +
> static const VMStateDescription vmstate_vhost_scsi = {
>     .name = "virtio-scsi",
>     .minimum_version_id = 1,
> @@ -385,6 +399,8 @@ static void vhost_user_scsi_class_init(ObjectClass *klass, void *data)
>     vdc->set_config = vhost_scsi_common_set_config;
>     vdc->set_status = vhost_user_scsi_set_status;
>     fwc->get_dev_path = vhost_scsi_common_get_fw_dev_path;
> +    vdc->reset = vhost_user_scsi_reset;
> +    vdc->get_vhost = vhost_user_scsi_get_vhost;
> }
> 
> static void vhost_user_scsi_instance_init(Object *obj)
> diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c
> index 4259fefeb6..d0a640af63 100644
> --- a/hw/virtio/virtio.c
> +++ b/hw/virtio/virtio.c
> @@ -2137,7 +2137,7 @@ void virtio_reset(void *opaque)
>         vdev->device_endian = virtio_default_endian();
>     }
> 
> -    if (vdev->vhost_started) {
> +    if (vdev->vhost_started && k->get_vhost) {
>         vhost_reset_device(k->get_vhost(vdev));
>     }
> 
> -- 
> 2.42.0
> 



^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2023-11-28  5:59 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-11-23  5:54 [PATCH 0/2] fix some vhost-user issues Li Feng
2023-11-23  5:54 ` [PATCH 1/2] vhost-user: fix the reconnect error Li Feng
2023-11-28  5:57   ` Raphael Norwitz
2023-11-23  5:54 ` [PATCH 2/2] vhost-user-scsi: free the inflight area when reset Li Feng
2023-11-28  5:57   ` Raphael Norwitz

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).