virsh: migrate: Add support for VIR_MIGRATE_PARAM_MIGRATE_DISKS_TARGET_ZERO

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

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
Peter Krempa
2026-03-24 17:59:16 +01:00
parent f5fc45efea
commit 623844bf2a
2 changed files with 30 additions and 0 deletions
+4
View File
@@ -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
+26
View File
@@ -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) {