From 297365b40ff24c7e07d6f40ec8f9ac83229ace94 Mon Sep 17 00:00:00 2001 From: Eric Blake Date: Tue, 29 Aug 2023 12:58:29 -0500 Subject: nbd/client: Pass mode through to nbd_send_request Once the 64-bit headers extension is enabled, the data layout we send over the wire for a client request depends on the mode negotiated with the server. Rather than adding a parameter to nbd_send_request, we can add a member to struct NBDRequest, since it already does not reflect on-wire format. Some callers initialize it directly; many others rely on a common initialization point during nbd_co_send_request(). At this point, there is no semantic change. Signed-off-by: Eric Blake Reviewed-by: Vladimir Sementsov-Ogievskiy Message-ID: <20230829175826.377251-21-eblake@redhat.com> --- nbd/client.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'nbd') diff --git a/nbd/client.c b/nbd/client.c index 844be42..345f1c0 100644 --- a/nbd/client.c +++ b/nbd/client.c @@ -1218,7 +1218,7 @@ int nbd_receive_export_list(QIOChannel *ioc, QCryptoTLSCreds *tlscreds, /* Send NBD_CMD_DISC as a courtesy to the server, but ignore all * errors now that we have the information we wanted. */ if (nbd_drop(ioc, 124, NULL) == 0) { - NBDRequest request = { .type = NBD_CMD_DISC }; + NBDRequest request = { .type = NBD_CMD_DISC, .mode = result }; nbd_send_request(ioc, &request); } @@ -1348,6 +1348,7 @@ int nbd_send_request(QIOChannel *ioc, NBDRequest *request) { uint8_t buf[NBD_REQUEST_SIZE]; + assert(request->mode <= NBD_MODE_STRUCTURED); /* TODO handle extended */ trace_nbd_send_request(request->from, request->len, request->cookie, request->flags, request->type, nbd_cmd_lookup(request->type)); -- cgit v1.1