[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-devel] [PATCH v3 2/3] xl: Allow user to configure xl mem-set behavior



Add mem_set_enforce_limit option to xl.conf file and equivalent xl
command line option. Those two things give a chance to align xl mem-set
behavior to xm mem-set behavior. Default xl mem-set behavior is not changed.

v3 - suggestions/fixes:
   - add xl command line option
     (suggested by Ian Jackson).

Signed-off-by: Daniel Kiper <daniel.kiper@xxxxxxxxxx>
---
 tools/libxl/xl.c          |    4 ++++
 tools/libxl/xl.h          |    1 +
 tools/libxl/xl_cmdimpl.c  |   16 ++++++++++------
 tools/libxl/xl_cmdtable.c |    3 ++-
 4 files changed, 17 insertions(+), 7 deletions(-)

diff --git a/tools/libxl/xl.c b/tools/libxl/xl.c
index 4c598db..5c445ca 100644
--- a/tools/libxl/xl.c
+++ b/tools/libxl/xl.c
@@ -38,6 +38,7 @@ xentoollog_logger_stdiostream *logger;
 int dryrun_only;
 int force_execution;
 int autoballoon = 1;
+int mem_set_enforce_limit = 1;
 char *blkdev_start;
 int run_hotplug_scripts = 1;
 char *lockfile;
@@ -72,6 +73,9 @@ static void parse_global_config(const char *configfile,
     if (!xlu_cfg_get_long (config, "autoballoon", &l, 0))
         autoballoon = l;
 
+    if (!xlu_cfg_get_long (config, "mem_set_enforce_limit", &l, 0))
+        mem_set_enforce_limit = l;
+
     if (!xlu_cfg_get_long (config, "run_hotplug_scripts", &l, 0))
         run_hotplug_scripts = l;
 
diff --git a/tools/libxl/xl.h b/tools/libxl/xl.h
index b881f92..321a0d0 100644
--- a/tools/libxl/xl.h
+++ b/tools/libxl/xl.h
@@ -143,6 +143,7 @@ int xl_child_pid(xlchildnum); /* returns 0 if child struct 
is not in use */
 
 /* global options */
 extern int autoballoon;
+extern int mem_set_enforce_limit;
 extern int run_hotplug_scripts;
 extern int dryrun_only;
 extern char *lockfile;
diff --git a/tools/libxl/xl_cmdimpl.c b/tools/libxl/xl_cmdimpl.c
index 2d40f8f..a0ff3e5 100644
--- a/tools/libxl/xl_cmdimpl.c
+++ b/tools/libxl/xl_cmdimpl.c
@@ -2495,7 +2495,7 @@ int main_memmax(int argc, char **argv)
     return 0;
 }
 
-static void set_memory_target(uint32_t domid, const char *mem)
+static void set_memory_target(uint32_t domid, const char *mem, int 
enforce_limit)
 {
     long long int memorykb;
 
@@ -2505,23 +2505,27 @@ static void set_memory_target(uint32_t domid, const 
char *mem)
         exit(3);
     }
 
-    libxl_set_memory_target(ctx, domid, memorykb, 0, /* enforce */ 1);
+    libxl_set_memory_target(ctx, domid, memorykb, 0, enforce_limit);
 }
 
 int main_memset(int argc, char **argv)
 {
     uint32_t domid;
-    int opt = 0;
+    int enforce_limit, opt = 0;
     const char *mem;
 
-    SWITCH_FOREACH_OPT(opt, "", NULL, "mem-set", 2) {
-        /* No options */
+    enforce_limit = mem_set_enforce_limit;
+
+    SWITCH_FOREACH_OPT(opt, "e:", NULL, "mem-set", 2) {
+    case 'e':
+        enforce_limit = atoi(optarg) ? 1 : 0;
+        break;
     }
 
     domid = find_domain(argv[optind]);
     mem = argv[optind + 1];
 
-    set_memory_target(domid, mem);
+    set_memory_target(domid, mem, enforce_limit);
     return 0;
 }
 
diff --git a/tools/libxl/xl_cmdtable.c b/tools/libxl/xl_cmdtable.c
index b4a87ca..5cfdb70 100644
--- a/tools/libxl/xl_cmdtable.c
+++ b/tools/libxl/xl_cmdtable.c
@@ -195,7 +195,8 @@ struct cmd_spec cmd_table[] = {
     { "mem-set",
       &main_memset, 0, 1,
       "Set the current memory usage for a domain",
-      "<Domain> <MemMB['b'[bytes]|'k'[KB]|'m'[MB]|'g'[GB]|'t'[TB]]>",
+      "[-e <0|1>] <Domain> 
<MemMB['b'[bytes]|'k'[KB]|'m'[MB]|'g'[GB]|'t'[TB]]>",
+      "-e <0|1> (Not)Enforce maximum memory allocation for a domain"
     },
     { "button-press",
       &main_button_press, 0, 1,
-- 
1.7.10.4


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.