virsh: Add support for VIR_MIGRATE_PARAM_MIGRATE_DISKS_DETECT_ZEROES migration parameter

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>
This commit is contained in:
Peter Krempa 2024-09-27 15:18:50 +02:00
parent 621f879adf
commit 89ce634253
2 changed files with 33 additions and 1 deletions

View 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

View 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) {