aboutsummaryrefslogtreecommitdiff
path: root/nbd/client.c
diff options
context:
space:
mode:
authorVladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>2019-06-18 14:43:21 +0300
committerEric Blake <eblake@redhat.com>2019-08-15 13:22:14 -0500
commita8e2bb6a76c7c661c117327f70f06eb628554230 (patch)
tree6ea29153f1608699a6014101e3e9c10e353dc66d /nbd/client.c
parent962b7b3d4c3aed241ec28ea712ec9079ac98d3ad (diff)
downloadqemu-a8e2bb6a76c7c661c117327f70f06eb628554230.zip
qemu-a8e2bb6a76c7c661c117327f70f06eb628554230.tar.gz
qemu-a8e2bb6a76c7c661c117327f70f06eb628554230.tar.bz2
block/nbd: use non-blocking io channel for nbd negotiation
No reason to use blocking channel for negotiation and we'll benefit in further reconnect feature, as qio_channel reads and writes will do qemu_coroutine_yield while waiting for io completion. Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> Reviewed-by: Eric Blake <eblake@redhat.com> Message-Id: <20190618114328.55249-3-vsementsov@virtuozzo.com> Signed-off-by: Eric Blake <eblake@redhat.com>
Diffstat (limited to 'nbd/client.c')
-rw-r--r--nbd/client.c16
1 files changed, 11 insertions, 5 deletions
diff --git a/nbd/client.c b/nbd/client.c
index 4de3063..8f524c3 100644
--- a/nbd/client.c
+++ b/nbd/client.c
@@ -867,7 +867,8 @@ static int nbd_list_meta_contexts(QIOChannel *ioc,
* 2: server is newstyle, but lacks structured replies
* 3: server is newstyle and set up for structured replies
*/
-static int nbd_start_negotiate(QIOChannel *ioc, QCryptoTLSCreds *tlscreds,
+static int nbd_start_negotiate(AioContext *aio_context, QIOChannel *ioc,
+ QCryptoTLSCreds *tlscreds,
const char *hostname, QIOChannel **outioc,
bool structured_reply, bool *zeroes,
Error **errp)
@@ -934,6 +935,10 @@ static int nbd_start_negotiate(QIOChannel *ioc, QCryptoTLSCreds *tlscreds,
return -EINVAL;
}
ioc = *outioc;
+ if (aio_context) {
+ qio_channel_set_blocking(ioc, false, NULL);
+ qio_channel_attach_aio_context(ioc, aio_context);
+ }
} else {
error_setg(errp, "Server does not support STARTTLS");
return -EINVAL;
@@ -998,7 +1003,8 @@ static int nbd_negotiate_finish_oldstyle(QIOChannel *ioc, NBDExportInfo *info,
* Returns: negative errno: failure talking to server
* 0: server is connected
*/
-int nbd_receive_negotiate(QIOChannel *ioc, QCryptoTLSCreds *tlscreds,
+int nbd_receive_negotiate(AioContext *aio_context, QIOChannel *ioc,
+ QCryptoTLSCreds *tlscreds,
const char *hostname, QIOChannel **outioc,
NBDExportInfo *info, Error **errp)
{
@@ -1009,7 +1015,7 @@ int nbd_receive_negotiate(QIOChannel *ioc, QCryptoTLSCreds *tlscreds,
assert(info->name);
trace_nbd_receive_negotiate_name(info->name);
- result = nbd_start_negotiate(ioc, tlscreds, hostname, outioc,
+ result = nbd_start_negotiate(aio_context, ioc, tlscreds, hostname, outioc,
info->structured_reply, &zeroes, errp);
info->structured_reply = false;
@@ -1129,8 +1135,8 @@ int nbd_receive_export_list(QIOChannel *ioc, QCryptoTLSCreds *tlscreds,
QIOChannel *sioc = NULL;
*info = NULL;
- result = nbd_start_negotiate(ioc, tlscreds, hostname, &sioc, true, NULL,
- errp);
+ result = nbd_start_negotiate(NULL, ioc, tlscreds, hostname, &sioc, true,
+ NULL, errp);
if (tlscreds && sioc) {
ioc = sioc;
}