From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
To: qemu-devel@nongnu.org, qemu-block@nongnu.org
Cc: armbru@redhat.com, stefanha@redhat.com, mreitz@redhat.com,
kwolf@redhat.com, eblake@redhat.com, vsementsov@virtuozzo.com,
den@openvz.org
Subject: [Qemu-devel] [PATCH v6 1/7] block/nbd-client: split connection_co start out of nbd_client_connect
Date: Thu, 11 Apr 2019 20:27:03 +0300 [thread overview]
Message-ID: <20190411172709.205032-2-vsementsov@virtuozzo.com> (raw)
In-Reply-To: <20190411172709.205032-1-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>
---
block/nbd-client.c | 20 +++++++++++++-------
1 file changed, 13 insertions(+), 7 deletions(-)
diff --git a/block/nbd-client.c b/block/nbd-client.c
index 790ecc1ee1..facf8f8099 100644
--- a/block/nbd-client.c
+++ b/block/nbd-client.c
@@ -1180,12 +1180,8 @@ static int nbd_client_connect(BlockDriverState *bs,
object_ref(OBJECT(client->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);
- client->connection_co = qemu_coroutine_create(nbd_connection_entry, client);
- bdrv_inc_in_flight(bs);
- nbd_client_attach_aio_context(bs, bdrv_get_aio_context(bs));
+ qio_channel_attach_aio_context(client->ioc, bdrv_get_aio_context(bs));
logout("Established connection with NBD server\n");
return 0;
@@ -1215,12 +1211,22 @@ int nbd_client_init(BlockDriverState *bs,
const char *x_dirty_bitmap,
Error **errp)
{
+ int ret;
NBDClientSession *client = nbd_get_client_session(bs);
client->bs = bs;
qemu_co_mutex_init(&client->send_mutex);
qemu_co_queue_init(&client->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;
+ }
+
+ client->connection_co = qemu_coroutine_create(nbd_connection_entry, client);
+ bdrv_inc_in_flight(bs);
+ aio_co_schedule(bdrv_get_aio_context(bs), client->connection_co);
+
+ return 0;
}
--
2.18.0
WARNING: multiple messages have this Message-ID (diff)
From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
To: qemu-devel@nongnu.org, qemu-block@nongnu.org
Cc: kwolf@redhat.com, vsementsov@virtuozzo.com, armbru@redhat.com,
mreitz@redhat.com, stefanha@redhat.com, den@openvz.org
Subject: [Qemu-devel] [PATCH v6 1/7] block/nbd-client: split connection_co start out of nbd_client_connect
Date: Thu, 11 Apr 2019 20:27:03 +0300 [thread overview]
Message-ID: <20190411172709.205032-2-vsementsov@virtuozzo.com> (raw)
Message-ID: <20190411172703.ZNhIGJgBn_JzB4XU7VnHcHdQqEMRD5BEthyhneyv440@z> (raw)
In-Reply-To: <20190411172709.205032-1-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>
---
block/nbd-client.c | 20 +++++++++++++-------
1 file changed, 13 insertions(+), 7 deletions(-)
diff --git a/block/nbd-client.c b/block/nbd-client.c
index 790ecc1ee1..facf8f8099 100644
--- a/block/nbd-client.c
+++ b/block/nbd-client.c
@@ -1180,12 +1180,8 @@ static int nbd_client_connect(BlockDriverState *bs,
object_ref(OBJECT(client->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);
- client->connection_co = qemu_coroutine_create(nbd_connection_entry, client);
- bdrv_inc_in_flight(bs);
- nbd_client_attach_aio_context(bs, bdrv_get_aio_context(bs));
+ qio_channel_attach_aio_context(client->ioc, bdrv_get_aio_context(bs));
logout("Established connection with NBD server\n");
return 0;
@@ -1215,12 +1211,22 @@ int nbd_client_init(BlockDriverState *bs,
const char *x_dirty_bitmap,
Error **errp)
{
+ int ret;
NBDClientSession *client = nbd_get_client_session(bs);
client->bs = bs;
qemu_co_mutex_init(&client->send_mutex);
qemu_co_queue_init(&client->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;
+ }
+
+ client->connection_co = qemu_coroutine_create(nbd_connection_entry, client);
+ bdrv_inc_in_flight(bs);
+ aio_co_schedule(bdrv_get_aio_context(bs), client->connection_co);
+
+ return 0;
}
--
2.18.0
next prev parent reply other threads:[~2019-04-11 17:27 UTC|newest]
Thread overview: 43+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-04-11 17:27 [Qemu-devel] [PATCH v6 0/7] NBD reconnect Vladimir Sementsov-Ogievskiy
2019-04-11 17:27 ` Vladimir Sementsov-Ogievskiy
2019-04-11 17:27 ` Vladimir Sementsov-Ogievskiy [this message]
2019-04-11 17:27 ` [Qemu-devel] [PATCH v6 1/7] block/nbd-client: split connection_co start out of nbd_client_connect Vladimir Sementsov-Ogievskiy
2019-06-07 2:32 ` Eric Blake
2019-04-11 17:27 ` [Qemu-devel] [PATCH v6 2/7] block/nbd-client: use non-blocking io channel for nbd negotiation Vladimir Sementsov-Ogievskiy
2019-04-11 17:27 ` Vladimir Sementsov-Ogievskiy
2019-06-07 2:34 ` Eric Blake
2019-04-11 17:27 ` [Qemu-devel] [PATCH v6 3/7] block/nbd-client: move from quit to state Vladimir Sementsov-Ogievskiy
2019-04-11 17:27 ` Vladimir Sementsov-Ogievskiy
2019-06-07 2:38 ` Eric Blake
2019-04-11 17:27 ` [Qemu-devel] [PATCH v6 4/7] block/nbd: add cmdline and qapi parameter reconnect-delay Vladimir Sementsov-Ogievskiy
2019-04-11 17:27 ` Vladimir Sementsov-Ogievskiy
2019-06-07 2:43 ` Eric Blake
2019-04-11 17:27 ` [Qemu-devel] [PATCH v6 5/7] qemu-coroutine-sleep: introduce qemu_co_sleep_wake Vladimir Sementsov-Ogievskiy
2019-04-11 17:27 ` Vladimir Sementsov-Ogievskiy
2019-06-07 2:48 ` Eric Blake
2019-06-07 7:57 ` Kevin Wolf
2019-06-07 11:18 ` Vladimir Sementsov-Ogievskiy
2019-06-07 13:02 ` Kevin Wolf
2019-06-07 15:01 ` Vladimir Sementsov-Ogievskiy
2019-06-07 15:52 ` Vladimir Sementsov-Ogievskiy
2019-06-07 17:10 ` Vladimir Sementsov-Ogievskiy
2019-06-11 8:53 ` Kevin Wolf
2019-06-11 10:28 ` Vladimir Sementsov-Ogievskiy
2019-04-11 17:27 ` [Qemu-devel] [PATCH v6 6/7] block/nbd-client: nbd reconnect Vladimir Sementsov-Ogievskiy
2019-04-11 17:27 ` Vladimir Sementsov-Ogievskiy
2019-06-07 3:17 ` Eric Blake
2019-06-07 8:06 ` Kevin Wolf
2019-06-07 12:02 ` Vladimir Sementsov-Ogievskiy
2019-06-07 13:26 ` Kevin Wolf
2019-06-07 14:27 ` Vladimir Sementsov-Ogievskiy
2019-06-07 14:54 ` Kevin Wolf
2019-06-07 11:44 ` Vladimir Sementsov-Ogievskiy
2019-06-10 12:38 ` Vladimir Sementsov-Ogievskiy
2019-06-10 13:29 ` Vladimir Sementsov-Ogievskiy
2019-06-10 14:33 ` Eric Blake
2019-04-11 17:27 ` [Qemu-devel] [PATCH v6 7/7] iotests: test " Vladimir Sementsov-Ogievskiy
2019-04-11 17:27 ` Vladimir Sementsov-Ogievskiy
2019-04-30 17:50 ` [Qemu-devel] [PATCH v6 0/7] NBD reconnect Vladimir Sementsov-Ogievskiy
2019-04-30 17:50 ` Vladimir Sementsov-Ogievskiy
2019-05-15 9:03 ` [Qemu-devel] ping " Vladimir Sementsov-Ogievskiy
2019-06-04 12:42 ` Vladimir Sementsov-Ogievskiy
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=20190411172709.205032-2-vsementsov@virtuozzo.com \
--to=vsementsov@virtuozzo.com \
--cc=armbru@redhat.com \
--cc=den@openvz.org \
--cc=eblake@redhat.com \
--cc=kwolf@redhat.com \
--cc=mreitz@redhat.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=stefanha@redhat.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).