diff options
author | Vladimir Sementsov-Ogievskiy | 2021-02-05 17:37:12 +0100 |
---|---|---|
committer | Eric Blake | 2021-02-12 16:45:18 +0100 |
commit | c4f7f24e1f6e81804a7f15356614d9249280ab02 (patch) | |
tree | e5ec9207d60dce4824612a97fbac076d1ad4c2ff | |
parent | block: add new BlockDriver handler: bdrv_cancel_in_flight (diff) | |
download | qemu-c4f7f24e1f6e81804a7f15356614d9249280ab02.tar.gz qemu-c4f7f24e1f6e81804a7f15356614d9249280ab02.tar.xz qemu-c4f7f24e1f6e81804a7f15356614d9249280ab02.zip |
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>
-rw-r--r-- | block/nbd.c | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/block/nbd.c b/block/nbd.c index b3cbbeb4b0..c26dc5a54f 100644 --- a/block/nbd.c +++ b/block/nbd.c @@ -2458,6 +2458,18 @@ static const char *const nbd_strong_runtime_opts[] = { 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 = { .format_name = "nbd", .protocol_name = "nbd", @@ -2484,6 +2496,7 @@ static BlockDriver bdrv_nbd = { .bdrv_co_block_status = nbd_client_co_block_status, .bdrv_dirname = nbd_dirname, .strong_runtime_opts = nbd_strong_runtime_opts, + .bdrv_cancel_in_flight = nbd_cancel_in_flight, }; static BlockDriver bdrv_nbd_tcp = { @@ -2512,6 +2525,7 @@ static BlockDriver bdrv_nbd_tcp = { .bdrv_co_block_status = nbd_client_co_block_status, .bdrv_dirname = nbd_dirname, .strong_runtime_opts = nbd_strong_runtime_opts, + .bdrv_cancel_in_flight = nbd_cancel_in_flight, }; static BlockDriver bdrv_nbd_unix = { @@ -2540,6 +2554,7 @@ static BlockDriver bdrv_nbd_unix = { .bdrv_co_block_status = nbd_client_co_block_status, .bdrv_dirname = nbd_dirname, .strong_runtime_opts = nbd_strong_runtime_opts, + .bdrv_cancel_in_flight = nbd_cancel_in_flight, }; static void bdrv_nbd_init(void) |