On 03/12/2018 08:13 AM, Vladimir Sementsov-Ogievskiy wrote:


We should probably validate that the length field is a multiple of min_block (if a server tells us that all operations must be 512-byte aligned, then reports an extent that is smaller than 512 bytes, we have no way to ask for the status of the second half of the sector). Probably also something that needs to be explicitly stated in the NBD spec. [1]

related question: what server should reply on zero-length request? I'll add

+     if (!bytes) {
+         *pnum = 0;
+         return 0;
+     }

to nbd_client_co_block_status, to prevent such situation, but looks like spec lacks the information.

nbd.git commit ee926037 mentions that NBD_CMD_READ, _WRITE, _TRIM, and _WRITE_ZEROES have unspecified behavior for zero-length transactions; we should do the same for NBD_CMD_BLOCK_STATUS. But in the meantime, handling it gracefully with a no-op reply (the way qemu.git commit ef8c887e handles 0-length structured read) is fine.

--
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3266
Virtualization:  qemu.org | libvirt.org

Reply via email to