mirror of https://github.com/xemu-project/xemu.git
nbd patches for 2018-04-02
- Eric Blake: nbd: Fix 32-bit compilation on BLOCK_STATUS - Eric Blake: nbd/client: Correctly handle bad server REP_META_CONTEXT - Eric Blake: nbd: trace meta context negotiation -----BEGIN PGP SIGNATURE----- Comment: Public key at http://people.redhat.com/eblake/eblake.gpg iQEcBAABCAAGBQJawjrlAAoJEKeha0olJ0NqFQMIAIJfn+VPlPSXsX72pYzlRDhQ rWmlpqrfeYo8+gfTSt30ZGa0LDz+ZiTlToN/NdCnqexBHiok0Im+vSzAH8UJFjpo KHvr/Lh/x+rvx1w5Z/+2wFu46EyrikwRHSLpvlCow5IyDv+GMPbS7qmVxT6Hri6f MsLJRqg54AwR6CuWXVdBC3SO1TV4VNJSM+Mmlrpk9G3s7l46HmYpS5PaNP3sjgLR vezmvZ1pCc4Q7bXjAOBSzyc3mCoq1XYldapgBOXRHCWQScYj13w+PWyLO6yVBWzG GDEDsD6GFdp/Sgphr66f+ou/ILt/Ic6SJ1s9wDZ+GRDPow8DmEcIiBIz92/iEys= =R2Qk -----END PGP SIGNATURE----- Merge remote-tracking branch 'remotes/ericb/tags/pull-nbd-2018-04-02' into staging nbd patches for 2018-04-02 - Eric Blake: nbd: Fix 32-bit compilation on BLOCK_STATUS - Eric Blake: nbd/client: Correctly handle bad server REP_META_CONTEXT - Eric Blake: nbd: trace meta context negotiation # gpg: Signature made Mon 02 Apr 2018 15:15:01 BST # gpg: using RSA key A7A16B4A2527436A # gpg: Good signature from "Eric Blake <eblake@redhat.com>" # gpg: aka "Eric Blake (Free Software Programmer) <ebb9@byu.net>" # gpg: aka "[jpeg image of size 6874]" # Primary key fingerprint: 71C2 CC22 B1C4 6029 27D2 F3AA A7A1 6B4A 2527 436A * remotes/ericb/tags/pull-nbd-2018-04-02: nbd: trace meta context negotiation nbd/client: Correctly handle bad server REP_META_CONTEXT nbd: Fix 32-bit compilation on BLOCK_STATUS Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
This commit is contained in:
commit
13b65ec54d
|
@ -239,7 +239,7 @@ static int nbd_parse_blockstatus_payload(NBDClientSession *client,
|
|||
{
|
||||
uint32_t context_id;
|
||||
|
||||
if (chunk->length != sizeof(context_id) + sizeof(extent)) {
|
||||
if (chunk->length != sizeof(context_id) + sizeof(*extent)) {
|
||||
error_setg(errp, "Protocol error: invalid payload for "
|
||||
"NBD_REPLY_TYPE_BLOCK_STATUS");
|
||||
return -EINVAL;
|
||||
|
|
30
nbd/client.c
30
nbd/client.c
|
@ -599,8 +599,8 @@ static QIOChannel *nbd_receive_starttls(QIOChannel *ioc,
|
|||
* Set one meta context. Simple means that reply must contain zero (not
|
||||
* negotiated) or one (negotiated) contexts. More contexts would be considered
|
||||
* as a protocol error. It's also implied that meta-data query equals queried
|
||||
* context name, so, if server replies with something different then @context,
|
||||
* it considered as error too.
|
||||
* context name, so, if server replies with something different than @context,
|
||||
* it is considered an error too.
|
||||
* return 1 for successful negotiation, context_id is set
|
||||
* 0 if operation is unsupported,
|
||||
* -1 with errp set for any other error
|
||||
|
@ -623,6 +623,7 @@ static int nbd_negotiate_simple_meta_context(QIOChannel *ioc,
|
|||
char *data = g_malloc(data_len);
|
||||
char *p = data;
|
||||
|
||||
trace_nbd_opt_meta_request(context, export);
|
||||
stl_be_p(p, export_len);
|
||||
memcpy(p += sizeof(export_len), export, export_len);
|
||||
stl_be_p(p += export_len, 1);
|
||||
|
@ -649,29 +650,38 @@ static int nbd_negotiate_simple_meta_context(QIOChannel *ioc,
|
|||
|
||||
if (reply.type == NBD_REP_META_CONTEXT) {
|
||||
char *name;
|
||||
size_t len;
|
||||
|
||||
if (reply.length != sizeof(received_id) + context_len) {
|
||||
error_setg(errp, "Failed to negotiate meta context '%s', server "
|
||||
"answered with unexpected length %" PRIu32, context,
|
||||
reply.length);
|
||||
nbd_send_opt_abort(ioc);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (nbd_read(ioc, &received_id, sizeof(received_id), errp) < 0) {
|
||||
return -1;
|
||||
}
|
||||
be32_to_cpus(&received_id);
|
||||
|
||||
len = reply.length - sizeof(received_id);
|
||||
name = g_malloc(len + 1);
|
||||
if (nbd_read(ioc, name, len, errp) < 0) {
|
||||
reply.length -= sizeof(received_id);
|
||||
name = g_malloc(reply.length + 1);
|
||||
if (nbd_read(ioc, name, reply.length, errp) < 0) {
|
||||
g_free(name);
|
||||
return -1;
|
||||
}
|
||||
name[len] = '\0';
|
||||
name[reply.length] = '\0';
|
||||
if (strcmp(context, name)) {
|
||||
error_setg(errp, "Failed to negotiate meta context '%s', server "
|
||||
"answered with different context '%s'", context,
|
||||
name);
|
||||
g_free(name);
|
||||
nbd_send_opt_abort(ioc);
|
||||
return -1;
|
||||
}
|
||||
g_free(name);
|
||||
|
||||
trace_nbd_opt_meta_reply(context, received_id);
|
||||
received = true;
|
||||
|
||||
/* receive NBD_REP_ACK */
|
||||
|
@ -690,6 +700,12 @@ static int nbd_negotiate_simple_meta_context(QIOChannel *ioc,
|
|||
if (reply.type != NBD_REP_ACK) {
|
||||
error_setg(errp, "Unexpected reply type %" PRIx32 " expected %x",
|
||||
reply.type, NBD_REP_ACK);
|
||||
nbd_send_opt_abort(ioc);
|
||||
return -1;
|
||||
}
|
||||
if (reply.length) {
|
||||
error_setg(errp, "Unexpected length to ACK response");
|
||||
nbd_send_opt_abort(ioc);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
|
|
@ -726,6 +726,7 @@ static int nbd_negotiate_send_meta_context(NBDClient *client,
|
|||
context_id = 0;
|
||||
}
|
||||
|
||||
trace_nbd_negotiate_meta_query_reply(context, context_id);
|
||||
set_be_option_rep(&opt.h, client->opt, NBD_REP_META_CONTEXT,
|
||||
sizeof(opt) - sizeof(opt.h) + iov[1].iov_len);
|
||||
stl_be_p(&opt.context_id, context_id);
|
||||
|
@ -752,10 +753,12 @@ static int nbd_meta_base_query(NBDClient *client, NBDExportMetaContexts *meta,
|
|||
if (client->opt == NBD_OPT_LIST_META_CONTEXT) {
|
||||
meta->base_allocation = true;
|
||||
}
|
||||
trace_nbd_negotiate_meta_query_parse("base:");
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (len != alen) {
|
||||
trace_nbd_negotiate_meta_query_skip("not base:allocation");
|
||||
return nbd_opt_skip(client, len, errp);
|
||||
}
|
||||
|
||||
|
@ -768,6 +771,7 @@ static int nbd_meta_base_query(NBDClient *client, NBDExportMetaContexts *meta,
|
|||
meta->base_allocation = true;
|
||||
}
|
||||
|
||||
trace_nbd_negotiate_meta_query_parse("base:allocation");
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -800,6 +804,7 @@ static int nbd_negotiate_meta_query(NBDClient *client,
|
|||
/* The only supported namespace for now is 'base'. So query should start
|
||||
* with 'base:'. Otherwise, we can ignore it and skip the remainder. */
|
||||
if (len < baselen) {
|
||||
trace_nbd_negotiate_meta_query_skip("length too short");
|
||||
return nbd_opt_skip(client, len, errp);
|
||||
}
|
||||
|
||||
|
@ -809,6 +814,7 @@ static int nbd_negotiate_meta_query(NBDClient *client,
|
|||
return ret;
|
||||
}
|
||||
if (strncmp(query, "base:", baselen) != 0) {
|
||||
trace_nbd_negotiate_meta_query_skip("not for base: namespace");
|
||||
return nbd_opt_skip(client, len, errp);
|
||||
}
|
||||
|
||||
|
@ -858,6 +864,8 @@ static int nbd_negotiate_meta_queries(NBDClient *client,
|
|||
return ret;
|
||||
}
|
||||
cpu_to_be32s(&nb_queries);
|
||||
trace_nbd_negotiate_meta_context(nbd_opt_lookup(client->opt),
|
||||
meta->export_name, nb_queries);
|
||||
|
||||
if (client->opt == NBD_OPT_LIST_META_CONTEXT && !nb_queries) {
|
||||
/* enable all known contexts */
|
||||
|
|
|
@ -10,6 +10,8 @@ nbd_receive_query_exports_start(const char *wantname) "Querying export list for
|
|||
nbd_receive_query_exports_success(const char *wantname) "Found desired export name '%s'"
|
||||
nbd_receive_starttls_new_client(void) "Setting up TLS"
|
||||
nbd_receive_starttls_tls_handshake(void) "Starting TLS handshake"
|
||||
nbd_opt_meta_request(const char *context, const char *export) "Requesting to set meta context %s for export %s"
|
||||
nbd_opt_meta_reply(const char *context, uint32_t id) "Received mapping of context %s to id %" PRIu32
|
||||
nbd_receive_negotiate(void *tlscreds, const char *hostname) "Receiving negotiation tlscreds=%p hostname=%s"
|
||||
nbd_receive_negotiate_magic(uint64_t magic) "Magic is 0x%" PRIx64
|
||||
nbd_receive_negotiate_server_flags(uint32_t globalflags) "Global flags are 0x%" PRIx32
|
||||
|
@ -44,6 +46,10 @@ nbd_negotiate_handle_info_request(int request, const char *name) "Client request
|
|||
nbd_negotiate_handle_info_block_size(uint32_t minimum, uint32_t preferred, uint32_t maximum) "advertising minimum 0x%" PRIx32 ", preferred 0x%" PRIx32 ", maximum 0x%" PRIx32
|
||||
nbd_negotiate_handle_starttls(void) "Setting up TLS"
|
||||
nbd_negotiate_handle_starttls_handshake(void) "Starting TLS handshake"
|
||||
nbd_negotiate_meta_context(const char *optname, const char *export, uint32_t queries) "Client requested %s for export %s, with %" PRIu32 " queries"
|
||||
nbd_negotiate_meta_query_skip(const char *reason) "Skipping meta query: %s"
|
||||
nbd_negotiate_meta_query_parse(const char *query) "Parsed meta query '%s'"
|
||||
nbd_negotiate_meta_query_reply(const char *context, uint32_t id) "Replying with meta context '%s' id %" PRIu32
|
||||
nbd_negotiate_options_flags(uint32_t flags) "Received client flags 0x%" PRIx32
|
||||
nbd_negotiate_options_check_magic(uint64_t magic) "Checking opts magic 0x%" PRIx64
|
||||
nbd_negotiate_options_check_option(uint32_t option, const char *name) "Checking option %" PRIu32 " (%s)"
|
||||
|
|
Loading…
Reference in New Issue