diff options
author | Peter Maydell | 2019-02-05 13:46:18 +0100 |
---|---|---|
committer | Peter Maydell | 2019-02-05 13:46:18 +0100 |
commit | 1c3d45df5e94042d5fb2bb31416072563ab30e49 (patch) | |
tree | b93bbcb015f1a7e2b2cc14d26930536b0559faa1 /nbd/server.c | |
parent | Merge remote-tracking branch 'remotes/xtensa/tags/20190204-xtensa' into staging (diff) | |
parent | block/nbd-client: rename read_reply_co to connection_co (diff) | |
download | qemu-1c3d45df5e94042d5fb2bb31416072563ab30e49.tar.gz qemu-1c3d45df5e94042d5fb2bb31416072563ab30e49.tar.xz qemu-1c3d45df5e94042d5fb2bb31416072563ab30e49.zip |
Merge remote-tracking branch 'remotes/ericb/tags/pull-nbd-2019-02-04' into staging
nbd patches for 2019-02-04
- deprecate 'qemu-nbd --partition'
- preparation for NBD reconnect, including better logging of read errors
# gpg: Signature made Tue 05 Feb 2019 03:50:56 GMT
# gpg: using RSA key A7A16B4A2527436A
# gpg: Good signature from "Eric Blake <eblake@redhat.com>" [full]
# gpg: aka "Eric Blake (Free Software Programmer) <ebb9@byu.net>" [full]
# gpg: aka "[jpeg image of size 6874]" [full]
# Primary key fingerprint: 71C2 CC22 B1C4 6029 27D2 F3AA A7A1 6B4A 2527 436A
* remotes/ericb/tags/pull-nbd-2019-02-04:
block/nbd-client: rename read_reply_co to connection_co
block/nbd-client: don't check ioc
block/nbd-client: fix nbd_reply_chunk_iter_receive
block/nbd-client: split connection from initialization
block/nbd: move connection code from block/nbd to block/nbd-client
block/nbd-client: split channel errors from export errors
nbd: generalize usage of nbd_read
qemu-nbd: Deprecate qemu-nbd --partition
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Diffstat (limited to 'nbd/server.c')
-rw-r--r-- | nbd/server.c | 27 |
1 files changed, 9 insertions, 18 deletions
diff --git a/nbd/server.c b/nbd/server.c index cb0d5634fa..838c150d8c 100644 --- a/nbd/server.c +++ b/nbd/server.c @@ -438,8 +438,7 @@ static int nbd_negotiate_handle_export_name(NBDClient *client, error_setg(errp, "Bad length received"); return -EINVAL; } - if (nbd_read(client->ioc, name, client->optlen, errp) < 0) { - error_prepend(errp, "read failed: "); + if (nbd_read(client->ioc, name, client->optlen, "export name", errp) < 0) { return -EIO; } name[client->optlen] = '\0'; @@ -1046,11 +1045,9 @@ static int nbd_negotiate_options(NBDClient *client, uint16_t myflags, ... Rest of request */ - if (nbd_read(client->ioc, &flags, sizeof(flags), errp) < 0) { - error_prepend(errp, "read failed: "); + if (nbd_read32(client->ioc, &flags, "flags", errp) < 0) { return -EIO; } - flags = be32_to_cpu(flags); trace_nbd_negotiate_options_flags(flags); if (flags & NBD_FLAG_C_FIXED_NEWSTYLE) { fixedNewstyle = true; @@ -1070,30 +1067,23 @@ static int nbd_negotiate_options(NBDClient *client, uint16_t myflags, uint32_t option, length; uint64_t magic; - if (nbd_read(client->ioc, &magic, sizeof(magic), errp) < 0) { - error_prepend(errp, "read failed: "); + if (nbd_read64(client->ioc, &magic, "opts magic", errp) < 0) { return -EINVAL; } - magic = be64_to_cpu(magic); trace_nbd_negotiate_options_check_magic(magic); if (magic != NBD_OPTS_MAGIC) { error_setg(errp, "Bad magic received"); return -EINVAL; } - if (nbd_read(client->ioc, &option, - sizeof(option), errp) < 0) { - error_prepend(errp, "read failed: "); + if (nbd_read32(client->ioc, &option, "option", errp) < 0) { return -EINVAL; } - option = be32_to_cpu(option); client->opt = option; - if (nbd_read(client->ioc, &length, sizeof(length), errp) < 0) { - error_prepend(errp, "read failed: "); + if (nbd_read32(client->ioc, &length, "option length", errp) < 0) { return -EINVAL; } - length = be32_to_cpu(length); assert(!client->optlen); client->optlen = length; @@ -1306,7 +1296,7 @@ static int nbd_receive_request(QIOChannel *ioc, NBDRequest *request, uint32_t magic; int ret; - ret = nbd_read(ioc, buf, sizeof(buf), errp); + ret = nbd_read(ioc, buf, sizeof(buf), "request", errp); if (ret < 0) { return ret; } @@ -2111,8 +2101,9 @@ static int nbd_co_receive_request(NBDRequestData *req, NBDRequest *request, } } if (request->type == NBD_CMD_WRITE) { - if (nbd_read(client->ioc, req->data, request->len, errp) < 0) { - error_prepend(errp, "reading from socket failed: "); + if (nbd_read(client->ioc, req->data, request->len, "CMD_WRITE data", + errp) < 0) + { return -EIO; } req->complete = true; |