[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 1/2] vhost-user-blk: handle errors in vhost_user_blk_connect
From: |
Konstantin Khlebnikov |
Subject: |
[PATCH 1/2] vhost-user-blk: handle errors in vhost_user_blk_connect |
Date: |
Thu, 10 Feb 2022 14:46:12 +0300 |
User-agent: |
StGit/1.4.dev11+gd5bef96 |
Cleanup vhost device and update connection state when initialization fails.
Signed-off-by: Konstantin Khlebnikov <khlebnikov@yandex-team.ru>
---
hw/block/vhost-user-blk.c | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/hw/block/vhost-user-blk.c b/hw/block/vhost-user-blk.c
index 1a42ae9187..35ac188ca4 100644
--- a/hw/block/vhost-user-blk.c
+++ b/hw/block/vhost-user-blk.c
@@ -340,18 +340,24 @@ static int vhost_user_blk_connect(DeviceState *dev, Error
**errp)
ret = vhost_dev_init(&s->dev, &s->vhost_user, VHOST_BACKEND_TYPE_USER, 0,
errp);
if (ret < 0) {
- return ret;
+ goto err_init;
}
/* restore vhost state */
if (virtio_device_started(vdev, vdev->status)) {
ret = vhost_user_blk_start(vdev, errp);
if (ret < 0) {
- return ret;
+ goto err_start;
}
}
return 0;
+
+err_start:
+ vhost_dev_cleanup(&s->dev);
+err_init:
+ s->connected = false;
+ return ret;
}
static void vhost_user_blk_disconnect(DeviceState *dev)
- [PATCH 1/2] vhost-user-blk: handle errors in vhost_user_blk_connect,
Konstantin Khlebnikov <=