[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 17/34] block/nbd: introduce nbd_client_connection_new()
From: |
Eric Blake |
Subject: |
[PULL 17/34] block/nbd: introduce nbd_client_connection_new() |
Date: |
Tue, 15 Jun 2021 15:47:39 -0500 |
From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
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>
---
block/nbd.c | 15 +++++++++------
1 file changed, 9 insertions(+), 6 deletions(-)
diff --git a/block/nbd.c b/block/nbd.c
index ce8d38d17abf..e7261aeaef7b 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
--
2.31.1
- [PULL 07/34] qemu-sockets: introduce socket_address_parse_named_fd(), (continued)
- [PULL 07/34] qemu-sockets: introduce socket_address_parse_named_fd(), Eric Blake, 2021/06/15
- [PULL 06/34] block/nbd: connect_thread_func(): do qio_channel_set_delay(false), Eric Blake, 2021/06/15
- [PULL 10/34] block/nbd: nbd_client_handshake(): fix leak of s->ioc, Eric Blake, 2021/06/15
- [PULL 09/34] block/nbd: ensure ->connection_thread is always valid, Eric Blake, 2021/06/15
- [PULL 08/34] block/nbd: call socket_address_parse_named_fd() in advance, Eric Blake, 2021/06/15
- [PULL 11/34] block/nbd: BDRVNBDState: drop unused connect_err and connect_status, Eric Blake, 2021/06/15
- [PULL 12/34] block/nbd: simplify waking of nbd_co_establish_connection(), Eric Blake, 2021/06/15
- [PULL 13/34] block/nbd: drop thr->state, Eric Blake, 2021/06/15
- [PULL 14/34] block/nbd: bs-independent interface for nbd_co_establish_connection(), Eric Blake, 2021/06/15
- [PULL 15/34] block/nbd: make nbd_co_establish_connection_cancel() bs-independent, Eric Blake, 2021/06/15
- [PULL 17/34] block/nbd: introduce nbd_client_connection_new(),
Eric Blake <=
- [PULL 18/34] block/nbd: introduce nbd_client_connection_release(), Eric Blake, 2021/06/15
- [PULL 16/34] block/nbd: rename NBDConnectThread to NBDClientConnection, Eric Blake, 2021/06/15
- [PULL 22/34] nbd/client-connection: implement connection retry, Eric Blake, 2021/06/15
- [PULL 20/34] nbd/client-connection: use QEMU_LOCK_GUARD, Eric Blake, 2021/06/15
- [PULL 21/34] nbd/client-connection: add possibility of negotiation, Eric Blake, 2021/06/15
- [PULL 19/34] nbd: move connection code from block/nbd to nbd/client-connection, Eric Blake, 2021/06/15
- [PULL 23/34] nbd/client-connection: shutdown connection on release, Eric Blake, 2021/06/15
- [PULL 25/34] block/nbd: use negotiation of NBDClientConnection, Eric Blake, 2021/06/15
- [PULL 26/34] block/nbd: don't touch s->sioc in nbd_teardown_connection(), Eric Blake, 2021/06/15
- [PULL 24/34] block/nbd: split nbd_handle_updated_info out of nbd_client_handshake(), Eric Blake, 2021/06/15