cryptospore / rpms / qemu-kvm

Forked from rpms/qemu-kvm 2 years ago
Clone

Blame SOURCES/kvm-block-qcow2-Move-bitmap-reopen-into-bdrv_reopen_comm.patch

ddf19c
From ec5408763c49cd0b63ee324bdc38a429ed1adeee Mon Sep 17 00:00:00 2001
ddf19c
From: Kevin Wolf <kwolf@redhat.com>
ddf19c
Date: Fri, 13 Mar 2020 12:34:29 +0000
ddf19c
Subject: [PATCH 09/20] block/qcow2: Move bitmap reopen into
ddf19c
 bdrv_reopen_commit_post
ddf19c
ddf19c
RH-Author: Kevin Wolf <kwolf@redhat.com>
ddf19c
Message-id: <20200313123439.10548-4-kwolf@redhat.com>
ddf19c
Patchwork-id: 94280
ddf19c
O-Subject: [RHEL-AV-8.2.0 qemu-kvm PATCH v2 03/13] block/qcow2: Move bitmap reopen into bdrv_reopen_commit_post
ddf19c
Bugzilla: 1790482 1805143
ddf19c
RH-Acked-by: John Snow <jsnow@redhat.com>
ddf19c
RH-Acked-by: Daniel P. Berrange <berrange@redhat.com>
ddf19c
RH-Acked-by: Peter Krempa <pkrempa@redhat.com>
ddf19c
ddf19c
From: Peter Krempa <pkrempa@redhat.com>
ddf19c
ddf19c
The bitmap code requires writing the 'file' child when the qcow2 driver
ddf19c
is reopened in read-write mode.
ddf19c
ddf19c
If the 'file' child is being reopened due to a permissions change, the
ddf19c
modification is commited yet when qcow2_reopen_commit is called. This
ddf19c
means that any attempt to write the 'file' child will end with EBADFD
ddf19c
as the original fd was already closed.
ddf19c
ddf19c
Moving bitmap reopening to the new callback which is called after
ddf19c
permission modifications are commited fixes this as the file descriptor
ddf19c
will be replaced with the correct one.
ddf19c
ddf19c
The above problem manifests itself when reopening 'qcow2' format layer
ddf19c
which uses a 'file-posix' file child which was opened with the
ddf19c
'auto-read-only' property set.
ddf19c
ddf19c
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
ddf19c
Message-Id: <db118dbafe1955afbc0a18d3dd220931074ce349.1582893284.git.pkrempa@redhat.com>
ddf19c
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
ddf19c
(cherry picked from commit 65eb7c85a3e62529e2bad782e94d5a7b11dd5a92)
ddf19c
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
ddf19c
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
ddf19c
---
ddf19c
 block/qcow2.c | 7 ++++++-
ddf19c
 1 file changed, 6 insertions(+), 1 deletion(-)
ddf19c
ddf19c
diff --git a/block/qcow2.c b/block/qcow2.c
ddf19c
index 7c18721..83b1fc0 100644
ddf19c
--- a/block/qcow2.c
ddf19c
+++ b/block/qcow2.c
ddf19c
@@ -1881,6 +1881,11 @@ fail:
ddf19c
 static void qcow2_reopen_commit(BDRVReopenState *state)
ddf19c
 {
ddf19c
     qcow2_update_options_commit(state->bs, state->opaque);
ddf19c
+    g_free(state->opaque);
ddf19c
+}
ddf19c
+
ddf19c
+static void qcow2_reopen_commit_post(BDRVReopenState *state)
ddf19c
+{
ddf19c
     if (state->flags & BDRV_O_RDWR) {
ddf19c
         Error *local_err = NULL;
ddf19c
 
ddf19c
@@ -1895,7 +1900,6 @@ static void qcow2_reopen_commit(BDRVReopenState *state)
ddf19c
                               bdrv_get_node_name(state->bs));
ddf19c
         }
ddf19c
     }
ddf19c
-    g_free(state->opaque);
ddf19c
 }
ddf19c
 
ddf19c
 static void qcow2_reopen_abort(BDRVReopenState *state)
ddf19c
@@ -5492,6 +5496,7 @@ BlockDriver bdrv_qcow2 = {
ddf19c
     .bdrv_close         = qcow2_close,
ddf19c
     .bdrv_reopen_prepare  = qcow2_reopen_prepare,
ddf19c
     .bdrv_reopen_commit   = qcow2_reopen_commit,
ddf19c
+    .bdrv_reopen_commit_post = qcow2_reopen_commit_post,
ddf19c
     .bdrv_reopen_abort    = qcow2_reopen_abort,
ddf19c
     .bdrv_join_options    = qcow2_join_options,
ddf19c
     .bdrv_child_perm      = bdrv_format_default_perms,
ddf19c
-- 
ddf19c
1.8.3.1
ddf19c