[PATCH] vhost-user-blk: fix the resize crash

Li Feng posted 1 patch 3 years, 4 months ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20220919121816.3252223-1-fengli@smartx.com
Maintainers: "Michael S. Tsirkin" <mst@redhat.com>, Raphael Norwitz <raphael.norwitz@nutanix.com>, Kevin Wolf <kwolf@redhat.com>, Hanna Reitz <hreitz@redhat.com>
hw/block/vhost-user-blk.c | 4 ++++
1 file changed, 4 insertions(+)
[PATCH] vhost-user-blk: fix the resize crash
Posted by Li Feng 3 years, 4 months ago
If the os is not installed and doesn't have the virtio guest driver,
the vhost dev isn't started, so the dev->vdev is NULL.

Reproduce: mount a Win 2019 iso, go into the install ui, then resize
the virtio-blk device, qemu crash.

Signed-off-by: Li Feng <fengli@smartx.com>
---
 hw/block/vhost-user-blk.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/hw/block/vhost-user-blk.c b/hw/block/vhost-user-blk.c
index 9117222456..db30bb754f 100644
--- a/hw/block/vhost-user-blk.c
+++ b/hw/block/vhost-user-blk.c
@@ -95,6 +95,10 @@ static int vhost_user_blk_handle_config_change(struct vhost_dev *dev)
     VHostUserBlk *s = VHOST_USER_BLK(dev->vdev);
     Error *local_err = NULL;
 
+    if (!dev->started) {
+        return 0;
+    }
+
     ret = vhost_dev_get_config(dev, (uint8_t *)&blkcfg,
                                sizeof(struct virtio_blk_config),
                                &local_err);
-- 
2.37.3
Re: [PATCH] vhost-user-blk: fix the resize crash
Posted by Kevin Wolf 3 years, 3 months ago
Am 19.09.2022 um 14:18 hat Li Feng geschrieben:
> If the os is not installed and doesn't have the virtio guest driver,
> the vhost dev isn't started, so the dev->vdev is NULL.
> 
> Reproduce: mount a Win 2019 iso, go into the install ui, then resize
> the virtio-blk device, qemu crash.
> 
> Signed-off-by: Li Feng <fengli@smartx.com>

Thanks, applied to the block branch.

Kevin
Re: [PATCH] vhost-user-blk: fix the resize crash
Posted by Raphael Norwitz 3 years, 4 months ago
>If the os is not installed and doesn't have the virtio guest driver,

>the vhost dev isn't started, so the dev->vdev is NULL.

>

>Reproduce: mount a Win 2019 iso, go into the install ui, then resize

>the virtio-blk device, qemu crash.

>

>Signed-off-by: Li Feng fengli@smartx.com<mailto:fengli@smartx.com>



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



>---

> hw/block/vhost-user-blk.c | 4 ++++

> 1 file changed, 4 insertions(+)

>

>diff --git a/hw/block/vhost-user-blk.c b/hw/block/vhost-user-blk.c

>index 9117222456..db30bb754f 100644

>--- a/hw/block/vhost-user-blk.c

>+++ b/hw/block/vhost-user-blk.c

>@@ -95,6 +95,10 @@ static int vhost_user_blk_handle_config_change(struct vhost_dev *dev)

>     VHostUserBlk *s = VHOST_USER_BLK(dev->vdev);

>     Error *local_err = NULL;

>

>+    if (!dev->started) {

>+        return 0;

>+    }

>+

>     ret = vhost_dev_get_config(dev, (uint8_t *)&blkcfg,

>                                sizeof(struct virtio_blk_config),

>                                &local_err);

>--

>2.37.3

>