From 3323e85bf659d47564bb85342c0a99aceac82a8f Mon Sep 17 00:00:00 2001 From: Peter Krempa Date: Thu, 12 Dec 2019 15:20:48 +0100 Subject: [PATCH] qemu: backup: Extract calculations of bitmaps to merge for incremental backup Separate the for now incomplete code that collects the bitmaps to be merged for an incremental backup into a separate function. This will allow adding testing prior to the improvement of the algorithm to include snapshots. Signed-off-by: Peter Krempa Reviewed-by: Eric Blake --- src/qemu/qemu_backup.c | 39 ++++++++++++++++++++++++++------------- 1 file changed, 26 insertions(+), 13 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,6 +170,30 @@ qemuBackupDiskDataCleanup(virDomainObjPtr vm, } +static virJSONValuePtr +qemuBackupDiskPrepareOneBitmapsChain(virDomainMomentDefPtr *incremental, + virStorageSourcePtr backingChain) +{ + g_autoptr(virJSONValue) ret = NULL; + + 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(ret, + backingChain->nodeformat, + (*incremental)->name) < 0) + return NULL; + + incremental++; + } + + return g_steal_pointer(&ret); +} + static int qemuBackupDiskPrepareOneBitmaps(struct qemuBackupDiskData *dd, @@ -179,21 +203,10 @@ qemuBackupDiskPrepareOneBitmaps(struct qemuBackupDiskData *dd, g_autoptr(virJSONValue) mergebitmaps = NULL; g_autoptr(virJSONValue) mergebitmapsstore = NULL; - if (!(mergebitmaps = virJSONValueNewArray())) + if (!(mergebitmaps = qemuBackupDiskPrepareOneBitmapsChain(incremental, + dd->domdisk->src))) return -1; - /* 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, - (*incremental)->name) < 0) - return -1; - - incremental++; - } - if (!(mergebitmapsstore = virJSONValueCopy(mergebitmaps))) return -1;