yeahuh / 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

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