nbd: Simplify meta-context parsing
commitebd57062a1957307a175a810441af87259d7dbe9
authorEric Blake <eblake@redhat.com>
Wed, 30 Sep 2020 12:11:03 +0000 (30 07:11 -0500)
committerEric Blake <eblake@redhat.com>
Fri, 9 Oct 2020 20:05:08 +0000 (9 15:05 -0500)
treea3c5a6f8b035d43727ee419b24c30e258d66c54f
parentd1e2c3e7bd22a99660b0c254fc05c020d0239ca0
nbd: Simplify meta-context parsing

We had a premature optimization of trying to read as little from the
wire as possible while handling NBD_OPT_SET_META_CONTEXT in phases.
But in reality, we HAVE to read the entire string from the client
before we can get to the next command, and it is easier to just read
it all at once than it is to read it in pieces.  And once we do that,
several functions end up no longer performing I/O, so they can drop
length and errp parameters, and just return a bool instead of
modifying through a pointer.

Our iotests still pass; I also checked that libnbd's testsuite (which
covers more corner cases of odd meta context requests) still passes.
There are cases where the sequence of trace messages produced differs
(for example, when no bitmap is exported, a query for "qemu:" now
produces two trace lines instead of one), but trace points are for
debug and have no effect on what the client sees.

Signed-off-by: Eric Blake <eblake@redhat.com>
Message-Id: <20200930121105.667049-4-eblake@redhat.com>
Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
[eblake: enhance commit message]
Signed-off-by: Eric Blake <eblake@redhat.com>
nbd/server.c