[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 06/29] block/qcow2: Move bitmap reopen into bdrv_reopen_commit_pos
From: |
Kevin Wolf |
Subject: |
[PULL 06/29] block/qcow2: Move bitmap reopen into bdrv_reopen_commit_post |
Date: |
Fri, 6 Mar 2020 18:14:35 +0100 |
From: Peter Krempa <address@hidden>
The bitmap code requires writing the 'file' child when the qcow2 driver
is reopened in read-write mode.
If the 'file' child is being reopened due to a permissions change, the
modification is commited yet when qcow2_reopen_commit is called. This
means that any attempt to write the 'file' child will end with EBADFD
as the original fd was already closed.
Moving bitmap reopening to the new callback which is called after
permission modifications are commited fixes this as the file descriptor
will be replaced with the correct one.
The above problem manifests itself when reopening 'qcow2' format layer
which uses a 'file-posix' file child which was opened with the
'auto-read-only' property set.
Signed-off-by: Peter Krempa <address@hidden>
Message-Id: <address@hidden>
Signed-off-by: Kevin Wolf <address@hidden>
---
block/qcow2.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/block/qcow2.c b/block/qcow2.c
index 3c754f616b..3640e8c07d 100644
--- a/block/qcow2.c
+++ b/block/qcow2.c
@@ -1884,6 +1884,11 @@ fail:
static void qcow2_reopen_commit(BDRVReopenState *state)
{
qcow2_update_options_commit(state->bs, state->opaque);
+ g_free(state->opaque);
+}
+
+static void qcow2_reopen_commit_post(BDRVReopenState *state)
+{
if (state->flags & BDRV_O_RDWR) {
Error *local_err = NULL;
@@ -1898,7 +1903,6 @@ static void qcow2_reopen_commit(BDRVReopenState *state)
bdrv_get_node_name(state->bs));
}
}
- g_free(state->opaque);
}
static void qcow2_reopen_abort(BDRVReopenState *state)
@@ -5534,6 +5538,7 @@ BlockDriver bdrv_qcow2 = {
.bdrv_close = qcow2_close,
.bdrv_reopen_prepare = qcow2_reopen_prepare,
.bdrv_reopen_commit = qcow2_reopen_commit,
+ .bdrv_reopen_commit_post = qcow2_reopen_commit_post,
.bdrv_reopen_abort = qcow2_reopen_abort,
.bdrv_join_options = qcow2_join_options,
.bdrv_child_perm = bdrv_format_default_perms,
--
2.20.1
- [PULL 00/29] Block layer patches, Kevin Wolf, 2020/03/06
- [PULL 02/29] iotests/026: Test EIO on preallocated zero cluster, Kevin Wolf, 2020/03/06
- [PULL 05/29] block: Introduce 'bdrv_reopen_commit_post' step, Kevin Wolf, 2020/03/06
- [PULL 04/29] block: Fix leak in bdrv_create_file_fallback(), Kevin Wolf, 2020/03/06
- [PULL 03/29] iotests/026: Test EIO on allocation in a data-file, Kevin Wolf, 2020/03/06
- [PULL 01/29] qcow2: Fix alloc_cluster_abort() for pre-existing clusters, Kevin Wolf, 2020/03/06
- [PULL 07/29] qemu-storage-daemon: Add barebone tool, Kevin Wolf, 2020/03/06
- [PULL 08/29] stubs: Add arch_type, Kevin Wolf, 2020/03/06
- [PULL 14/29] qemu-storage-daemon: Add --object option, Kevin Wolf, 2020/03/06
- [PULL 06/29] block/qcow2: Move bitmap reopen into bdrv_reopen_commit_post,
Kevin Wolf <=
- [PULL 16/29] blockdev-nbd: Boxed argument type for nbd-server-add, Kevin Wolf, 2020/03/06
- [PULL 13/29] qapi: Flatten object-add, Kevin Wolf, 2020/03/06
- [PULL 15/29] qemu-storage-daemon: Add --nbd-server option, Kevin Wolf, 2020/03/06
- [PULL 19/29] qemu-storage-daemon: Add --chardev option, Kevin Wolf, 2020/03/06
- [PULL 18/29] qemu-storage-daemon: Add main loop, Kevin Wolf, 2020/03/06
- [PULL 22/29] monitor: Create QAPIfied monitor_init(), Kevin Wolf, 2020/03/06
- [PULL 21/29] qapi: Create 'pragma' module, Kevin Wolf, 2020/03/06
- [PULL 10/29] block: Move common QMP commands to block-core QAPI module, Kevin Wolf, 2020/03/06
- [PULL 12/29] qemu-storage-daemon: Add --blockdev option, Kevin Wolf, 2020/03/06
- [PULL 20/29] stubs: Update monitor stubs for qemu-storage-daemon, Kevin Wolf, 2020/03/06