qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH resend] nbd: register yank function earlier
@ 2021-07-04 10:56 Lukas Straub
  2021-07-05  8:07 ` Vladimir Sementsov-Ogievskiy
  0 siblings, 1 reply; 2+ messages in thread
From: Lukas Straub @ 2021-07-04 10:56 UTC (permalink / raw)
  To: qemu-devel
  Cc: Kevin Wolf, Vladimir Sementsov-Ogievskiy, Eric Blake, qemu-block,
	Max Reitz

[-- Attachment #1: Type: text/plain, Size: 1771 bytes --]

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

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;
-- 
2.32.0

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

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

* Re: [PATCH resend] nbd: register yank function earlier
  2021-07-04 10:56 [PATCH resend] nbd: register yank function earlier Lukas Straub
@ 2021-07-05  8:07 ` Vladimir Sementsov-Ogievskiy
  0 siblings, 0 replies; 2+ messages in thread
From: Vladimir Sementsov-Ogievskiy @ 2021-07-05  8:07 UTC (permalink / raw)
  To: Lukas Straub, qemu-devel; +Cc: qemu-block, Eric Blake, Kevin Wolf, Max Reitz

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>


-- 
Best regards,
Vladimir


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

end of thread, other threads:[~2021-07-05  8:08 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-07-04 10:56 [PATCH resend] nbd: register yank function earlier Lukas Straub
2021-07-05  8:07 ` Vladimir Sementsov-Ogievskiy

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