Blame SOURCES/libvirt-qemuDomainBlockPivot-Copy-bitmaps-backing-checkpoints-for-virDomainBlockCopy.patch

d76c62
From 85658fdaaf7b24f64c31950f4bf710c0dcdafacd Mon Sep 17 00:00:00 2001
d76c62
Message-Id: <85658fdaaf7b24f64c31950f4bf710c0dcdafacd@dist-git>
d76c62
From: Peter Krempa <pkrempa@redhat.com>
d76c62
Date: Tue, 4 Feb 2020 15:08:27 +0100
d76c62
Subject: [PATCH] qemuDomainBlockPivot: Copy bitmaps backing checkpoints for
d76c62
 virDomainBlockCopy
d76c62
MIME-Version: 1.0
d76c62
Content-Type: text/plain; charset=UTF-8
d76c62
Content-Transfer-Encoding: 8bit
d76c62
d76c62
Use qemuBlockBitmapsHandleBlockcopy to calculate bitmaps to copy over
d76c62
for a block-copy job.
d76c62
d76c62
We copy them when pivoting to the new image as at that point we are
d76c62
certain that we don't dirty any bitmap unnecessarily.
d76c62
d76c62
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
d76c62
Reviewed-by: Ján Tomko <jtomko@redhat.com>
d76c62
(cherry picked from commit 54030892f5122ef120c1e8ffb6e0546871030272)
d76c62
d76c62
https://bugzilla.redhat.com/show_bug.cgi?id=1207659
d76c62
Message-Id: <c60a7a567a634836370fc9c0c38317569fa5a22d.1580824112.git.pkrempa@redhat.com>
d76c62
Reviewed-by: Ján Tomko <jtomko@redhat.com>
d76c62
---
d76c62
 src/qemu/qemu_driver.c | 28 +++++++++++++++++++++++++---
d76c62
 1 file changed, 25 insertions(+), 3 deletions(-)
d76c62
d76c62
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
d76c62
index 71c75b25a6..caeb76a20c 100644
d76c62
--- a/src/qemu/qemu_driver.c
d76c62
+++ b/src/qemu/qemu_driver.c
d76c62
@@ -17552,6 +17552,7 @@ qemuDomainBlockPivot(virQEMUDriverPtr driver,
d76c62
     int ret = -1;
d76c62
     qemuDomainObjPrivatePtr priv = vm->privateData;
d76c62
     bool blockdev = virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_BLOCKDEV);
d76c62
+    g_autoptr(virJSONValue) actions = NULL;
d76c62
 
d76c62
     switch ((qemuBlockJobType) job->type) {
d76c62
     case QEMU_BLOCKJOB_TYPE_NONE:
d76c62
@@ -17572,6 +17573,20 @@ qemuDomainBlockPivot(virQEMUDriverPtr driver,
d76c62
         return -1;
d76c62
 
d76c62
     case QEMU_BLOCKJOB_TYPE_COPY:
d76c62
+        if (blockdev && !job->jobflagsmissing) {
d76c62
+            g_autoptr(virHashTable) blockNamedNodeData = NULL;
d76c62
+            bool shallow = job->jobflags & VIR_DOMAIN_BLOCK_COPY_SHALLOW;
d76c62
+
d76c62
+            if (!(blockNamedNodeData = qemuBlockGetNamedNodeData(vm, QEMU_ASYNC_JOB_NONE)))
d76c62
+                return -1;
d76c62
+
d76c62
+            if (qemuBlockBitmapsHandleBlockcopy(disk->src, disk->mirror,
d76c62
+                                                blockNamedNodeData,
d76c62
+                                                shallow, &actions) < 0)
d76c62
+                return -1;
d76c62
+        }
d76c62
+        break;
d76c62
+
d76c62
     case QEMU_BLOCKJOB_TYPE_ACTIVE_COMMIT:
d76c62
         break;
d76c62
     }
d76c62
@@ -17584,10 +17599,17 @@ qemuDomainBlockPivot(virQEMUDriverPtr driver,
d76c62
     }
d76c62
 
d76c62
     qemuDomainObjEnterMonitor(driver, vm);
d76c62
-    if (blockdev)
d76c62
-        ret = qemuMonitorJobComplete(priv->mon, job->name);
d76c62
-    else
d76c62
+    if (blockdev) {
d76c62
+        int rc = 0;
d76c62
+
d76c62
+        if (actions)
d76c62
+            rc = qemuMonitorTransaction(priv->mon, &actions);
d76c62
+
d76c62
+        if (rc == 0)
d76c62
+            ret = qemuMonitorJobComplete(priv->mon, job->name);
d76c62
+    } else {
d76c62
         ret = qemuMonitorDrivePivot(priv->mon, job->name);
d76c62
+    }
d76c62
     if (qemuDomainObjExitMonitor(driver, vm) < 0)
d76c62
         return -1;
d76c62
 
d76c62
-- 
d76c62
2.25.0
d76c62