[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 21/28] nbd: make client request fixed new style if ad
From: |
Paolo Bonzini |
Subject: |
[Qemu-devel] [PULL 21/28] nbd: make client request fixed new style if advertised |
Date: |
Tue, 16 Feb 2016 17:34:39 +0100 |
From: "Daniel P. Berrange" <address@hidden>
If the server advertises support for the fixed new style
negotiation, the client should in turn enable new style.
This will allow the client to negotiate further NBD
options besides the export name.
Signed-off-by: Daniel P. Berrange <address@hidden>
Message-Id: <address@hidden>
Signed-off-by: Paolo Bonzini <address@hidden>
---
nbd/client.c | 27 +++++++++++++++++----------
1 file changed, 17 insertions(+), 10 deletions(-)
diff --git a/nbd/client.c b/nbd/client.c
index 5064788..88f2ada 100644
--- a/nbd/client.c
+++ b/nbd/client.c
@@ -76,7 +76,6 @@ int nbd_receive_negotiate(QIOChannel *ioc, const char *name,
uint32_t *flags,
{
char buf[256];
uint64_t magic, s;
- uint16_t tmp;
int rc;
TRACE("Receiving negotiation.");
@@ -117,19 +116,26 @@ int nbd_receive_negotiate(QIOChannel *ioc, const char
*name, uint32_t *flags,
TRACE("Magic is 0x%" PRIx64, magic);
if (magic == NBD_OPTS_MAGIC) {
- uint32_t reserved = 0;
+ uint32_t clientflags = 0;
uint32_t opt;
uint32_t namesize;
+ uint16_t globalflags;
+ uint16_t exportflags;
- if (read_sync(ioc, &tmp, sizeof(tmp)) != sizeof(tmp)) {
+ if (read_sync(ioc, &globalflags, sizeof(globalflags)) !=
+ sizeof(globalflags)) {
error_setg(errp, "Failed to read server flags");
goto fail;
}
- *flags = be16_to_cpu(tmp) << 16;
- /* reserved for future use */
- if (write_sync(ioc, &reserved, sizeof(reserved)) !=
- sizeof(reserved)) {
- error_setg(errp, "Failed to read reserved field");
+ *flags = be16_to_cpu(globalflags) << 16;
+ if (globalflags & NBD_FLAG_FIXED_NEWSTYLE) {
+ TRACE("Server supports fixed new style");
+ clientflags |= NBD_FLAG_C_FIXED_NEWSTYLE;
+ }
+ /* client requested flags */
+ if (write_sync(ioc, &clientflags, sizeof(clientflags)) !=
+ sizeof(clientflags)) {
+ error_setg(errp, "Failed to send clientflags field");
goto fail;
}
/* write the export name */
@@ -165,11 +171,12 @@ int nbd_receive_negotiate(QIOChannel *ioc, const char
*name, uint32_t *flags,
*size = be64_to_cpu(s);
TRACE("Size is %" PRIu64, *size);
- if (read_sync(ioc, &tmp, sizeof(tmp)) != sizeof(tmp)) {
+ if (read_sync(ioc, &exportflags, sizeof(exportflags)) !=
+ sizeof(exportflags)) {
error_setg(errp, "Failed to read export flags");
goto fail;
}
- *flags |= be16_to_cpu(tmp);
+ *flags |= be16_to_cpu(exportflags);
} else if (magic == NBD_CLIENT_MAGIC) {
if (name) {
error_setg(errp, "Server does not support export names");
--
2.5.0
- [Qemu-devel] [PULL 10/28] mptsas: fix memory leak, (continued)
- [Qemu-devel] [PULL 10/28] mptsas: fix memory leak, Paolo Bonzini, 2016/02/16
- [Qemu-devel] [PULL 11/28] mptsas: fix wrong formula, Paolo Bonzini, 2016/02/16
- [Qemu-devel] [PULL 09/28] mptsas: add missing va_end, Paolo Bonzini, 2016/02/16
- [Qemu-devel] [PULL 14/28] qemu-nbd: add support for --object command line arg, Paolo Bonzini, 2016/02/16
- [Qemu-devel] [PULL 16/28] nbd: convert qemu-nbd server to use I/O channels for connection setup, Paolo Bonzini, 2016/02/16
- [Qemu-devel] [PULL 13/28] qom: add helpers for UserCreatable object types, Paolo Bonzini, 2016/02/16
- [Qemu-devel] [PULL 15/28] nbd: convert block client to use I/O channels for connection setup, Paolo Bonzini, 2016/02/16
- [Qemu-devel] [PULL 17/28] nbd: convert blockdev NBD server to use I/O channels for connection setup, Paolo Bonzini, 2016/02/16
- [Qemu-devel] [PULL 19/28] nbd: invert client logic for negotiating protocol version, Paolo Bonzini, 2016/02/16
- [Qemu-devel] [PULL 20/28] nbd: make server compliant with fixed newstyle spec, Paolo Bonzini, 2016/02/16
- [Qemu-devel] [PULL 21/28] nbd: make client request fixed new style if advertised,
Paolo Bonzini <=
- [Qemu-devel] [PULL 23/28] nbd: always query export list in fixed new style protocol, Paolo Bonzini, 2016/02/16
- [Qemu-devel] [PULL 18/28] nbd: convert to using I/O channels for actual socket I/O, Paolo Bonzini, 2016/02/16
- [Qemu-devel] [PULL 24/28] nbd: use "" as a default export name if none provided, Paolo Bonzini, 2016/02/16
- [Qemu-devel] [PULL 22/28] nbd: allow setting of an export name for qemu-nbd server, Paolo Bonzini, 2016/02/16
- [Qemu-devel] [PULL 26/28] nbd: enable use of TLS with NBD block driver, Paolo Bonzini, 2016/02/16
- [Qemu-devel] [PULL 25/28] nbd: implement TLS support in the protocol negotiation, Paolo Bonzini, 2016/02/16
- [Qemu-devel] [PULL 27/28] nbd: enable use of TLS with qemu-nbd server, Paolo Bonzini, 2016/02/16
- [Qemu-devel] [PULL 28/28] nbd: enable use of TLS with nbd-server-start command, Paolo Bonzini, 2016/02/16
- Re: [Qemu-devel] [PULL 00/28] Bug fixes + NBD-over-TLS support patches for 2016-02-16, Peter Maydell, 2016/02/16