diff options
author | Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> | 2018-03-08 21:46:35 +0300 |
---|---|---|
committer | Eric Blake <eblake@redhat.com> | 2018-03-13 15:38:55 -0500 |
commit | 6a4175997b942d74f95d18433cacd98c264c5dc6 (patch) | |
tree | 99ae5e7fd5cc3a9c8c389ecd27a133f623cfec70 /backends | |
parent | a0d7ce20a94ba66e1d9577429a62d133f1cd19cf (diff) | |
download | qemu-6a4175997b942d74f95d18433cacd98c264c5dc6.zip |
nbd/server: refactor nbd_trip: cmd_read and generic reply
nbd_trip has difficult logic when sending replies: it tries to use one
code path for all replies. It is ok for simple replies, but is not
comfortable for structured replies. Also, two types of error (and
corresponding messages in local_err) - fatal (leading to disconnect)
and not-fatal (just to be sent to the client) are difficult to follow.
To make things a bit clearer, the following is done:
- split CMD_READ logic to separate function. It is the most difficult
command for now, and it is definitely cramped inside nbd_trip. Also,
it is difficult to follow CMD_READ logic, shared between
"case NBD_CMD_READ" and "if"s under "reply:" label.
- create separate helper function nbd_send_generic_reply() and use it
both in new nbd_do_cmd_read and for other commands in nbd_trip instead
of common code-path under "reply:" label in nbd_trip. The helper
supports an error message, so logic with local_err in nbd_trip is
simplified.
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
Message-Id: <20180308184636.178534-5-vsementsov@virtuozzo.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
[eblake: grammar tweaks and blank line placement]
Signed-off-by: Eric Blake <eblake@redhat.com>
Diffstat (limited to 'backends')
0 files changed, 0 insertions, 0 deletions