From: Peter Krempa <[email protected]>

Add '--migrate-disks-target-zero' to pass the list of pre-zeroed disk
images.

Signed-off-by: Peter Krempa <[email protected]>
---
 docs/manpages/virsh.rst |  4 ++++
 tools/virsh-domain.c    | 26 ++++++++++++++++++++++++++
 2 files changed, 30 insertions(+)

diff --git a/docs/manpages/virsh.rst b/docs/manpages/virsh.rst
index da9e9f8658..4b8bbec7d6 100644
--- a/docs/manpages/virsh.rst
+++ b/docs/manpages/virsh.rst
@@ -3722,6 +3722,7 @@ migrate
       [--timeout seconds [--timeout-suspend | --timeout-postcopy]]
       [--xml file]
       [--migrate-disks disk-list] [--migrate-disks-detect-zeroes disk-list]
+      [--migrate-disks-target-zero disk-list]
       [--disks-port port]
       [--compressed] [--comp-methods method-list]
       [--comp-mt-level] [--comp-mt-threads] [--comp-mt-dthreads]
@@ -3760,6 +3761,9 @@ disk target names enables zeroed block detection for the 
listed migrated disks.
 These blocks are not transferred or allocated (requires that 'discard' option
 on given disk is set to 'unmap') on destination, effectively sparsifying the
 disk at the cost of CPU overhead.
+The *--migrate-disks-target-zero* option which takes a comma separated list of
+disk target names specifies disk images where the target was zeroed out prior
+to the migration and thus hypervisor will not attempt to zero them.
 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
diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c
index 1af7f9eb0e..a17c8b42e2 100644
--- a/tools/virsh-domain.c
+++ b/tools/virsh-domain.c
@@ -11218,6 +11218,11 @@ static const vshCmdOptDef opts_migrate[] = {
      .completer = virshDomainMigrateDisksCompleter,
      .help = N_("comma separated list of disks to be migrated with zero 
detection enabled")
     },
+    {.name = "migrate-disks-target-zero",
+     .type = VSH_OT_STRING,
+     .completer = virshDomainMigrateDisksCompleter,
+     .help = N_("comma separated list of disks to be migrated with assumption 
that target image is zeroed")
+    },
     {.name = "disks-port",
      .type = VSH_OT_INT,
      .unwanted_positional = true,
@@ -11461,6 +11466,27 @@ doMigrate(void *opaque)
         }
     }

+    if (vshCommandOptString(ctl, cmd, "migrate-disks-target-zero", &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, "%s", _("'--migrate-disks-target-zero' 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_TARGET_ZERO,
+                                        (const char **)val) < 0) {
+            goto save_error;
+        }
+    }
+
     if (vshCommandOptString(ctl, cmd, "comp-methods", &opt) < 0)
         goto out;
     if (opt) {
-- 
2.53.0

Reply via email to