aboutsummaryrefslogtreecommitdiff
path: root/nbd/client.c
diff options
context:
space:
mode:
authorPeter Maydell <peter.maydell@linaro.org>2019-08-16 15:53:37 +0100
committerPeter Maydell <peter.maydell@linaro.org>2019-08-16 15:53:37 +0100
commitc6a2225a5a5e272edc0304845e32ea436ea1043a (patch)
tree4bd7a214066714ef048ac30b4dedd5b8f6b31458 /nbd/client.c
parent95a9457fd44ad97c518858a4e1586a5498f9773c (diff)
parent8f071c9db506e03abcb1b76ec6d3d2f9488cc3b3 (diff)
Merge remote-tracking branch 'remotes/ericb/tags/pull-nbd-2019-08-15' into staging
nbd patches for 2019-08-15 - Addition of InetSocketAddress keep-alive - Addition of BDRV_REQ_PREFETCH for more efficient copy-on-read - Initial refactoring in preparation of NBD reconnect # gpg: Signature made Thu 15 Aug 2019 19:28:41 BST # gpg: using RSA key A7A16B4A2527436A # gpg: Good signature from "Eric Blake <eblake@redhat.com>" [full] # gpg: aka "Eric Blake (Free Software Programmer) <ebb9@byu.net>" [full] # gpg: aka "[jpeg image of size 6874]" [full] # Primary key fingerprint: 71C2 CC22 B1C4 6029 27D2 F3AA A7A1 6B4A 2527 436A * remotes/ericb/tags/pull-nbd-2019-08-15: block/nbd: refactor nbd connection parameters block/nbd: add cmdline and qapi parameter reconnect-delay block/nbd: move from quit to state block/nbd: use non-blocking io channel for nbd negotiation block/nbd: split connection_co start out of nbd_client_connect nbd: improve CMD_CACHE: use BDRV_REQ_PREFETCH block/stream: use BDRV_REQ_PREFETCH block: implement BDRV_REQ_PREFETCH qapi: Add InetSocketAddress member keep-alive Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
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 d554ae353d..49bf9906f9 100644
--- a/nbd/client.c
+++ b/nbd/client.c
@@ -868,7 +868,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)
@@ -935,6 +936,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;
@@ -999,7 +1004,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)
{
@@ -1010,7 +1016,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;
@@ -1130,8 +1136,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;
}