[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 5/9] block/nbd: split connection_co start out of nbd_
From: |
Eric Blake |
Subject: |
[Qemu-devel] [PULL 5/9] block/nbd: split connection_co start out of nbd_client_connect |
Date: |
Thu, 15 Aug 2019 13:30:35 -0500 |
From: Vladimir Sementsov-Ogievskiy <address@hidden>
nbd_client_connect is going to be used from connection_co, so, let's
refactor nbd_client_connect in advance, leaving io channel
configuration all in nbd_client_connect.
Signed-off-by: Vladimir Sementsov-Ogievskiy <address@hidden>
Reviewed-by: Eric Blake <address@hidden>
Message-Id: <address@hidden>
Signed-off-by: Eric Blake <address@hidden>
---
block/nbd.c | 22 +++++++++++++---------
1 file changed, 13 insertions(+), 9 deletions(-)
diff --git a/block/nbd.c b/block/nbd.c
index 57c1a205811a..c16d02528b2f 100644
--- a/block/nbd.c
+++ b/block/nbd.c
@@ -1231,14 +1231,8 @@ static int nbd_client_connect(BlockDriverState *bs,
object_ref(OBJECT(s->ioc));
}
- /*
- * Now that we're connected, set the socket to be non-blocking and
- * kick the reply mechanism.
- */
qio_channel_set_blocking(QIO_CHANNEL(sioc), false, NULL);
- s->connection_co = qemu_coroutine_create(nbd_connection_entry, s);
- bdrv_inc_in_flight(bs);
- nbd_client_attach_aio_context(bs, bdrv_get_aio_context(bs));
+ qio_channel_attach_aio_context(s->ioc, bdrv_get_aio_context(bs));
trace_nbd_client_connect_success(export);
@@ -1269,14 +1263,24 @@ static int nbd_client_init(BlockDriverState *bs,
const char *x_dirty_bitmap,
Error **errp)
{
+ int ret;
BDRVNBDState *s = (BDRVNBDState *)bs->opaque;
s->bs = bs;
qemu_co_mutex_init(&s->send_mutex);
qemu_co_queue_init(&s->free_sema);
- return nbd_client_connect(bs, saddr, export, tlscreds, hostname,
- x_dirty_bitmap, errp);
+ ret = nbd_client_connect(bs, saddr, export, tlscreds, hostname,
+ x_dirty_bitmap, errp);
+ if (ret < 0) {
+ return ret;
+ }
+
+ s->connection_co = qemu_coroutine_create(nbd_connection_entry, s);
+ bdrv_inc_in_flight(bs);
+ aio_co_schedule(bdrv_get_aio_context(bs), s->connection_co);
+
+ return 0;
}
static int nbd_parse_uri(const char *filename, QDict *options)
--
2.20.1
- [Qemu-devel] [PULL 0/9] First batch of 4.2 NBD patches, Eric Blake, 2019/08/15
- [Qemu-devel] [PULL 1/9] qapi: Add InetSocketAddress member keep-alive, Eric Blake, 2019/08/15
- [Qemu-devel] [PULL 7/9] block/nbd: move from quit to state, Eric Blake, 2019/08/15
- [Qemu-devel] [PULL 8/9] block/nbd: add cmdline and qapi parameter reconnect-delay, Eric Blake, 2019/08/15
- [Qemu-devel] [PULL 6/9] block/nbd: use non-blocking io channel for nbd negotiation, Eric Blake, 2019/08/15
- [Qemu-devel] [PULL 2/9] block: implement BDRV_REQ_PREFETCH, Eric Blake, 2019/08/15
- [Qemu-devel] [PULL 3/9] block/stream: use BDRV_REQ_PREFETCH, Eric Blake, 2019/08/15
- [Qemu-devel] [PULL 4/9] nbd: improve CMD_CACHE: use BDRV_REQ_PREFETCH, Eric Blake, 2019/08/15
- [Qemu-devel] [PULL 5/9] block/nbd: split connection_co start out of nbd_client_connect,
Eric Blake <=
- [Qemu-devel] [PULL 9/9] block/nbd: refactor nbd connection parameters, Eric Blake, 2019/08/15
- Re: [Qemu-devel] [PULL 0/9] First batch of 4.2 NBD patches, Peter Maydell, 2019/08/16