]> git.proxmox.com Git - mirror_qemu.git/commit - nbd/server.c
nbd: Add 'qemu-nbd -A' to expose allocation depth
authorEric Blake <eblake@redhat.com>
Tue, 27 Oct 2020 05:05:55 +0000 (00:05 -0500)
committerEric Blake <eblake@redhat.com>
Fri, 30 Oct 2020 20:22:00 +0000 (15:22 -0500)
commitdbc7b01492371e4a54b92d2b6d968f9b863cc794
tree24812091f95b86d03192a23bec70e21d9a5b74eb
parent71719cd57fc02ddfd91a4a3ca3f469bfb4d221bc
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>
block/nbd.c
docs/tools/qemu-nbd.rst
nbd/server.c
qapi/block-core.json
qapi/block-export.json
qemu-nbd.c
tests/qemu-iotests/309 [new file with mode: 0755]
tests/qemu-iotests/309.out [new file with mode: 0644]
tests/qemu-iotests/group