15135fe71SPhilippe Mathieu-DaudéQEMU supports the NBD protocol, and has an internal NBD client (see 23229a835SVladimir Sementsov-Ogievskiyblock/nbd.c), an internal NBD server (see blockdev-nbd.c), and an 33229a835SVladimir Sementsov-Ogievskiyexternal NBD server tool (see qemu-nbd.c). The common code is placed 43229a835SVladimir Sementsov-Ogievskiyin nbd/*. 53229a835SVladimir Sementsov-Ogievskiy 63229a835SVladimir Sementsov-OgievskiyThe NBD protocol is specified here: 73229a835SVladimir Sementsov-Ogievskiyhttps://github.com/NetworkBlockDevice/nbd/blob/master/doc/proto.md 83229a835SVladimir Sementsov-Ogievskiy 93229a835SVladimir Sementsov-OgievskiyThe following paragraphs describe some specific properties of NBD 105135fe71SPhilippe Mathieu-Daudéprotocol realization in QEMU. 113229a835SVladimir Sementsov-Ogievskiy 123229a835SVladimir Sementsov-Ogievskiy= Metadata namespaces = 133229a835SVladimir Sementsov-Ogievskiy 145135fe71SPhilippe Mathieu-DaudéQEMU supports the "base:allocation" metadata context as defined in the 153229a835SVladimir Sementsov-OgievskiyNBD protocol specification, and also defines an additional metadata 163229a835SVladimir Sementsov-Ogievskiynamespace "qemu". 173229a835SVladimir Sementsov-Ogievskiy 183229a835SVladimir Sementsov-Ogievskiy== "qemu" namespace == 193229a835SVladimir Sementsov-Ogievskiy 2071719cd5SEric BlakeThe "qemu" namespace currently contains two available metadata context 2171719cd5SEric Blaketypes. The first is related to exposing the contents of a dirty 2271719cd5SEric Blakebitmap alongside the associated disk contents. That metadata context 2371719cd5SEric Blakeis named with the following form: 243229a835SVladimir Sementsov-Ogievskiy 253229a835SVladimir Sementsov-Ogievskiy qemu:dirty-bitmap:<dirty-bitmap-export-name> 263229a835SVladimir Sementsov-Ogievskiy 273229a835SVladimir Sementsov-OgievskiyEach dirty-bitmap metadata context defines only one flag for extents 283229a835SVladimir Sementsov-Ogievskiyin reply for NBD_CMD_BLOCK_STATUS: 293229a835SVladimir Sementsov-Ogievskiy 3071719cd5SEric Blake bit 0: NBD_STATE_DIRTY, set when the extent is "dirty" 3171719cd5SEric Blake 3271719cd5SEric BlakeThe second is related to exposing the source of various extents within 3371719cd5SEric Blakethe image, with a single metadata context named: 3471719cd5SEric Blake 3571719cd5SEric Blake qemu:allocation-depth 3671719cd5SEric Blake 3771719cd5SEric BlakeIn the allocation depth context, the entire 32-bit value represents a 3871719cd5SEric Blakedepth of which layer in a thin-provisioned backing chain provided the 3971719cd5SEric Blakedata (0 for unallocated, 1 for the active layer, 2 for the first 4071719cd5SEric Blakebacking layer, and so forth). 413229a835SVladimir Sementsov-Ogievskiy 423229a835SVladimir Sementsov-OgievskiyFor NBD_OPT_LIST_META_CONTEXT the following queries are supported 4371719cd5SEric Blakein addition to the specific "qemu:allocation-depth" and 4471719cd5SEric Blake"qemu:dirty-bitmap:<dirty-bitmap-export-name>": 453229a835SVladimir Sementsov-Ogievskiy 463229a835SVladimir Sementsov-Ogievskiy* "qemu:" - returns list of all available metadata contexts in the 473229a835SVladimir Sementsov-Ogievskiy namespace. 483229a835SVladimir Sementsov-Ogievskiy* "qemu:dirty-bitmap:" - returns list of all available dirty-bitmap 493229a835SVladimir Sementsov-Ogievskiy metadata contexts. 50ba2d3b3aSEric Blake 51ba2d3b3aSEric Blake= Features by version = 52ba2d3b3aSEric Blake 53ba2d3b3aSEric BlakeThe following list documents which qemu version first implemented 54ba2d3b3aSEric Blakevarious features (both as a server exposing the feature, and as a 55ba2d3b3aSEric Blakeclient taking advantage of the feature when present), to make it 56ba2d3b3aSEric Blakeeasier to plan for cross-version interoperability. Note that in 57ba2d3b3aSEric Blakeseveral cases, the initial release containing a feature may require 58ba2d3b3aSEric Blakeadditional patches from the corresponding stable branch to fix bugs in 59ba2d3b3aSEric Blakethe operation of that feature. 60ba2d3b3aSEric Blake 61ba2d3b3aSEric Blake* 2.6: NBD_OPT_STARTTLS with TLS X.509 Certificates 62ba2d3b3aSEric Blake* 2.8: NBD_CMD_WRITE_ZEROES 63ba2d3b3aSEric Blake* 2.10: NBD_OPT_GO, NBD_INFO_BLOCK 64ba2d3b3aSEric Blake* 2.11: NBD_OPT_STRUCTURED_REPLY 65ba2d3b3aSEric Blake* 2.12: NBD_CMD_BLOCK_STATUS for "base:allocation" 66ba2d3b3aSEric Blake* 3.0: NBD_OPT_STARTTLS with TLS Pre-Shared Keys (PSK), 67ba2d3b3aSEric BlakeNBD_CMD_BLOCK_STATUS for "qemu:dirty-bitmap:", NBD_CMD_CACHE 6876ca4b58Szhaolichang* 4.2: NBD_FLAG_CAN_MULTI_CONN for shareable read-only exports, 690a479545SEric BlakeNBD_CMD_FLAG_FAST_ZERO 7071719cd5SEric Blake* 5.2: NBD_CMD_BLOCK_STATUS for "qemu:allocation-depth" 7158a6fdccSEric Blake* 7.1: NBD_FLAG_CAN_MULTI_CONN for shareable writable exports 72*2dcbb11bSEric Blake* 8.2: NBD_OPT_EXTENDED_HEADERS, NBD_FLAG_BLOCK_STATUS_PAYLOAD 73