qemu/nbd
Eric Blake 7596bbb390 nbd/server: Hoist length check to qmp_nbd_server_add
We only had two callers to nbd_export_new; qemu-nbd.c always
passed a valid offset/length pair (because it already checked
the file length, to ensure that offset was in bounds), while
blockdev-nbd.c always passed 0/-1.  Then nbd_export_new reduces
the size to a multiple of BDRV_SECTOR_SIZE (can only happen
when offset is not sector-aligned, since bdrv_getlength()
currently rounds up) (someday, it would be nice to have
byte-accurate lengths - but not today).

However, I'm finding it easier to work with the code if we are
consistent on having both callers pass in a valid length, and
just assert that things are sane in nbd_export_new, meaning
that no negative values were passed, and that offset+size does
not exceed 63 bits (as that really is a fundamental limit to
later operations, whether we use off_t or uint64_t).

Signed-off-by: Eric Blake <eblake@redhat.com>
Message-Id: <20190117193658.16413-6-eblake@redhat.com>
Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
2019-01-21 15:49:51 -06:00
..
client.c nbd/client: Drop pointless buf variable 2019-01-05 07:53:22 -06:00
common.c nbd/server: introduce NBD_CMD_CACHE 2018-06-21 09:41:39 -05:00
Makefile.objs nbd: Split nbd.c 2016-01-15 18:58:02 +01:00
nbd-internal.h nbd/client: Drop pointless buf variable 2019-01-05 07:53:22 -06:00
server.c nbd/server: Hoist length check to qmp_nbd_server_add 2019-01-21 15:49:51 -06:00
trace-events nbd/client: Trace all server option error messages 2019-01-04 17:34:58 -06:00