debuggers.hg
changeset 22247:4aac6084fdc5
xl: add a global configuration file
Add a global configuration file: /etc/xen/xl.conf; the only option
currently parsed is autoballoon that is 1 by default.
[fixed up for conflicts with libxl__ naming policy changes -iwj]
Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
Add a global configuration file: /etc/xen/xl.conf; the only option
currently parsed is autoballoon that is 1 by default.
[fixed up for conflicts with libxl__ naming policy changes -iwj]
Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
author | Stefano Stabellini <stefano.stabellini@eu.citrix.com> |
---|---|
date | Wed Sep 22 17:42:01 2010 +0100 (2010-09-22) |
parents | 49a3c1721734 |
children | 0afdfb8b460f |
files | tools/examples/Makefile tools/examples/xl.conf tools/libxl/xl.c tools/libxl/xl.h |
line diff
1.1 --- a/tools/examples/Makefile Wed Sep 22 17:40:44 2010 +0100 1.2 +++ b/tools/examples/Makefile Wed Sep 22 17:42:01 2010 +0100 1.3 @@ -21,6 +21,7 @@ XEN_CONFIGS += xmexample.nbd 1.4 XEN_CONFIGS += xmexample.vti 1.5 XEN_CONFIGS += xend-pci-quirks.sxp 1.6 XEN_CONFIGS += xend-pci-permissive.sxp 1.7 +XEN_CONFIGS += xl.conf 1.8 1.9 .PHONY: all 1.10 all:
2.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 2.2 +++ b/tools/examples/xl.conf Wed Sep 22 17:42:01 2010 +0100 2.3 @@ -0,0 +1,5 @@ 2.4 +## Global XL config file ## 2.5 + 2.6 +# automatically balloon down dom0 when xen doesn't have enough free 2.7 +# memory to create a domain 2.8 +autoballon=1
3.1 --- a/tools/libxl/xl.c Wed Sep 22 17:40:44 2010 +0100 3.2 +++ b/tools/libxl/xl.c Wed Sep 22 17:42:01 2010 +0100 3.3 @@ -29,18 +29,49 @@ 3.4 3.5 #include "libxl.h" 3.6 #include "libxl_utils.h" 3.7 +#include "libxlutil.h" 3.8 #include "xl.h" 3.9 3.10 xentoollog_logger_stdiostream *logger; 3.11 +int autoballoon = 1; 3.12 3.13 static xentoollog_level minmsglevel = XTL_PROGRESS; 3.14 3.15 +static void parse_global_config(const char *configfile, 3.16 + const char *configfile_data, 3.17 + int configfile_len) 3.18 +{ 3.19 + long l; 3.20 + XLU_Config *config; 3.21 + int e; 3.22 + 3.23 + config = xlu_cfg_init(stderr, configfile); 3.24 + if (!config) { 3.25 + fprintf(stderr, "Failed to allocate for configuration\n"); 3.26 + exit(1); 3.27 + } 3.28 + 3.29 + e = xlu_cfg_readdata(config, configfile_data, configfile_len); 3.30 + if (e) { 3.31 + fprintf(stderr, "Failed to parse config file: %s\n", strerror(e)); 3.32 + exit(1); 3.33 + } 3.34 + 3.35 + if (!xlu_cfg_get_long (config, "autoballoon", &l)) 3.36 + autoballoon = l; 3.37 + 3.38 + xlu_cfg_destroy(config); 3.39 +} 3.40 + 3.41 int main(int argc, char **argv) 3.42 { 3.43 int opt = 0; 3.44 char *cmd = 0; 3.45 struct cmd_spec *cspec; 3.46 int ret; 3.47 + char *config_file; 3.48 + void *config_data = 0; 3.49 + int config_len = 0; 3.50 3.51 while ((opt = getopt(argc, argv, "+v")) >= 0) { 3.52 switch (opt) { 3.53 @@ -69,6 +100,21 @@ int main(int argc, char **argv) 3.54 exit(1); 3.55 } 3.56 3.57 + /* Read global config file options */ 3.58 + ret = asprintf(&config_file, "%s/xl.conf", libxl_xen_config_dir_path()); 3.59 + if (ret < 0) { 3.60 + fprintf(stderr, "memory allocation failed ret=%d, errno=%d\n", ret, errno); 3.61 + exit(1); 3.62 + } 3.63 + 3.64 + ret = libxl_read_file_contents(&ctx, config_file, 3.65 + &config_data, &config_len); 3.66 + if (ret) 3.67 + fprintf(stderr, "Failed to read config file: %s: %s\n", 3.68 + config_file, strerror(errno)); 3.69 + parse_global_config(config_file, config_data, config_len); 3.70 + free(config_file); 3.71 + 3.72 /* Reset options for per-command use of getopt. */ 3.73 argv += optind; 3.74 argc -= optind;
4.1 --- a/tools/libxl/xl.h Wed Sep 22 17:40:44 2010 +0100 4.2 +++ b/tools/libxl/xl.h Wed Sep 22 17:42:01 2010 +0100 4.3 @@ -90,4 +90,7 @@ struct cmd_spec *cmdtable_lookup(const c 4.4 extern libxl_ctx ctx; 4.5 extern xentoollog_logger_stdiostream *logger; 4.6 4.7 +/* global options */ 4.8 +extern int autoballoon; 4.9 + 4.10 #endif /* XL_H */