block/nbd: implement .bdrv_cancel_in_flight

Just stop waiting for connection in existing requests.

Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Message-Id: <20210205163720.887197-3-vsementsov@virtuozzo.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
This commit is contained in:
Vladimir Sementsov-Ogievskiy 2021-02-05 19:37:12 +03:00 committed by Eric Blake
parent bd54669a4a
commit c4f7f24e1f

View File

@ -2458,6 +2458,18 @@ static const char *const nbd_strong_runtime_opts[] = {
NULL NULL
}; };
static void nbd_cancel_in_flight(BlockDriverState *bs)
{
BDRVNBDState *s = (BDRVNBDState *)bs->opaque;
reconnect_delay_timer_del(s);
if (s->state == NBD_CLIENT_CONNECTING_WAIT) {
s->state = NBD_CLIENT_CONNECTING_NOWAIT;
qemu_co_queue_restart_all(&s->free_sema);
}
}
static BlockDriver bdrv_nbd = { static BlockDriver bdrv_nbd = {
.format_name = "nbd", .format_name = "nbd",
.protocol_name = "nbd", .protocol_name = "nbd",
@ -2484,6 +2496,7 @@ static BlockDriver bdrv_nbd = {
.bdrv_co_block_status = nbd_client_co_block_status, .bdrv_co_block_status = nbd_client_co_block_status,
.bdrv_dirname = nbd_dirname, .bdrv_dirname = nbd_dirname,
.strong_runtime_opts = nbd_strong_runtime_opts, .strong_runtime_opts = nbd_strong_runtime_opts,
.bdrv_cancel_in_flight = nbd_cancel_in_flight,
}; };
static BlockDriver bdrv_nbd_tcp = { static BlockDriver bdrv_nbd_tcp = {
@ -2512,6 +2525,7 @@ static BlockDriver bdrv_nbd_tcp = {
.bdrv_co_block_status = nbd_client_co_block_status, .bdrv_co_block_status = nbd_client_co_block_status,
.bdrv_dirname = nbd_dirname, .bdrv_dirname = nbd_dirname,
.strong_runtime_opts = nbd_strong_runtime_opts, .strong_runtime_opts = nbd_strong_runtime_opts,
.bdrv_cancel_in_flight = nbd_cancel_in_flight,
}; };
static BlockDriver bdrv_nbd_unix = { static BlockDriver bdrv_nbd_unix = {
@ -2540,6 +2554,7 @@ static BlockDriver bdrv_nbd_unix = {
.bdrv_co_block_status = nbd_client_co_block_status, .bdrv_co_block_status = nbd_client_co_block_status,
.bdrv_dirname = nbd_dirname, .bdrv_dirname = nbd_dirname,
.strong_runtime_opts = nbd_strong_runtime_opts, .strong_runtime_opts = nbd_strong_runtime_opts,
.bdrv_cancel_in_flight = nbd_cancel_in_flight,
}; };
static void bdrv_nbd_init(void) static void bdrv_nbd_init(void)