diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c index 2b70054b32..96dd4fabd8 100644 --- a/tools/virsh-domain.c +++ b/tools/virsh-domain.c @@ -8735,6 +8735,68 @@ done: return ret; } +/* + * "migrate-compcache" command + */ +static const vshCmdInfo info_migrate_compcache[] = { + {.name = "help", + .data = N_("get/set compression cache size") + }, + {.name = "desc", + .data = N_("Get/set size of the cache (in bytes) used for compressing " + "repeatedly transferred memory pages during live migration.") + }, + {.name = NULL} +}; + +static const vshCmdOptDef opts_migrate_compcache[] = { + {.name = "domain", + .type = VSH_OT_DATA, + .flags = VSH_OFLAG_REQ, + .help = N_("domain name, id or uuid") + }, + {.name = "size", + .type = VSH_OT_INT, + .flags = VSH_OFLAG_REQ_OPT, + .help = N_("requested size of the cache (in bytes) used for compression") + }, + {.name = NULL} +}; + +static bool +cmdMigrateCompCache(vshControl *ctl, const vshCmd *cmd) +{ + virDomainPtr dom = NULL; + unsigned long long size = 0; + bool ret = false; + const char *unit; + double value; + int rc; + + if (!(dom = vshCommandOptDomain(ctl, cmd, NULL))) + return false; + + rc = vshCommandOptULongLong(cmd, "size", &size); + if (rc < 0) { + vshError(ctl, "%s", _("Unable to parse size parameter")); + goto cleanup; + } else if (rc != 0) { + if (virDomainMigrateSetCompressionCache(dom, size, 0) < 0) + goto cleanup; + } + + if (virDomainMigrateGetCompressionCache(dom, &size, 0) < 0) + goto cleanup; + + value = vshPrettyCapacity(size, &unit); + vshPrint(ctl, _("Compression cache: %.3lf %s"), value, unit); + + ret = true; +cleanup: + virDomainFree(dom); + return ret; +} + /* * "migrate-setspeed" command */ @@ -10679,6 +10741,12 @@ const vshCmdDef domManagementCmds[] = { .info = info_migrate_setmaxdowntime, .flags = 0 }, + {.name = "migrate-compcache", + .handler = cmdMigrateCompCache, + .opts = opts_migrate_compcache, + .info = info_migrate_compcache, + .flags = 0 + }, {.name = "migrate-setspeed", .handler = cmdMigrateSetMaxSpeed, .opts = opts_migrate_setspeed, diff --git a/tools/virsh.pod b/tools/virsh.pod index e67585029d..a5d8fe6021 100644 --- a/tools/virsh.pod +++ b/tools/virsh.pod @@ -1114,6 +1114,18 @@ Set maximum tolerable downtime for a domain which is being live-migrated to another host. The I is a number of milliseconds the guest is allowed to be down at the end of live migration. +=item B I [I<--size> B] + +Sets and/or gets size of the cache (in bytes) used for compressing repeatedly +transferred memory pages during live migration. When called without I, +the command just prints current size of the compression cache. When I +is specified, the hypervisor is asked to change compression cache to I +bytes and then the current size is printed (the result may differ from the +requested size due to rounding done by the hypervisor). The I option +is supposed to be used while the domain is being live-migrated as a reaction +to migration progress and increasing number of compression cache misses +obtained from domjobinfo. + =item B I I Set the maximum migration bandwidth (in Mbps) for a domain which is being