Skip to content

Commit

Permalink
block/nbd: introduce nbd_client_connection_new()
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Vladimir Sementsov-Ogievskiy authored and ebblake committed Jun 18, 2021
1 parent 90ddc64 commit f687297
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions block/nbd.c
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit f687297

Please sign in to comment.