[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-block] [PATCH 09/15] nbd: make client request fixed new style if a
From: |
Daniel P. Berrange |
Subject: |
[Qemu-block] [PATCH 09/15] nbd: make client request fixed new style if advertized |
Date: |
Fri, 27 Nov 2015 12:20:47 +0000 |
If the server advertizes 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>
---
nbd.c | 27 +++++++++++++++++----------
1 file changed, 17 insertions(+), 10 deletions(-)
diff --git a/nbd.c b/nbd.c
index 09a32a9..6ec04a7 100644
--- a/nbd.c
+++ b/nbd.c
@@ -664,7 +664,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.");
@@ -705,19 +704,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 */
@@ -753,11 +759,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-block] [PATCH 00/15] Implement TLS support to QEMU NBD server & client, Daniel P. Berrange, 2015/11/27
- [Qemu-block] [PATCH 01/15] qom: add user_creatable_add & user_creatable_del methods, Daniel P. Berrange, 2015/11/27
- [Qemu-block] [PATCH 03/15] nbd: convert block client to use I/O channels for connection setup, Daniel P. Berrange, 2015/11/27
- [Qemu-block] [PATCH 04/15] nbd: convert qemu-nbd server to use I/O channels for connection setup, Daniel P. Berrange, 2015/11/27
- [Qemu-block] [PATCH 05/15] nbd: convert blockdev NBD server to use I/O channels for connection setup, Daniel P. Berrange, 2015/11/27
- [Qemu-block] [PATCH 02/15] qemu-nbd: add support for --object command line arg, Daniel P. Berrange, 2015/11/27
- [Qemu-block] [PATCH 07/15] nbd: invert client logic for negotiating protocol version, Daniel P. Berrange, 2015/11/27
- [Qemu-block] [PATCH 06/15] nbd: convert to using I/O channels for actual socket I/O, Daniel P. Berrange, 2015/11/27
- [Qemu-block] [PATCH 08/15] nbd: make server compliant with fixed newstyle spec, Daniel P. Berrange, 2015/11/27
- [Qemu-block] [PATCH 09/15] nbd: make client request fixed new style if advertized,
Daniel P. Berrange <=
- [Qemu-block] [PATCH 11/15] nbd: pick first exported volume if no export name is requested, Daniel P. Berrange, 2015/11/27
- [Qemu-block] [PATCH 10/15] nbd: allow setting of an export name for qemu-nbd server, Daniel P. Berrange, 2015/11/27
- [Qemu-block] [PATCH 13/15] nbd: enable use of TLS with NBD block driver, Daniel P. Berrange, 2015/11/27
- [Qemu-block] [PATCH 12/15] nbd: implement TLS support in the protocol negotiation, Daniel P. Berrange, 2015/11/27
- [Qemu-block] [PATCH 14/15] nbd: enable use of TLS with qemu-nbd server, Daniel P. Berrange, 2015/11/27
- [Qemu-block] [PATCH 15/15] nbd: enable use of TLS with nbd-server-start command, Daniel P. Berrange, 2015/11/27
- Re: [Qemu-block] [PATCH 00/15] Implement TLS support to QEMU NBD server & client, Wouter Verhelst, 2015/11/27