diff options
author | Kevin Wolf <kwolf@redhat.com> | 2023-10-27 17:53:30 +0200 |
---|---|---|
committer | Kevin Wolf <kwolf@redhat.com> | 2023-11-08 17:56:17 +0100 |
commit | 8f8973416e231bc1e45b2c4a3d419fbb8ef91c94 (patch) | |
tree | 3e13c9086d77fd43390d8666a0c25a8d1a28040e /block/qcow2.c | |
parent | 79a558664840adf502fe94907b0a680836e3e98e (diff) | |
download | qemu-8f8973416e231bc1e45b2c4a3d419fbb8ef91c94.zip qemu-8f8973416e231bc1e45b2c4a3d419fbb8ef91c94.tar.gz qemu-8f8973416e231bc1e45b2c4a3d419fbb8ef91c94.tar.bz2 |
qcow2: Take locks for accessing bs->file
This updates the qcow2 code to add GRAPH_RDLOCK annotations for all
places that read bs->file.
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Message-ID: <20231027155333.420094-22-kwolf@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Diffstat (limited to 'block/qcow2.c')
-rw-r--r-- | block/qcow2.c | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/block/qcow2.c b/block/qcow2.c index 7ab399f..cf24688 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -95,9 +95,10 @@ static int qcow2_probe(const uint8_t *buf, int buf_size, const char *filename) } -static int qcow2_crypto_hdr_read_func(QCryptoBlock *block, size_t offset, - uint8_t *buf, size_t buflen, - void *opaque, Error **errp) +static int GRAPH_RDLOCK +qcow2_crypto_hdr_read_func(QCryptoBlock *block, size_t offset, + uint8_t *buf, size_t buflen, + void *opaque, Error **errp) { BlockDriverState *bs = opaque; BDRVQcow2State *s = bs->opaque; @@ -156,7 +157,7 @@ qcow2_crypto_hdr_init_func(QCryptoBlock *block, size_t headerlen, void *opaque, /* The graph lock must be held when called in coroutine context */ -static int coroutine_mixed_fn +static int coroutine_mixed_fn GRAPH_RDLOCK qcow2_crypto_hdr_write_func(QCryptoBlock *block, size_t offset, const uint8_t *buf, size_t buflen, void *opaque, Error **errp) @@ -2029,6 +2030,8 @@ static void qcow2_reopen_commit(BDRVReopenState *state) { BDRVQcow2State *s = state->bs->opaque; + GRAPH_RDLOCK_GUARD_MAINLOOP(); + qcow2_update_options_commit(state->bs, state->opaque); if (!s->data_file) { /* @@ -2064,6 +2067,8 @@ static void qcow2_reopen_abort(BDRVReopenState *state) { BDRVQcow2State *s = state->bs->opaque; + GRAPH_RDLOCK_GUARD_MAINLOOP(); + if (!s->data_file) { /* * If we don't have an external data file, s->data_file was cleared by |