render / rpms / libvirt

Forked from rpms/libvirt 9 months ago
Clone
a41c76
From 97a6adcb3ac735ff135469aa602c798fbc0b1491 Mon Sep 17 00:00:00 2001
a41c76
Message-Id: <97a6adcb3ac735ff135469aa602c798fbc0b1491@dist-git>
a41c76
From: Peter Krempa <pkrempa@redhat.com>
a41c76
Date: Tue, 23 Jun 2020 12:23:36 +0200
a41c76
Subject: [PATCH] qemu: backup: Fix backup of disk skipped in an intermediate
a41c76
 checkpoint
a41c76
MIME-Version: 1.0
a41c76
Content-Type: text/plain; charset=UTF-8
a41c76
Content-Transfer-Encoding: 8bit
a41c76
a41c76
If a disk is not captured by one of the intermediate checkpoints the
a41c76
code would fail, but we can easily calculate the bitmaps to merge
a41c76
correctly by skipping over checkpoints which don't describe the disk.
a41c76
a41c76
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
a41c76
Reviewed-by: Eric Blake <eblake@redhat.com>
a41c76
(cherry picked from commit c89a44777fdf89b400878adcb03a3557bcec3f4e)
a41c76
a41c76
https://bugzilla.redhat.com/show_bug.cgi?id=1804593
a41c76
Message-Id: <d0efe760e9f8049758691b7f66a7de41fce5c264.1592906423.git.pkrempa@redhat.com>
a41c76
Reviewed-by: Ján Tomko <jtomko@redhat.com>
a41c76
---
a41c76
 src/qemu/qemu_backup.c | 24 ++++++++++++++++++++++++
a41c76
 tests/qemublocktest.c  |  6 ++++++
a41c76
 2 files changed, 30 insertions(+)
a41c76
a41c76
diff --git a/src/qemu/qemu_backup.c b/src/qemu/qemu_backup.c
a41c76
index 400b711f79..adbf696de6 100644
a41c76
--- a/src/qemu/qemu_backup.c
a41c76
+++ b/src/qemu/qemu_backup.c
a41c76
@@ -240,6 +240,30 @@ qemuBackupDiskPrepareOneBitmapsChain(virDomainMomentDefPtr *incremental,
a41c76
     for (incridx = 0; incremental[incridx]; incridx++) {
a41c76
         g_autoptr(virJSONValue) tmp = virJSONValueNewArray();
a41c76
         virStorageSourcePtr tmpsrc = NULL;
a41c76
+        virDomainCheckpointDefPtr chkdef = (virDomainCheckpointDefPtr) incremental[incridx];
a41c76
+        bool checkpoint_has_disk = false;
a41c76
+        size_t i;
a41c76
+
a41c76
+        for (i = 0; i < chkdef->ndisks; i++) {
a41c76
+            if (STRNEQ_NULLABLE(diskdst, chkdef->disks[i].name))
a41c76
+                continue;
a41c76
+
a41c76
+            if (chkdef->disks[i].type == VIR_DOMAIN_CHECKPOINT_TYPE_BITMAP)
a41c76
+                checkpoint_has_disk = true;
a41c76
+
a41c76
+            break;
a41c76
+        }
a41c76
+
a41c76
+        if (!checkpoint_has_disk) {
a41c76
+            if (!incremental[incridx + 1]) {
a41c76
+                virReportError(VIR_ERR_INVALID_ARG,
a41c76
+                               _("disk '%s' not found in checkpoint '%s'"),
a41c76
+                               diskdst, incremental[incridx]->name);
a41c76
+                return NULL;
a41c76
+            }
a41c76
+
a41c76
+            continue;
a41c76
+        }
a41c76
 
a41c76
         if (qemuBackupGetBitmapMergeRange(n, incremental[incridx]->name,
a41c76
                                           &tmp, &tmpsrc, diskdst,
a41c76
diff --git a/tests/qemublocktest.c b/tests/qemublocktest.c
a41c76
index e461b3a23d..d15965d9eb 100644
a41c76
--- a/tests/qemublocktest.c
a41c76
+++ b/tests/qemublocktest.c
a41c76
@@ -727,6 +727,12 @@ testQemuBackupGetIncrementalMoment(const char *name)
a41c76
     if (!(checkpoint = virDomainCheckpointDefNew()))
a41c76
         abort();
a41c76
 
a41c76
+    checkpoint->disks = g_new0(virDomainCheckpointDiskDef, 1);
a41c76
+    checkpoint->ndisks = 1;
a41c76
+
a41c76
+    checkpoint->disks[0].name = g_strdup("testdisk");
a41c76
+    checkpoint->disks[0].type = VIR_DOMAIN_CHECKPOINT_TYPE_BITMAP;
a41c76
+
a41c76
     checkpoint->parent.name = g_strdup(name);
a41c76
 
a41c76
     return (virDomainMomentDefPtr) checkpoint;
a41c76
-- 
a41c76
2.27.0
a41c76