From f140e3000371e67ff4e00df3213e2d576d9c91be Mon Sep 17 00:00:00 2001 From: Vladimir Sementsov-Ogievskiy Date: Fri, 27 Oct 2017 12:40:37 +0200 Subject: nbd: Minimal structured read for client Minimal implementation: for structured error only error_report error message. Note that test 83 is now more verbose, because the implementation prints more warnings about unexpected communication errors; perhaps future patches should tone things down by using trace messages instead of traces, but the common case of successful communication is no noisier than before. Signed-off-by: Vladimir Sementsov-Ogievskiy Signed-off-by: Eric Blake Message-Id: <20171027104037.8319-13-eblake@redhat.com> --- nbd/client.c | 12 ++++++++++++ nbd/nbd-internal.h | 1 - 2 files changed, 12 insertions(+), 1 deletion(-) (limited to 'nbd') diff --git a/nbd/client.c b/nbd/client.c index 4f0745f601..3d680e63e1 100644 --- a/nbd/client.c +++ b/nbd/client.c @@ -602,9 +602,11 @@ int nbd_receive_negotiate(QIOChannel *ioc, const char *name, uint64_t magic; int rc; bool zeroes = true; + bool structured_reply = info->structured_reply; trace_nbd_receive_negotiate(tlscreds, hostname ? hostname : ""); + info->structured_reply = false; rc = -EINVAL; if (outioc) { @@ -685,6 +687,16 @@ int nbd_receive_negotiate(QIOChannel *ioc, const char *name, if (fixedNewStyle) { int result; + if (structured_reply) { + result = nbd_request_simple_option(ioc, + NBD_OPT_STRUCTURED_REPLY, + errp); + if (result < 0) { + goto fail; + } + info->structured_reply = result == 1; + } + /* Try NBD_OPT_GO first - if it works, we are done (it * also gives us a good message if the server requires * TLS). If it is not available, fall back to diff --git a/nbd/nbd-internal.h b/nbd/nbd-internal.h index b64eb1cc9b..eeff78d3c9 100644 --- a/nbd/nbd-internal.h +++ b/nbd/nbd-internal.h @@ -104,7 +104,6 @@ const char *nbd_opt_lookup(uint32_t opt); const char *nbd_rep_lookup(uint32_t rep); const char *nbd_info_lookup(uint16_t info); const char *nbd_cmd_lookup(uint16_t info); -const char *nbd_reply_type_lookup(uint16_t type); const char *nbd_err_lookup(int err); int nbd_drop(QIOChannel *ioc, size_t size, Error **errp); -- cgit v1.2.3-55-g7522