On 03/22/2011 11:49 PM, Taku Izumi wrote:
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(a)jp.fujitsu.com>
---
tools/virsh.c | 20 +++++++++++++++-----
tools/virsh.pod | 7 +++++--
All right - you remembered to update the docs at the same time!
+ if (current) {
+ if (live || config) {
+ vshError(ctl, "%s", _("--current must be specified
exclusively"));
+ return FALSE;
+ }
+ flags = VIR_DOMAIN_MEM_CURRENT;
+ } else {
+ if (config)
+ flags |= VIR_DOMAIN_MEM_CONFIG;
if (live)
flags |= VIR_DOMAIN_MEM_LIVE;
+ /* neither option is specified */
+ if (!live && !config)
+ flags = -1;
}
if (!vshConnectionUsability(ctl, ctl->conn))
@@ -2972,7 +2982,7 @@ cmdSetmem(vshControl *ctl, const vshCmd
return FALSE;
}
- if (!flags) {
+ if (flags == -1) {
if (virDomainSetMemory(dom, kilobytes) != 0) {
Looks reasonable.
+++ libvirt/tools/virsh.pod
@@ -578,12 +578,15 @@ Therefore, -1 is a useful shorthand for
B<Note>: The weight and cap parameters are defined only for the
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>
I wrapped this at 80 columns.
Change the memory allocation for a guest domain.
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.
-Both flags may be given. If neither flag is given, I<--live> is assumed.
+If I<--current> is specified, affect a current guest.
I tweaked this to 'current guest state (active or persistent)'.
+Both I<--live> and I<--config> flags may be given, but
I<--current> is
+exclusive. If neither flag is specified, behavior is different depending
+on hypervisor.
ACK and applied.
--
Eric Blake eblake(a)redhat.com +1-801-349-2682
Libvirt virtualization library
http://libvirt.org