mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-04 00:03:54 -06:00
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>
This commit is contained in:
parent
962b7b3d4c
commit
a8e2bb6a76
4 changed files with 21 additions and 16 deletions
16
nbd/client.c
16
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;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue