assert(!s->ioc);
- s->ioc = nbd_co_establish_connection(s->conn, &s->info, errp);
+ s->ioc = nbd_co_establish_connection(s->conn, &s->info, true, errp);
if (!s->ioc) {
return -ECONNREFUSED;
}
QIOChannel *coroutine_fn
nbd_co_establish_connection(NBDClientConnection *conn, NBDExportInfo *info,
- Error **errp);
+ bool blocking, Error **errp);
void coroutine_fn nbd_co_establish_connection_cancel(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
*/
QIOChannel *coroutine_fn
nbd_co_establish_connection(NBDClientConnection *conn, NBDExportInfo *info,
- Error **errp)
+ bool blocking, Error **errp)
{
QemuThread thread;
connect_thread_func, conn, QEMU_THREAD_DETACHED);
}
+ if (!blocking) {
+ return NULL;
+ }
+
conn->wait_co = qemu_coroutine_self();
}