]> xenbits.xensource.com Git - libvirt.git/commitdiff
virsh: Add support for VIR_MIGRATE_PARAM_MIGRATE_DISKS_DETECT_ZEROES migration parameter
authorPeter Krempa <pkrempa@redhat.com>
Fri, 27 Sep 2024 13:18:50 +0000 (15:18 +0200)
committerPeter Krempa <pkrempa@redhat.com>
Tue, 1 Oct 2024 10:57:02 +0000 (12:57 +0200)
Expose the new parameter as '--migrate-disks-detect-zeroes' option.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
docs/manpages/virsh.rst
tools/virsh-domain.c

index f02a28156d9e7d6195ef35090ae6a8eea969cd77..6665d464975928e97b41b7e7bdc23f885bf7c6c9 100644 (file)
@@ -3389,7 +3389,9 @@ migrate
       [--postcopy-after-precopy] [--postcopy-resume] [--zerocopy]
       domain desturi [migrateuri] [graphicsuri] [listen-address] [dname]
       [--timeout seconds [--timeout-suspend | --timeout-postcopy]]
-      [--xml file] [--migrate-disks disk-list] [--disks-port port]
+      [--xml file]
+      [--migrate-disks disk-list] [--migrate-disks-detect-zeroes disk-list]
+      [--disks-port port]
       [--compressed] [--comp-methods method-list]
       [--comp-mt-level] [--comp-mt-threads] [--comp-mt-dthreads]
       [--comp-xbzrle-cache] [--comp-zlib-level] [--comp-zstd-level]
@@ -3420,6 +3422,10 @@ images on source host to the images found at the same place on the destination
 host. By default only non-shared non-readonly images are transferred. Use
 *--migrate-disks* to explicitly specify a list of disk targets to
 transfer via the comma separated ``disk-list`` argument.
+The *--migrate-disks-detect-zeroes* option which takes a comma separated list of
+disk target names enables zeroed block detection for the listed migrated disks.
+These blocks are not transferred or allocated on destination, effectively
+sparsifying the disk at the cost of CPU overhead.
 With *--copy-storage-synchronous-writes* flag used the disk data migration will
 synchronously handle guest disk writes to both the original source and the
 destination to ensure that the disk migration converges at the price of possibly
index 50e80689a28ba307c3ef464e80b87b5fd00473a1..e4923284afadd6d07a0211babe5c89768e10020c 100644 (file)
@@ -10691,6 +10691,11 @@ static const vshCmdOptDef opts_migrate[] = {
      .completer = virshDomainMigrateDisksCompleter,
      .help = N_("comma separated list of disks to be migrated")
     },
+    {.name = "migrate-disks-detect-zeroes",
+     .type = VSH_OT_STRING,
+     .completer = virshDomainMigrateDisksCompleter,
+     .help = N_("comma separated list of disks to be migrated with zero detection enabled")
+    },
     {.name = "disks-port",
      .type = VSH_OT_INT,
      .unwanted_positional = true,
@@ -10909,6 +10914,27 @@ doMigrate(void *opaque)
         }
     }
 
+    if (vshCommandOptString(ctl, cmd, "migrate-disks-detect-zeroes", &opt) < 0)
+        goto out;
+    if (opt) {
+        g_autofree char **val = NULL;
+
+        if (!(flags & (VIR_MIGRATE_NON_SHARED_DISK | VIR_MIGRATE_NON_SHARED_INC))) {
+            vshError(ctl, "'--migrate-disks-detect-zeroes' requires one of '--copy-storage-all', '--copy-storage-inc'");
+            goto out;
+        }
+
+        val = g_strsplit(opt, ",", 0);
+
+        if (virTypedParamsAddStringList(&params,
+                                        &nparams,
+                                        &maxparams,
+                                        VIR_MIGRATE_PARAM_MIGRATE_DISKS_DETECT_ZEROES,
+                                        (const char **)val) < 0) {
+            goto save_error;
+        }
+    }
+
     if (vshCommandOptString(ctl, cmd, "comp-methods", &opt) < 0)
         goto out;
     if (opt) {