From: Eric Blake <eblake@redhat.com>
To: qemu-devel@nongnu.org
Cc: Kevin Wolf <kwolf@redhat.com>,
Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>,
"open list:Network Block Dev..." <qemu-block@nongnu.org>,
Max Reitz <mreitz@redhat.com>
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 [thread overview]
Message-ID: <20190815183039.4264-6-eblake@redhat.com> (raw)
In-Reply-To: <20190815183039.4264-1-eblake@redhat.com>
From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
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 <vsementsov@virtuozzo.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Message-Id: <20190618114328.55249-2-vsementsov@virtuozzo.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
---
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
next prev parent reply other threads:[~2019-08-15 18:38 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-08-15 18:30 [Qemu-devel] [PULL 0/9] First batch of 4.2 NBD patches Eric Blake
2019-08-15 18:30 ` [Qemu-devel] [PULL 1/9] qapi: Add InetSocketAddress member keep-alive Eric Blake
2019-09-09 17:32 ` Peter Maydell
2019-09-10 7:56 ` Vladimir Sementsov-Ogievskiy
2019-09-10 8:10 ` Peter Maydell
2019-08-15 18:30 ` [Qemu-devel] [PULL 2/9] block: implement BDRV_REQ_PREFETCH Eric Blake
2019-08-15 18:30 ` [Qemu-devel] [PULL 3/9] block/stream: use BDRV_REQ_PREFETCH Eric Blake
2019-08-15 18:30 ` [Qemu-devel] [PULL 4/9] nbd: improve CMD_CACHE: " Eric Blake
2019-08-15 18:30 ` Eric Blake [this message]
2019-08-15 18:30 ` [Qemu-devel] [PULL 6/9] block/nbd: use non-blocking io channel for nbd negotiation Eric Blake
2019-08-15 18:30 ` [Qemu-devel] [PULL 7/9] block/nbd: move from quit to state Eric Blake
2019-08-15 18:30 ` [Qemu-devel] [PULL 8/9] block/nbd: add cmdline and qapi parameter reconnect-delay Eric Blake
2019-08-15 18:30 ` [Qemu-devel] [PULL 9/9] block/nbd: refactor nbd connection parameters Eric Blake
2019-08-16 15:43 ` [Qemu-devel] [PULL 0/9] First batch of 4.2 NBD patches Peter Maydell
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190815183039.4264-6-eblake@redhat.com \
--to=eblake@redhat.com \
--cc=kwolf@redhat.com \
--cc=mreitz@redhat.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=vsementsov@virtuozzo.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).