summaryrefslogtreecommitdiffstats
path: root/block
diff options
context:
space:
mode:
authorVladimir Sementsov-Ogievskiy2019-02-01 14:01:35 +0100
committerEric Blake2019-02-04 22:11:27 +0100
commitb0e4b5a58fde6c0ed9edb9b683cfbbd8ab45c35d (patch)
tree4d5cb117b1e05c7901e95293acdb7fa4e2b4a2c9 /block
parentblock/nbd: move connection code from block/nbd to block/nbd-client (diff)
downloadqemu-b0e4b5a58fde6c0ed9edb9b683cfbbd8ab45c35d.tar.gz
qemu-b0e4b5a58fde6c0ed9edb9b683cfbbd8ab45c35d.tar.xz
qemu-b0e4b5a58fde6c0ed9edb9b683cfbbd8ab45c35d.zip
block/nbd-client: split connection from initialization
Split connection code to reuse it for reconnect. Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> Reviewed-by: Eric Blake <eblake@redhat.com> Message-Id: <20190201130138.94525-4-vsementsov@virtuozzo.com> Signed-off-by: Eric Blake <eblake@redhat.com>
Diffstat (limited to 'block')
-rw-r--r--block/nbd-client.c33
1 files changed, 24 insertions, 9 deletions
diff --git a/block/nbd-client.c b/block/nbd-client.c
index 80dc8cff47..d7d8829769 100644
--- a/block/nbd-client.c
+++ b/block/nbd-client.c
@@ -1012,13 +1012,13 @@ static QIOChannelSocket *nbd_establish_connection(SocketAddress *saddr,
return sioc;
}
-int nbd_client_init(BlockDriverState *bs,
- SocketAddress *saddr,
- const char *export,
- QCryptoTLSCreds *tlscreds,
- const char *hostname,
- const char *x_dirty_bitmap,
- Error **errp)
+static int nbd_client_connect(BlockDriverState *bs,
+ SocketAddress *saddr,
+ const char *export,
+ QCryptoTLSCreds *tlscreds,
+ const char *hostname,
+ const char *x_dirty_bitmap,
+ Error **errp)
{
NBDClientSession *client = nbd_get_client_session(bs);
int ret;
@@ -1071,8 +1071,6 @@ int nbd_client_init(BlockDriverState *bs,
bs->supported_zero_flags |= BDRV_REQ_MAY_UNMAP;
}
- qemu_co_mutex_init(&client->send_mutex);
- qemu_co_queue_init(&client->free_sema);
client->sioc = sioc;
if (!client->ioc) {
@@ -1105,3 +1103,20 @@ int nbd_client_init(BlockDriverState *bs,
return ret;
}
}
+
+int nbd_client_init(BlockDriverState *bs,
+ SocketAddress *saddr,
+ const char *export,
+ QCryptoTLSCreds *tlscreds,
+ const char *hostname,
+ const char *x_dirty_bitmap,
+ Error **errp)
+{
+ NBDClientSession *client = nbd_get_client_session(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);
+}