aboutsummaryrefslogtreecommitdiff
path: root/block/nbd.c
diff options
context:
space:
mode:
authorPaolo Bonzini <pbonzini@redhat.com>2021-05-17 12:05:47 +0200
committerStefan Hajnoczi <stefanha@redhat.com>2021-05-21 18:22:33 +0100
commit29a6ea24eb85d8400df1607a9e11d0ef9ec5e88d (patch)
tree86dbfa59f1ceb9324ee7937f457ac906e6b81069 /block/nbd.c
parent1485f0c24cfbef7a542ce13d49e9f68e285c57d8 (diff)
coroutine-sleep: replace QemuCoSleepState pointer with struct in the API
Right now, users of qemu_co_sleep_ns_wakeable are simply passing a pointer to QemuCoSleepState by reference to the function. But QemuCoSleepState really is just a Coroutine*; making the content of the struct public is just as efficient and lets us skip the user_state_pointer indirection. Since the usage is changed, take the occasion to rename the struct to QemuCoSleep. Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Message-id: 20210517100548.28806-6-pbonzini@redhat.com Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Diffstat (limited to 'block/nbd.c')
-rw-r--r--block/nbd.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/block/nbd.c b/block/nbd.c
index 1c6315b168..616f9ae6c4 100644
--- a/block/nbd.c
+++ b/block/nbd.c
@@ -116,7 +116,7 @@ typedef struct BDRVNBDState {
CoQueue free_sema;
Coroutine *connection_co;
Coroutine *teardown_co;
- QemuCoSleepState *connection_co_sleep_ns_state;
+ QemuCoSleep reconnect_sleep;
bool drained;
bool wait_drained_end;
int in_flight;
@@ -289,7 +289,7 @@ static void coroutine_fn nbd_client_co_drain_begin(BlockDriverState *bs)
BDRVNBDState *s = (BDRVNBDState *)bs->opaque;
s->drained = true;
- qemu_co_sleep_wake(s->connection_co_sleep_ns_state);
+ qemu_co_sleep_wake(&s->reconnect_sleep);
nbd_co_establish_connection_cancel(bs, false);
@@ -328,7 +328,7 @@ static void nbd_teardown_connection(BlockDriverState *bs)
s->state = NBD_CLIENT_QUIT;
if (s->connection_co) {
- qemu_co_sleep_wake(s->connection_co_sleep_ns_state);
+ qemu_co_sleep_wake(&s->reconnect_sleep);
nbd_co_establish_connection_cancel(bs, true);
}
if (qemu_in_coroutine()) {
@@ -685,8 +685,8 @@ static coroutine_fn void nbd_co_reconnect_loop(BDRVNBDState *s)
}
bdrv_inc_in_flight(s->bs);
} else {
- qemu_co_sleep_ns_wakeable(QEMU_CLOCK_REALTIME, timeout,
- &s->connection_co_sleep_ns_state);
+ qemu_co_sleep_ns_wakeable(&s->reconnect_sleep,
+ QEMU_CLOCK_REALTIME, timeout);
if (s->drained) {
continue;
}