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

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