mirror of
https://github.com/qemu/qemu.git
synced 2024-11-29 23:03:41 +08:00
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>
This commit is contained in:
parent
d42f78e940
commit
b0e4b5a58f
@ -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);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user