qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH 1/2] vhost-user-blk: handle errors in vhost_user_blk_connect


From: Philippe Mathieu-Daudé
Subject: Re: [PATCH 1/2] vhost-user-blk: handle errors in vhost_user_blk_connect
Date: Thu, 10 Feb 2022 12:56:41 +0100
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:91.0) Gecko/20100101 Thunderbird/91.5.1

On 10/2/22 12:46, Konstantin Khlebnikov wrote:
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;
          }
      }

What about moving here ...:

    s->connected = true;

return 0;
+
+err_start:
+    vhost_dev_cleanup(&s->dev);
+err_init:
+    s->connected = false;

... to have a single 'err' label?

+    return ret;
  }
static void vhost_user_blk_disconnect(DeviceState *dev)






reply via email to

[Prev in Thread] Current Thread [Next in Thread]