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

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