This patch adds the new options (--live and --config) to "virsh setmem"
command.
The behavior of above options is the same as that of "virsh setvcpus" and so
on.
That is, when the --config option is specified, a modification is effective for
the persistent domain. Moreover we can modify the memory size of inactive domains
as well as that of active domains.
Signed-off-by: Taku Izumi <izumi.taku(a)jp.fujitsu.com>
---
tools/virsh.c | 16 ++++++++++++++--
1 file changed, 14 insertions(+), 2 deletions(-)
Index: libvirt-git/tools/virsh.c
===================================================================
--- libvirt-git.orig/tools/virsh.c
+++ libvirt-git/tools/virsh.c
@@ -2910,6 +2910,8 @@ static const vshCmdInfo info_setmem[] =
static const vshCmdOptDef opts_setmem[] = {
{"domain", VSH_OT_DATA, VSH_OFLAG_REQ, N_("domain name, id or
uuid")},
{"kilobytes", VSH_OT_INT, VSH_OFLAG_REQ, N_("number of kilobytes of
memory")},
+ {"config", VSH_OT_BOOL, 0, N_("affect next boot")},
+ {"live", VSH_OT_BOOL, 0, N_("affect running domain")},
{NULL, 0, 0, NULL}
};
@@ -2920,6 +2922,10 @@ cmdSetmem(vshControl *ctl, const vshCmd
virDomainInfo info;
unsigned long kilobytes;
int ret = TRUE;
+ int config = vshCommandOptBool(cmd, "config");
+ int live = vshCommandOptBool(cmd, "live");
+ int flags = ((config ? VIR_DOMAIN_MEM_CONFIG : 0) |
+ (live ? VIR_DOMAIN_MEM_LIVE : 0));
if (!vshConnectionUsability(ctl, ctl->conn))
return FALSE;
@@ -2947,8 +2953,14 @@ cmdSetmem(vshControl *ctl, const vshCmd
return FALSE;
}
- if (virDomainSetMemory(dom, kilobytes) != 0) {
- ret = FALSE;
+ if (!flags) {
+ if (virDomainSetMemory(dom, kilobytes) != 0) {
+ ret = FALSE;
+ }
+ } else {
+ if (virDomainSetMemoryFlags(dom, kilobytes, flags) < 0) {
+ ret = FALSE;
+ }
}
virDomainFree(dom);