diff mbox series

[resend] nbd: register yank function earlier

Message ID 20210704125643.69f303ca@gecko.fritz.box (mailing list archive)
State New, archived
Headers show
Series [resend] nbd: register yank function earlier | expand

Commit Message

Lukas Straub July 4, 2021, 10:56 a.m. UTC
Although unlikely, qemu might hang in nbd_send_request().

Allow recovery in this case by registering the yank function before
calling it.

Signed-off-by: Lukas Straub <lukasstraub2@web.de>
---

Fix CC: email address so the mailing list doesn't reject it.

 block/nbd.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

Comments

Vladimir Sementsov-Ogievskiy July 5, 2021, 8:07 a.m. UTC | #1
04.07.2021 13:56, Lukas Straub wrote:
> Although unlikely, qemu might hang in nbd_send_request().
> 
> Allow recovery in this case by registering the yank function before
> calling it.
> 
> Signed-off-by: Lukas Straub<lukasstraub2@web.de>


Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
diff mbox series

Patch

diff --git a/block/nbd.c b/block/nbd.c
index 601fccc5ba..f6ff1c4fb4 100644
--- a/block/nbd.c
+++ b/block/nbd.c
@@ -369,32 +369,34 @@  int coroutine_fn nbd_co_do_establish_connection(BlockDriverState *bs,
     s->ioc = nbd_co_establish_connection(s->conn, &s->info, true, errp);
     if (!s->ioc) {
         return -ECONNREFUSED;
     }
 
+    yank_register_function(BLOCKDEV_YANK_INSTANCE(s->bs->node_name), nbd_yank,
+                           bs);
+
     ret = nbd_handle_updated_info(s->bs, NULL);
     if (ret < 0) {
         /*
          * We have connected, but must fail for other reasons.
          * Send NBD_CMD_DISC as a courtesy to the server.
          */
         NBDRequest request = { .type = NBD_CMD_DISC };
 
         nbd_send_request(s->ioc, &request);
 
+        yank_unregister_function(BLOCKDEV_YANK_INSTANCE(s->bs->node_name),
+                                 nbd_yank, bs);
         object_unref(OBJECT(s->ioc));
         s->ioc = NULL;
 
         return ret;
     }
 
     qio_channel_set_blocking(s->ioc, false, NULL);
     qio_channel_attach_aio_context(s->ioc, bdrv_get_aio_context(bs));
 
-    yank_register_function(BLOCKDEV_YANK_INSTANCE(s->bs->node_name), nbd_yank,
-                           bs);
-
     /* successfully connected */
     s->state = NBD_CLIENT_CONNECTED;
     qemu_co_queue_restart_all(&s->free_sema);
 
     return 0;