Blob Blame History Raw
From fa5d6a3c048e15f466a5bd2f7cc6de0b106d69a2 Mon Sep 17 00:00:00 2001
Message-Id: <fa5d6a3c048e15f466a5bd2f7cc6de0b106d69a2@dist-git>
From: Peter Krempa <pkrempa@redhat.com>
Date: Mon, 16 Mar 2020 22:12:30 +0100
Subject: [PATCH] qemuDomainBlockPivot: Handle merging of bitmaps when pivoting
 an active block-commit
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Active layer block commit makes the 'base' image the new top image of
the disk after it finishes. This means that all bitmap operations need
to be handled prior to this happening as we'd lose writes otherwise.

The ideal place is to handle it when pivoting to the new image as only
guest-writes would be happening after this point.

Use qemuBlockBitmapsHandleCommitFinish to calculate the merging
transaction.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
(cherry picked from commit 8502b4b0595ac040f22e1ec8c2ab6375506c14a3)
https://bugzilla.redhat.com/show_bug.cgi?id=1799013
Message-Id: <7fbaf9f9a8533489334c5b08e6451b23011ab657.1584391727.git.pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
---
 src/qemu/qemu_driver.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 2f8fee2ef0..05e525e935 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -17626,6 +17626,23 @@ qemuDomainBlockPivot(virQEMUDriverPtr driver,
         break;
 
     case QEMU_BLOCKJOB_TYPE_ACTIVE_COMMIT:
+        /* we technically don't need reopen here, but we couldn't prepare
+         * the bitmaps if it wasn't present thus must skip this */
+        if (blockdev &&
+            virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_BLOCKDEV_REOPEN)) {
+            g_autoptr(virHashTable) blockNamedNodeData = NULL;
+
+            if (!(blockNamedNodeData = qemuBlockGetNamedNodeData(vm, QEMU_ASYNC_JOB_NONE)))
+                return -1;
+
+            if (qemuBlockBitmapsHandleCommitFinish(job->data.commit.top,
+                                                   job->data.commit.base,
+                                                   blockNamedNodeData,
+                                                   &actions,
+                                                   job->data.commit.disabledBitmapsBase) < 0)
+                return -1;
+        }
+
         break;
     }
 
-- 
2.25.1