memtune: Add min_guarantee to the virsh memtune command

* tools/virsh.c: Add new memory tunable "min_guarantee", currently only
  ESX can use this
* tools/virsh.pod: Update the manpage
This commit is contained in:
Nikunj A. Dadhania 2010-10-19 14:45:35 +02:00 committed by Daniel Veillard
parent 61dfbf8c3a
commit 0a22f54248
2 changed files with 16 additions and 3 deletions

View File

@ -2693,6 +2693,8 @@ static const vshCmdOptDef opts_memtune[] = {
N_("Memory during contention in kilobytes")},
{VIR_DOMAIN_SWAP_HARD_LIMIT, VSH_OT_STRING, VSH_OFLAG_NONE,
N_("Max swap in kilobytes")},
{VIR_DOMAIN_MEMORY_MIN_GUARANTEE, VSH_OT_STRING, VSH_OFLAG_NONE,
N_("Min guaranteed memory in kilobytes")},
{NULL, 0, 0, NULL}
};
@ -2700,7 +2702,7 @@ static int
cmdMemtune(vshControl * ctl, const vshCmd * cmd)
{
virDomainPtr dom;
int hard_limit, soft_limit, swap_hard_limit;
int hard_limit, soft_limit, swap_hard_limit, min_guarantee;
int nparams = 0;
unsigned int i = 0;
virMemoryParameterPtr params = NULL, temp = NULL;
@ -2728,6 +2730,12 @@ cmdMemtune(vshControl * ctl, const vshCmd * cmd)
if (swap_hard_limit)
nparams++;
min_guarantee =
vshCommandOptInt(cmd, VIR_DOMAIN_MEMORY_MIN_GUARANTEE,
&min_guarantee);
if (min_guarantee)
nparams++;
if (nparams == 0) {
/* get the number of memory parameters */
if ((virDomainGetMemoryParameters(dom, NULL, &nparams, 0) != 0) &&
@ -2772,7 +2780,7 @@ cmdMemtune(vshControl * ctl, const vshCmd * cmd)
params[i].value.b);
break;
default:
vshPrint(ctl, "unimplemented scheduler parameter type\n");
vshPrint(ctl, "unimplemented memory parameter type\n");
}
}
@ -2807,6 +2815,11 @@ cmdMemtune(vshControl * ctl, const vshCmd * cmd)
strncpy(temp->field, VIR_DOMAIN_SWAP_HARD_LIMIT,
sizeof(temp->field));
swap_hard_limit = 0;
} else if (min_guarantee) {
temp->value.ul = min_guarantee;
strncpy(temp->field, VIR_DOMAIN_MEMORY_MIN_GUARANTEE,
sizeof(temp->field));
min_guarantee = 0;
}
}
if (virDomainSetMemoryParameters(dom, params, nparams, 0) != 0)

View File

@ -517,7 +517,7 @@ kilobytes.
Displays the domain memory parameters.
=item B<memtune> I<domain-id> optional I<--hard-limit> B<kilobytes> optional I<--soft-limit> B<kilobytes> optional I<--swap-hard-limit> B<kilobytes>
=item B<memtune> I<domain-id> optional I<--hard-limit> B<kilobytes> optional I<--soft-limit> B<kilobytes> optional I<--swap-hard-limit> B<kilobytes> -I<--min-guarantee> B<kilobytes>
Allows you to set the domain memory parameters. LXC and QEMU/KVM supports these parameters.