diff options
author | Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> | 2021-06-10 13:07:45 +0300 |
---|---|---|
committer | Eric Blake <eblake@redhat.com> | 2021-06-18 10:59:53 -0500 |
commit | f68729747da6b770e895fa88fedf7997666bc735 (patch) | |
tree | 02eb2feabd66a02d6c198d67fde3fbbfc6cf8879 | |
parent | 90ddc64fb2b9b1d698efc6d76026e76d5fe224ce (diff) | |
download | qemu-f68729747da6b770e895fa88fedf7997666bc735.zip qemu-f68729747da6b770e895fa88fedf7997666bc735.tar.gz qemu-f68729747da6b770e895fa88fedf7997666bc735.tar.bz2 |
block/nbd: introduce nbd_client_connection_new()
This is a step of creating bs-independent nbd connection interface.
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
Reviewed-by: Roman Kagan <rvkagan@yandex-team.ru>
Reviewed-by: Eric Blake <eblake@redhat.com>
Message-Id: <20210610100802.5888-16-vsementsov@virtuozzo.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
-rw-r--r-- | block/nbd.c | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/block/nbd.c b/block/nbd.c index ce8d38d..e7261ae 100644 --- a/block/nbd.c +++ b/block/nbd.c @@ -358,15 +358,18 @@ static bool nbd_client_connecting_wait(BDRVNBDState *s) return qatomic_load_acquire(&s->state) == NBD_CLIENT_CONNECTING_WAIT; } -static void nbd_init_connect_thread(BDRVNBDState *s) +static NBDClientConnection * +nbd_client_connection_new(const SocketAddress *saddr) { - s->conn = g_new(NBDClientConnection, 1); + NBDClientConnection *conn = g_new(NBDClientConnection, 1); - *s->conn = (NBDClientConnection) { - .saddr = QAPI_CLONE(SocketAddress, s->saddr), + *conn = (NBDClientConnection) { + .saddr = QAPI_CLONE(SocketAddress, saddr), }; - qemu_mutex_init(&s->conn->mutex); + qemu_mutex_init(&conn->mutex); + + return conn; } static void nbd_free_connect_thread(NBDClientConnection *conn) @@ -2230,7 +2233,7 @@ static int nbd_open(BlockDriverState *bs, QDict *options, int flags, goto fail; } - nbd_init_connect_thread(s); + s->conn = nbd_client_connection_new(s->saddr); /* * establish TCP connection, return error if it fails |