In case when the block migration job required temporary bitmaps for
merging the appropriate checkpoints we need to clean them up when
cancelling the job. On success we don't need to do that though as the
bitmaps are just temporary thus are not written to disk.

Signed-off-by: Peter Krempa <pkre...@redhat.com>
Reviewed-by: Jiri Denemark <jdene...@redhat.com>
---
 src/qemu/qemu_migration.c | 28 ++++++++++++++++++++++++++++
 1 file changed, 28 insertions(+)

diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c
index 94b9b34ca0..4e69fab384 100644
--- a/src/qemu/qemu_migration.c
+++ b/src/qemu/qemu_migration.c
@@ -840,6 +840,29 @@ qemuMigrationSrcNBDCopyCancel(virQEMUDriverPtr driver,
 }


+static int
+qemuMigrationSrcCancelRemoveTempBitmaps(virDomainObjPtr vm,
+                                        qemuDomainAsyncJob asyncJob)
+{
+    qemuDomainObjPrivatePtr priv = vm->privateData;
+    virQEMUDriverPtr driver = priv->driver;
+    qemuDomainJobPrivatePtr jobPriv = priv->job.privateData;
+    GSList *next;
+
+    for (next = jobPriv->migTempBitmaps; next; next = next->next) {
+        qemuDomainJobPrivateMigrateTempBitmapPtr t = next->data;
+
+        if (qemuDomainObjEnterMonitorAsync(driver, vm, asyncJob) < 0)
+            return -1;
+        qemuMonitorBitmapRemove(priv->mon, t->nodename, t->bitmapname);
+        if (qemuDomainObjExitMonitor(driver, vm) < 0)
+            return -1;
+    }
+
+    return 0;
+}
+
+
 static virStorageSourcePtr
 qemuMigrationSrcNBDStorageCopyBlockdevPrepareSource(virDomainDiskDefPtr disk,
                                                     const char *host,
@@ -4003,6 +4026,8 @@ qemuMigrationSrcRun(virQEMUDriverPtr driver,
                                           QEMU_ASYNC_JOB_MIGRATION_OUT,
                                           dconn);

+        qemuMigrationSrcCancelRemoveTempBitmaps(vm, 
QEMU_ASYNC_JOB_MIGRATION_OUT);
+
         if (priv->job.current->status != QEMU_DOMAIN_JOB_STATUS_CANCELED)
             priv->job.current->status = QEMU_DOMAIN_JOB_STATUS_FAILED;
     }
@@ -5705,6 +5730,9 @@ qemuMigrationSrcCancel(virQEMUDriverPtr driver,
                                       QEMU_ASYNC_JOB_NONE, NULL) < 0)
         return -1;

+    if (qemuMigrationSrcCancelRemoveTempBitmaps(vm, QEMU_ASYNC_JOB_NONE) < 0)
+        return -1;
+
     return 0;
 }

-- 
2.29.2

Reply via email to