mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-23 06:05:27 +00:00
setmem: add --current option to virsh setmem command
This patch adds the new option (--current) to the "virsh setmem" command. When --current option is specified, it affects a "current" domain. The word "current" denotes that if a domain is running, it affects a running domain only; otherwise it affects a persistent domain. Signed-off-by: Taku Izumi <izumi.taku@jp.fujitsu.com>
This commit is contained in:
parent
95298e2380
commit
80427f1d87
@ -2932,6 +2932,7 @@ static const vshCmdOptDef opts_setmem[] = {
|
|||||||
{"kilobytes", VSH_OT_INT, VSH_OFLAG_REQ, N_("number of kilobytes of memory")},
|
{"kilobytes", VSH_OT_INT, VSH_OFLAG_REQ, N_("number of kilobytes of memory")},
|
||||||
{"config", VSH_OT_BOOL, 0, N_("affect next boot")},
|
{"config", VSH_OT_BOOL, 0, N_("affect next boot")},
|
||||||
{"live", VSH_OT_BOOL, 0, N_("affect running domain")},
|
{"live", VSH_OT_BOOL, 0, N_("affect running domain")},
|
||||||
|
{"current", VSH_OT_BOOL, 0, N_("affect current domain")},
|
||||||
{NULL, 0, 0, NULL}
|
{NULL, 0, 0, NULL}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -2944,14 +2945,23 @@ cmdSetmem(vshControl *ctl, const vshCmd *cmd)
|
|||||||
int ret = TRUE;
|
int ret = TRUE;
|
||||||
int config = vshCommandOptBool(cmd, "config");
|
int config = vshCommandOptBool(cmd, "config");
|
||||||
int live = vshCommandOptBool(cmd, "live");
|
int live = vshCommandOptBool(cmd, "live");
|
||||||
|
int current = vshCommandOptBool(cmd, "current");
|
||||||
int flags = 0;
|
int flags = 0;
|
||||||
|
|
||||||
/* Need to use flags if config was specified, but prefer older api
|
if (current) {
|
||||||
* for live-only behavior otherwise */
|
if (live || config) {
|
||||||
if (config) {
|
vshError(ctl, "%s", _("--current must be specified exclusively"));
|
||||||
flags = VIR_DOMAIN_MEM_CONFIG;
|
return FALSE;
|
||||||
|
}
|
||||||
|
flags = VIR_DOMAIN_MEM_CURRENT;
|
||||||
|
} else {
|
||||||
|
if (config)
|
||||||
|
flags |= VIR_DOMAIN_MEM_CONFIG;
|
||||||
if (live)
|
if (live)
|
||||||
flags |= VIR_DOMAIN_MEM_LIVE;
|
flags |= VIR_DOMAIN_MEM_LIVE;
|
||||||
|
/* neither option is specified */
|
||||||
|
if (!live && !config)
|
||||||
|
flags = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!vshConnectionUsability(ctl, ctl->conn))
|
if (!vshConnectionUsability(ctl, ctl->conn))
|
||||||
@ -2984,7 +2994,7 @@ cmdSetmem(vshControl *ctl, const vshCmd *cmd)
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!flags) {
|
if (flags == -1) {
|
||||||
if (virDomainSetMemory(dom, kilobytes) != 0) {
|
if (virDomainSetMemory(dom, kilobytes) != 0) {
|
||||||
ret = FALSE;
|
ret = FALSE;
|
||||||
}
|
}
|
||||||
|
@ -583,11 +583,15 @@ B<Note>: The weight and cap parameters are defined only for the
|
|||||||
XEN_CREDIT scheduler and are now I<DEPRECATED>.
|
XEN_CREDIT scheduler and are now I<DEPRECATED>.
|
||||||
|
|
||||||
=item B<setmem> I<domain-id> B<kilobytes> optional I<--config> I<--live>
|
=item B<setmem> I<domain-id> B<kilobytes> optional I<--config> I<--live>
|
||||||
|
I<--current>
|
||||||
|
|
||||||
Change the memory allocation for a guest domain.
|
Change the memory allocation for a guest domain.
|
||||||
If I<--live> is specified, perform a memory balloon of a running guest.
|
If I<--live> is specified, perform a memory balloon of a running guest.
|
||||||
If I<--config> is specified, affect the next boot of a persistent guest.
|
If I<--config> is specified, affect the next boot of a persistent guest.
|
||||||
Both flags may be given. If neither flag is given, I<--live> is assumed.
|
If I<--current> is specified, affect the current guest state.
|
||||||
|
Both I<--live> and I<--config> flags may be given, but I<--current> is
|
||||||
|
exclusive. If no flag is specified, behavior is different depending
|
||||||
|
on hypervisor.
|
||||||
|
|
||||||
Some hypervisors require a larger granularity than kilobytes, and requests
|
Some hypervisors require a larger granularity than kilobytes, and requests
|
||||||
that are not an even multiple will be rounded up. For example, vSphere/ESX
|
that are not an even multiple will be rounded up. For example, vSphere/ESX
|
||||||
|
Loading…
Reference in New Issue
Block a user