]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
qemuMigrationDstPrepareAnyBlockDirtyBitmaps: Fix check for existing bitmaps
authorPeter Krempa <pkrempa@redhat.com>
Tue, 27 Jan 2026 18:22:08 +0000 (19:22 +0100)
committerPeter Krempa <pkrempa@redhat.com>
Tue, 3 Feb 2026 14:34:52 +0000 (15:34 +0100)
On incoming migration qemu doesn't load bitmaps into memory (which makes
them available under the 'dirty-bitmaps' field which we parse as the
'bitmaps' array in 'qemuBlockNamedNodeData') until after actually
resuming CPUs, thus the check for existing bitmaps never actually
worked.

We need to check the 'qcow2bitmaps' field instead which is populated
from the qcow2 headers prior to activating the image.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
src/qemu/qemu_migration.c

index 6dd022163b5a2830d104bb37ee023662cdd73e75..a502515d93aa32f011feef4818b37d1bebf0a850 100644 (file)
@@ -3230,6 +3230,8 @@ qemuMigrationDstPrepareAnyBlockDirtyBitmaps(virDomainObj *vm,
         qemuBlockNamedNodeData *nodedata;
         GSList *nextbitmap;
 
+        VIR_DEBUG("offer migrate bitmaps for '%s'", disk->target);
+
         if (!(nodedata = virHashLookup(blockNamedNodeData, disk->nodename))) {
             virReportError(VIR_ERR_INTERNAL_ERROR,
                            _("failed to find data for block node '%1$s'"),
@@ -3246,18 +3248,14 @@ qemuMigrationDstPrepareAnyBlockDirtyBitmaps(virDomainObj *vm,
 
         for (nextbitmap = disk->bitmaps; nextbitmap; nextbitmap = nextbitmap->next) {
             qemuMigrationBlockDirtyBitmapsDiskBitmap *bitmap = nextbitmap->data;
-            size_t k;
 
             /* don't migrate into existing bitmaps */
-            for (k = 0; k < nodedata->nbitmaps; k++) {
-                if (STREQ(bitmap->bitmapname, nodedata->bitmaps[k]->name)) {
-                    bitmap->skip = true;
-                    break;
-                }
-            }
+            if (nodedata->qcow2bitmaps)
+                bitmap->skip = g_strv_contains((const char **) nodedata->qcow2bitmaps, bitmap->bitmapname);
+
+            VIR_DEBUG("offer migrate bitmap '%s' disk '%s' -> skip: '%d'",
+                      bitmap->bitmapname, disk->target, bitmap->skip);
 
-            if (bitmap->skip)
-                continue;
         }
     }