Blob Blame History Raw
From 85658fdaaf7b24f64c31950f4bf710c0dcdafacd Mon Sep 17 00:00:00 2001
Message-Id: <85658fdaaf7b24f64c31950f4bf710c0dcdafacd@dist-git>
From: Peter Krempa <pkrempa@redhat.com>
Date: Tue, 4 Feb 2020 15:08:27 +0100
Subject: [PATCH] qemuDomainBlockPivot: Copy bitmaps backing checkpoints for
 virDomainBlockCopy
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Use qemuBlockBitmapsHandleBlockcopy to calculate bitmaps to copy over
for a block-copy job.

We copy them when pivoting to the new image as at that point we are
certain that we don't dirty any bitmap unnecessarily.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
(cherry picked from commit 54030892f5122ef120c1e8ffb6e0546871030272)

https://bugzilla.redhat.com/show_bug.cgi?id=1207659
Message-Id: <c60a7a567a634836370fc9c0c38317569fa5a22d.1580824112.git.pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
---
 src/qemu/qemu_driver.c | 28 +++++++++++++++++++++++++---
 1 file changed, 25 insertions(+), 3 deletions(-)

diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 71c75b25a6..caeb76a20c 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -17552,6 +17552,7 @@ qemuDomainBlockPivot(virQEMUDriverPtr driver,
     int ret = -1;
     qemuDomainObjPrivatePtr priv = vm->privateData;
     bool blockdev = virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_BLOCKDEV);
+    g_autoptr(virJSONValue) actions = NULL;
 
     switch ((qemuBlockJobType) job->type) {
     case QEMU_BLOCKJOB_TYPE_NONE:
@@ -17572,6 +17573,20 @@ qemuDomainBlockPivot(virQEMUDriverPtr driver,
         return -1;
 
     case QEMU_BLOCKJOB_TYPE_COPY:
+        if (blockdev && !job->jobflagsmissing) {
+            g_autoptr(virHashTable) blockNamedNodeData = NULL;
+            bool shallow = job->jobflags & VIR_DOMAIN_BLOCK_COPY_SHALLOW;
+
+            if (!(blockNamedNodeData = qemuBlockGetNamedNodeData(vm, QEMU_ASYNC_JOB_NONE)))
+                return -1;
+
+            if (qemuBlockBitmapsHandleBlockcopy(disk->src, disk->mirror,
+                                                blockNamedNodeData,
+                                                shallow, &actions) < 0)
+                return -1;
+        }
+        break;
+
     case QEMU_BLOCKJOB_TYPE_ACTIVE_COMMIT:
         break;
     }
@@ -17584,10 +17599,17 @@ qemuDomainBlockPivot(virQEMUDriverPtr driver,
     }
 
     qemuDomainObjEnterMonitor(driver, vm);
-    if (blockdev)
-        ret = qemuMonitorJobComplete(priv->mon, job->name);
-    else
+    if (blockdev) {
+        int rc = 0;
+
+        if (actions)
+            rc = qemuMonitorTransaction(priv->mon, &actions);
+
+        if (rc == 0)
+            ret = qemuMonitorJobComplete(priv->mon, job->name);
+    } else {
         ret = qemuMonitorDrivePivot(priv->mon, job->name);
+    }
     if (qemuDomainObjExitMonitor(driver, vm) < 0)
         return -1;
 
-- 
2.25.0