[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v2 1/6] nbd/server: nbd_negotiate: return 1 on NBD_O
From: |
Vladimir Sementsov-Ogievskiy |
Subject: |
[Qemu-devel] [PATCH v2 1/6] nbd/server: nbd_negotiate: return 1 on NBD_OPT_ABORT |
Date: |
Wed, 21 Jun 2017 18:34:19 +0300 |
Separate case when client sent NBD_OPT_ABORT from other errors.
It will be needed for the following patch, where errors will be
reported.
Considered case is not actually the error - it honestly follows NBD
protocol. Therefore it should not be reported like an error.
Signed-off-by: Vladimir Sementsov-Ogievskiy <address@hidden>
---
nbd/server.c | 20 +++++++++++++++-----
1 file changed, 15 insertions(+), 5 deletions(-)
diff --git a/nbd/server.c b/nbd/server.c
index 8a70c054a6..f0bff23b8b 100644
--- a/nbd/server.c
+++ b/nbd/server.c
@@ -349,9 +349,13 @@ static QIOChannel *nbd_negotiate_handle_starttls(NBDClient
*client,
return QIO_CHANNEL(tioc);
}
-
-/* Process all NBD_OPT_* client option commands.
- * Return -errno on error, 0 on success. */
+/* nbd_negotiate_options
+ * Process all NBD_OPT_* client option commands.
+ * Return:
+ * -errno on error
+ * 0 on successful negotiation
+ * 1 if client sent NBD_OPT_ABORT, i.e. on legal disconnect
+ */
static int nbd_negotiate_options(NBDClient *client)
{
uint32_t flags;
@@ -459,7 +463,7 @@ static int nbd_negotiate_options(NBDClient *client)
}
/* Let the client keep trying, unless they asked to quit */
if (clientflags == NBD_OPT_ABORT) {
- return -EINVAL;
+ return 1;
}
break;
}
@@ -477,7 +481,7 @@ static int nbd_negotiate_options(NBDClient *client)
* disconnecting, but that we must also tolerate
* guests that don't wait for our reply. */
nbd_negotiate_send_rep(client->ioc, NBD_REP_ACK, clientflags);
- return -EINVAL;
+ return 1;
case NBD_OPT_EXPORT_NAME:
return nbd_negotiate_handle_export_name(client, length);
@@ -533,6 +537,12 @@ static int nbd_negotiate_options(NBDClient *client)
}
}
+/* nbd_negotiate
+ * Return:
+ * -errno on error
+ * 0 on successful negotiation
+ * 1 if client sent NBD_OPT_ABORT, i.e. on legal disconnect
+ */
static coroutine_fn int nbd_negotiate(NBDClient *client)
{
char buf[8 + 8 + 8 + 128];
--
2.11.1
- [Qemu-devel] [PATCH v2 0/6] nbd refactoring part 2, Vladimir Sementsov-Ogievskiy, 2017/06/21
- [Qemu-devel] [PATCH v2 5/6] nbd/client: refactor TRACE of NBD_MAGIC, Vladimir Sementsov-Ogievskiy, 2017/06/21
- [Qemu-devel] [PATCH v2 4/6] nbd/common: nbd_tls_handshake: remove extra TRACE, Vladimir Sementsov-Ogievskiy, 2017/06/21
- [Qemu-devel] [PATCH v2 2/6] nbd/server: use errp instead of LOG, Vladimir Sementsov-Ogievskiy, 2017/06/21
- [Qemu-devel] [PATCH v2 6/6] nbd: use generic trace subsystem instead of TRACE macro, Vladimir Sementsov-Ogievskiy, 2017/06/21
- [Qemu-devel] [PATCH v2 1/6] nbd/server: nbd_negotiate: return 1 on NBD_OPT_ABORT,
Vladimir Sementsov-Ogievskiy <=
- [Qemu-devel] [PATCH v2 3/6] nbd/server: add errp to nbd_send_reply(), Vladimir Sementsov-Ogievskiy, 2017/06/21