virsh: Add migrate-compcache command

This is a command wrapping virDomainMigrateGetCompressionCache and
virDomainMigrateSetCompressionCache.
This commit is contained in:
Jiri Denemark 2013-02-18 21:14:49 +01:00
parent be80186732
commit e94aeb1428
2 changed files with 80 additions and 0 deletions

View File

@ -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,

View File

@ -1114,6 +1114,18 @@ Set maximum tolerable downtime for a domain which is being live-migrated to
another host. The I<downtime> is a number of milliseconds the guest is allowed
to be down at the end of live migration.
=item B<migrate-compcache> I<domain> [I<--size> B<bytes>]
Sets and/or gets size of the cache (in bytes) used for compressing repeatedly
transferred memory pages during live migration. When called without I<size>,
the command just prints current size of the compression cache. When I<size>
is specified, the hypervisor is asked to change compression cache to I<size>
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<size> 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<migrate-setspeed> I<domain> I<bandwidth>
Set the maximum migration bandwidth (in Mbps) for a domain which is being