From: Eric Blake <eblake@redhat.com>
To: qemu-devel@nongnu.org
Cc: Kevin Wolf <kwolf@redhat.com>, Lukas Straub <lukasstraub2@web.de>,
Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>,
"open list:Network Block Dev..." <qemu-block@nongnu.org>,
Max Reitz <mreitz@redhat.com>
Subject: [PULL 4/4] nbd: register yank function earlier
Date: Fri, 9 Jul 2021 09:09:51 -0500 [thread overview]
Message-ID: <20210709140951.2775730-5-eblake@redhat.com> (raw)
In-Reply-To: <20210709140951.2775730-1-eblake@redhat.com>
From: Lukas Straub <lukasstraub2@web.de>
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>
Message-Id: <20210704000730.1befb596@gecko.fritz.box>
Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
---
block/nbd.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/block/nbd.c b/block/nbd.c
index 601fccc5bacd..f6ff1c4fb472 100644
--- a/block/nbd.c
+++ b/block/nbd.c
@@ -371,6 +371,9 @@ int coroutine_fn nbd_co_do_establish_connection(BlockDriverState *bs,
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) {
/*
@@ -381,6 +384,8 @@ int coroutine_fn nbd_co_do_establish_connection(BlockDriverState *bs,
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;
@@ -390,9 +395,6 @@ int coroutine_fn nbd_co_do_establish_connection(BlockDriverState *bs,
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);
--
2.31.1
next prev parent reply other threads:[~2021-07-09 14:11 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-07-09 14:09 [PULL 0/4] NBD patches for soft freeze, 2021-07-09 Eric Blake
2021-07-09 14:09 ` [PULL 1/4] iotests: Improve and rename test 309 to nbd-qemu-allocation Eric Blake
2021-07-09 14:09 ` [PULL 2/4] qemu-img: Make unallocated part of backing chain obvious in map Eric Blake
2021-07-09 14:09 ` [PULL 3/4] qemu-img: Reword 'qemu-img map --output=json' docs Eric Blake
2021-07-09 14:09 ` Eric Blake [this message]
2021-07-11 12:09 ` [PULL 0/4] NBD patches for soft freeze, 2021-07-09 Peter Maydell
2021-07-12 16:13 ` Eric Blake
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210709140951.2775730-5-eblake@redhat.com \
--to=eblake@redhat.com \
--cc=kwolf@redhat.com \
--cc=lukasstraub2@web.de \
--cc=mreitz@redhat.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=vsementsov@virtuozzo.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).