[libvirt] [PATCH 13/19] qemu: backup: Extract calculations of bitmaps to merge for incremental backup

Peter Krempa pkrempa at redhat.com
Thu Dec 12 17:18:43 UTC 2019


Separate the for now incomplete code that collects the bitmaps to be
merged for an incremental backup into a separate function. This will
allow to add testing prior to the improvement of the algorithm to
include snapshots.

Signed-off-by: Peter Krempa <pkrempa at redhat.com>
---
 src/qemu/qemu_backup.c | 37 +++++++++++++++++++++++++------------
 1 file changed, 25 insertions(+), 12 deletions(-)

diff --git a/src/qemu/qemu_backup.c b/src/qemu/qemu_backup.c
index 1cd466d211..31949b5399 100644
--- a/src/qemu/qemu_backup.c
+++ b/src/qemu/qemu_backup.c
@@ -170,30 +170,43 @@ qemuBackupDiskDataCleanup(virDomainObjPtr vm,
 }


-
-static int
-qemuBackupDiskPrepareOneBitmaps(struct qemuBackupDiskData *dd,
-                                virJSONValuePtr actions,
-                                virDomainMomentDefPtr *incremental)
+static virJSONValuePtr
+qemuBackupDiskPrepareOneBitmapsChain(virDomainMomentDefPtr *incremental,
+                                     virStorageSourcePtr backingChain)
 {
-    g_autoptr(virJSONValue) mergebitmaps = NULL;
-    g_autoptr(virJSONValue) mergebitmapsstore = NULL;
+    g_autoptr(virJSONValue) ret = NULL;

-    if (!(mergebitmaps = virJSONValueNewArray()))
-        return -1;
+    if (!(ret = virJSONValueNewArray()))
+        return NULL;

     /* TODO: this code works only if the bitmaps are present on a single node.
      * The algorithm needs to be changed so that it looks into the backing chain
      * so that we can combine all relevant bitmaps for a given backing chain */
     while (*incremental) {
-        if (qemuMonitorTransactionBitmapMergeSourceAddBitmap(mergebitmaps,
-                                                             dd->domdisk->src->nodeformat,
+        if (qemuMonitorTransactionBitmapMergeSourceAddBitmap(ret,
+                                                             backingChain->nodeformat,
                                                              (*incremental)->name) < 0)
-            return -1;
+            return NULL;

         incremental++;
     }

+    return g_steal_pointer(&ret);
+}
+
+
+static int
+qemuBackupDiskPrepareOneBitmaps(struct qemuBackupDiskData *dd,
+                                virJSONValuePtr actions,
+                                virDomainMomentDefPtr *incremental)
+{
+    g_autoptr(virJSONValue) mergebitmaps = NULL;
+    g_autoptr(virJSONValue) mergebitmapsstore = NULL;
+
+    if (!(mergebitmaps = qemuBackupDiskPrepareOneBitmapsChain(incremental,
+                                                              dd->domdisk->src)))
+        return -1;
+
     if (!(mergebitmapsstore = virJSONValueCopy(mergebitmaps)))
         return -1;

-- 
2.23.0




More information about the libvir-list mailing list