nbd: register yank function earlier
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>
This commit is contained in:
parent
a275b452c6
commit
0b9cd6b947
@ -371,6 +371,9 @@ int coroutine_fn nbd_co_do_establish_connection(BlockDriverState *bs,
|
|||||||
return -ECONNREFUSED;
|
return -ECONNREFUSED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
yank_register_function(BLOCKDEV_YANK_INSTANCE(s->bs->node_name), nbd_yank,
|
||||||
|
bs);
|
||||||
|
|
||||||
ret = nbd_handle_updated_info(s->bs, NULL);
|
ret = nbd_handle_updated_info(s->bs, NULL);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
/*
|
/*
|
||||||
@ -381,6 +384,8 @@ int coroutine_fn nbd_co_do_establish_connection(BlockDriverState *bs,
|
|||||||
|
|
||||||
nbd_send_request(s->ioc, &request);
|
nbd_send_request(s->ioc, &request);
|
||||||
|
|
||||||
|
yank_unregister_function(BLOCKDEV_YANK_INSTANCE(s->bs->node_name),
|
||||||
|
nbd_yank, bs);
|
||||||
object_unref(OBJECT(s->ioc));
|
object_unref(OBJECT(s->ioc));
|
||||||
s->ioc = NULL;
|
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_set_blocking(s->ioc, false, NULL);
|
||||||
qio_channel_attach_aio_context(s->ioc, bdrv_get_aio_context(bs));
|
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 */
|
/* successfully connected */
|
||||||
s->state = NBD_CLIENT_CONNECTED;
|
s->state = NBD_CLIENT_CONNECTED;
|
||||||
qemu_co_queue_restart_all(&s->free_sema);
|
qemu_co_queue_restart_all(&s->free_sema);
|
||||||
|
Loading…
Reference in New Issue
Block a user