libvirt/SOURCES/libvirt-qemu-block-Remove-active-write-bitmap-even-if-there-are-no-bitmaps-to-merge.patch
2021-09-10 11:57:33 +00:00

106 lines
3.9 KiB
Diff

From cb297cdd8dc75abc8fd0d60dddf54cbe305d4c14 Mon Sep 17 00:00:00 2001
Message-Id: <cb297cdd8dc75abc8fd0d60dddf54cbe305d4c14@dist-git>
From: Peter Krempa <pkrempa@redhat.com>
Date: Tue, 21 Jul 2020 13:56:23 +0200
Subject: [PATCH] qemu: block: Remove 'active-write' bitmap even if there are
no bitmaps to merge
The 'libvirt-tmp-activewrite' bitmap is added during the 'pivot'
operation of block copy and active layer block commit operations
regardless of whether there are any bitmaps to merge, but was not
removed unless a bitmap was merged. This meant that subsequent attempts
to merge into the same image would fail.
Fix it by checking whether the 'libvirt-tmp-activewrite' would be used
by the code and don't skip the code which would delete it.
This is a regression introduced when we switched to the new code for
block commit in <20a7abc2d2d> and for block copy in <7bfff40fdfe5>. The
actual bug originates from <4fa8654ece>.
https://bugzilla.redhat.com/show_bug.cgi?id=1857735
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
(cherry picked from commit 9d039863e2cae227cc73b7a886b40be5e5218a12)
rhel-8.3: https://bugzilla.redhat.com/show_bug.cgi?id=1857779
rhel-av-8.2.1: not cloned yet
Message-Id: <4fea6a40be534d5a6fe7aad88d6bee1c3e77dcfb.1595332476.git.pkrempa@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
---
src/qemu/qemu_block.c | 3 ++-
tests/qemublocktestdata/bitmapblockcommit/empty | 9 +++++++++
.../bitmapblockcopy/empty-deep-out.json | 9 +++++++++
.../bitmapblockcopy/empty-shallow-out.json | 9 +++++++++
4 files changed, 29 insertions(+), 1 deletion(-)
diff --git a/src/qemu/qemu_block.c b/src/qemu/qemu_block.c
index 18c3861a2e..dc5fa3da03 100644
--- a/src/qemu/qemu_block.c
+++ b/src/qemu/qemu_block.c
@@ -2935,7 +2935,7 @@ qemuBlockGetBitmapMergeActions(virStorageSourcePtr topsrc,
if (!(bitmaps = qemuBlockGetBitmapMergeActionsGetBitmaps(topsrc, bitmapname,
blockNamedNodeData)))
- return 0;
+ goto done;
for (next = bitmaps; next; next = next->next) {
const char *curbitmap = next->data;
@@ -2992,6 +2992,7 @@ qemuBlockGetBitmapMergeActions(virStorageSourcePtr topsrc,
return -1;
}
+ done:
if (writebitmapsrc &&
qemuMonitorTransactionBitmapRemove(act, writebitmapsrc->nodeformat,
"libvirt-tmp-activewrite") < 0)
diff --git a/tests/qemublocktestdata/bitmapblockcommit/empty b/tests/qemublocktestdata/bitmapblockcommit/empty
index 9260011852..eddef0ddcd 100644
--- a/tests/qemublocktestdata/bitmapblockcommit/empty
+++ b/tests/qemublocktestdata/bitmapblockcommit/empty
@@ -1 +1,10 @@
merge bitmpas:
+[
+ {
+ "type": "block-dirty-bitmap-remove",
+ "data": {
+ "node": "libvirt-2-format",
+ "name": "libvirt-tmp-activewrite"
+ }
+ }
+]
diff --git a/tests/qemublocktestdata/bitmapblockcopy/empty-deep-out.json b/tests/qemublocktestdata/bitmapblockcopy/empty-deep-out.json
index e69de29bb2..99f2589ed4 100644
--- a/tests/qemublocktestdata/bitmapblockcopy/empty-deep-out.json
+++ b/tests/qemublocktestdata/bitmapblockcopy/empty-deep-out.json
@@ -0,0 +1,9 @@
+[
+ {
+ "type": "block-dirty-bitmap-remove",
+ "data": {
+ "node": "mirror-format-node",
+ "name": "libvirt-tmp-activewrite"
+ }
+ }
+]
diff --git a/tests/qemublocktestdata/bitmapblockcopy/empty-shallow-out.json b/tests/qemublocktestdata/bitmapblockcopy/empty-shallow-out.json
index e69de29bb2..99f2589ed4 100644
--- a/tests/qemublocktestdata/bitmapblockcopy/empty-shallow-out.json
+++ b/tests/qemublocktestdata/bitmapblockcopy/empty-shallow-out.json
@@ -0,0 +1,9 @@
+[
+ {
+ "type": "block-dirty-bitmap-remove",
+ "data": {
+ "node": "mirror-format-node",
+ "name": "libvirt-tmp-activewrite"
+ }
+ }
+]
--
2.27.0