diff options
author | Eric Blake <eblake@redhat.com> | 2020-10-27 00:05:55 -0500 |
---|---|---|
committer | Eric Blake <eblake@redhat.com> | 2020-10-30 15:22:00 -0500 |
commit | dbc7b01492371e4a54b92d2b6d968f9b863cc794 (patch) | |
tree | 24812091f95b86d03192a23bec70e21d9a5b74eb /nbd | |
parent | 71719cd57fc02ddfd91a4a3ca3f469bfb4d221bc (diff) |
nbd: Add 'qemu-nbd -A' to expose allocation depth
Allow the server to expose an additional metacontext to be requested
by savvy clients. qemu-nbd adds a new option -A to expose the
qemu:allocation-depth metacontext through NBD_CMD_BLOCK_STATUS; this
can also be set via QMP when using block-export-add.
qemu as client is hacked into viewing the key aspects of this new
context by abusing the already-experimental x-dirty-bitmap option to
collapse all depths greater than 2, which results in a tri-state value
visible in the output of 'qemu-img map --output=json' (yes, that means
x-dirty-bitmap is now a bit of a misnomer, but I didn't feel like
renaming it as it would introduce a needless break of back-compat,
even though we make no compat guarantees with x- members):
unallocated (depth 0) => "zero":false, "data":true
local (depth 1) => "zero":false, "data":false
backing (depth 2+) => "zero":true, "data":true
libnbd as client is probably a nicer way to get at the information
without having to decipher such hacks in qemu as client. ;)
Signed-off-by: Eric Blake <eblake@redhat.com>
Message-Id: <20201027050556.269064-11-eblake@redhat.com>
Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
Diffstat (limited to 'nbd')
-rw-r--r-- | nbd/server.c | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/nbd/server.c b/nbd/server.c index ebbefcb6d3..d145e1a690 100644 --- a/nbd/server.c +++ b/nbd/server.c @@ -1641,6 +1641,8 @@ static int nbd_export_create(BlockExport *blk_exp, BlockExportOptions *exp_args, bdrv_dirty_bitmap_set_busy(exp->export_bitmaps[i], true); } + exp->allocation_depth = arg->allocation_depth; + blk_add_aio_context_notifier(blk, blk_aio_attached, blk_aio_detach, exp); QTAILQ_INSERT_TAIL(&exports, exp, next); |