diff options
author | Hanna Reitz <hreitz@redhat.com> | 2022-04-27 13:40:55 +0200 |
---|---|---|
committer | Kevin Wolf <kwolf@redhat.com> | 2022-05-04 15:55:23 +0200 |
commit | 06e9cd19a4e9acf8d24327361a999943d846f607 (patch) | |
tree | c043ee84103a6394afc9be8362175a75f3531c77 /net/net.c | |
parent | 15aee7ac9587562b1d021959dedc2bbb7e9a9fb3 (diff) | |
download | qemu-06e9cd19a4e9acf8d24327361a999943d846f607.zip qemu-06e9cd19a4e9acf8d24327361a999943d846f607.tar.gz qemu-06e9cd19a4e9acf8d24327361a999943d846f607.tar.bz2 |
qcow2: Do not reopen data_file in invalidate_cache
qcow2_co_invalidate_cache() closes and opens the qcow2 file, by calling
qcow2_close() and qcow2_do_open(). These two functions must thus be
usable from both a global-state and an I/O context.
As they are, they are not safe to call in an I/O context, because they
use bdrv_unref_child() and bdrv_open_child() to close/open the data_file
child, respectively, both of which are global-state functions. When
used from qcow2_co_invalidate_cache(), we do not need to close/open the
data_file child, though (we do not do this for bs->file or bs->backing
either), and so we should skip it in the qcow2_co_invalidate_cache()
path.
To do so, add a parameter to qcow2_do_open() and qcow2_close() to make
them skip handling s->data_file, and have qcow2_co_invalidate_cache()
exempt it from the memset() on the BDRVQcow2State.
(Note that the QED driver similarly closes/opens the QED image by
invoking bdrv_qed_close()+bdrv_qed_do_open(), but both functions seem
safe to use in an I/O context.)
Fixes: https://gitlab.com/qemu-project/qemu/-/issues/945
Signed-off-by: Hanna Reitz <hreitz@redhat.com>
Message-Id: <20220427114057.36651-3-hreitz@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Diffstat (limited to 'net/net.c')
0 files changed, 0 insertions, 0 deletions