summaryrefslogtreecommitdiffstats
path: root/nbd
diff options
context:
space:
mode:
authorVladimir Sementsov-Ogievskiy2021-06-10 12:07:59 +0200
committerEric Blake2021-06-18 19:21:22 +0200
commit97cf89259e4e0455c3b2742911737de5969dc0de (patch)
tree7c228cf801d332fe1a9ce6351b9c34db56c0bdc2 /nbd
parentblock/nbd: split nbd_co_do_establish_connection out of nbd_reconnect_attempt (diff)
downloadqemu-97cf89259e4e0455c3b2742911737de5969dc0de.tar.gz
qemu-97cf89259e4e0455c3b2742911737de5969dc0de.tar.xz
qemu-97cf89259e4e0455c3b2742911737de5969dc0de.zip
nbd/client-connection: add option for non-blocking connection attempt
We'll need a possibility of non-blocking nbd_co_establish_connection(), so that it returns immediately, and it returns success only if a connections was previously established in background. Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> Reviewed-by: Eric Blake <eblake@redhat.com> Message-Id: <20210610100802.5888-30-vsementsov@virtuozzo.com> Signed-off-by: Eric Blake <eblake@redhat.com>
Diffstat (limited to 'nbd')
-rw-r--r--nbd/client-connection.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/nbd/client-connection.c b/nbd/client-connection.c
index 955edafb7c..7123b1e189 100644
--- a/nbd/client-connection.c
+++ b/nbd/client-connection.c
@@ -266,6 +266,8 @@ void nbd_client_connection_release(NBDClientConnection *conn)
* otherwise the thread is not running, so start a thread and wait for
* completion
*
+ * If @blocking is false, don't wait for the thread, return immediately.
+ *
* If @info is not NULL, also do nbd-negotiation after successful connection.
* In this case info is used only as out parameter, and is fully initialized by
* nbd_co_establish_connection(). "IN" fields of info as well as related only to
@@ -274,7 +276,7 @@ void nbd_client_connection_release(NBDClientConnection *conn)
*/
QIOChannel *coroutine_fn
nbd_co_establish_connection(NBDClientConnection *conn, NBDExportInfo *info,
- Error **errp)
+ bool blocking, Error **errp)
{
QemuThread thread;
@@ -315,6 +317,10 @@ nbd_co_establish_connection(NBDClientConnection *conn, NBDExportInfo *info,
connect_thread_func, conn, QEMU_THREAD_DETACHED);
}
+ if (!blocking) {
+ return NULL;
+ }
+
conn->wait_co = qemu_coroutine_self();
}