aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>2017-07-07 18:29:09 +0300
committerEric Blake <eblake@redhat.com>2017-07-10 09:57:24 -0500
commit1e120ffead85d08d41160065e0d8cf86400b1c9e (patch)
treefe44c8769b0005c8c3ea3a14ca90ea56dd4a5d2c
parent99c62e70aaa9a3ad843ab1a58129104f83f366db (diff)
downloadqemu-1e120ffead85d08d41160065e0d8cf86400b1c9e.zip
qemu-1e120ffead85d08d41160065e0d8cf86400b1c9e.tar.gz
qemu-1e120ffead85d08d41160065e0d8cf86400b1c9e.tar.bz2
nbd/server: nbd_negotiate: return 1 on NBD_OPT_ABORT
Separate the case when a client sends NBD_OPT_ABORT from all other errors. It will be needed for the following patch, where errors will be reported. This particular case is not actually an error - it honestly follows the NBD protocol. Therefore it should not be reported like an error. Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> Reviewed-by: Eric Blake <eblake@redhat.com> Message-Id: <20170707152918.23086-2-vsementsov@virtuozzo.com> Signed-off-by: Eric Blake <eblake@redhat.com>
-rw-r--r--nbd/server.c20
1 files changed, 15 insertions, 5 deletions
diff --git a/nbd/server.c b/nbd/server.c
index 8a70c05..3963972 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 valid 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 valid disconnect
+ */
static coroutine_fn int nbd_negotiate(NBDClient *client)
{
char buf[8 + 8 + 8 + 128];