WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

Re: [Xen-devel] [PATCH 6 of 8] xl: add a global configuration file

To: Stefano Stabellini <stefano.stabellini@xxxxxxxxxxxxx>
Subject: Re: [Xen-devel] [PATCH 6 of 8] xl: add a global configuration file
From: Zhigang Wang <zhigang.x.wang@xxxxxxxxxx>
Date: Fri, 27 Aug 2010 17:30:49 -0400
Cc: xen-devel@xxxxxxxxxxxxxxxxxxx
Delivery-date: Fri, 27 Aug 2010 14:33:23 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
In-reply-to: <alpine.DEB.2.00.1008271216490.2545@kaball-desktop>
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
References: <alpine.DEB.2.00.1008271216490.2545@kaball-desktop>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.7) Gecko/20100720 Fedora/3.1.1-1.fc13 Thunderbird/3.1.1
 I think we should not add configure files to xl. Instead, we may add a global
option to xl command line.

I don't want to see xl going heavy.

Thanks,

Zhigang

On 08/27/2010 07:19 AM, Stefano Stabellini wrote:
> 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.
>
> Signed-off-by: Stefano Stabellini <stefano.stabellini@xxxxxxxxxxxxx>
>
> diff -r 88da46b5c142 tools/examples/Makefile
> --- a/tools/examples/Makefile Wed Aug 25 19:56:47 2010 +0100
> +++ b/tools/examples/Makefile Wed Aug 25 20:05:34 2010 +0100
> @@ -21,6 +21,7 @@ XEN_CONFIGS += xmexample.nbd
>  XEN_CONFIGS += xmexample.vti
>  XEN_CONFIGS += xend-pci-quirks.sxp
>  XEN_CONFIGS += xend-pci-permissive.sxp
> +XEN_CONFIGS += xl.conf
>  
>  .PHONY: all
>  all:
> diff -r 88da46b5c142 tools/examples/xl.conf
> --- /dev/null Thu Jan 01 00:00:00 1970 +0000
> +++ b/tools/examples/xl.conf  Wed Aug 25 20:05:34 2010 +0100
> @@ -0,0 +1,5 @@
> +## Global XL config file ##
> +
> +# automatically balloon down dom0 when xen doesn't have enough free
> +# memory to create a domain
> +autoballon=1
> diff -r 88da46b5c142 tools/libxl/xl.c
> --- a/tools/libxl/xl.c        Wed Aug 25 19:56:47 2010 +0100
> +++ b/tools/libxl/xl.c        Wed Aug 25 20:05:34 2010 +0100
> @@ -29,18 +29,49 @@
>  
>  #include "libxl.h"
>  #include "libxl_utils.h"
> +#include "libxlutil.h"
>  #include "xl.h"
>  
>  xentoollog_logger_stdiostream *logger;
> +int autoballoon = 1;
>  
>  static xentoollog_level minmsglevel = XTL_PROGRESS;
>  
> +static void parse_global_config(const char *configfile,
> +                              const char *configfile_data,
> +                              int configfile_len)
> +{
> +    long l;
> +    XLU_Config *config;
> +    int e;
> +
> +    config = xlu_cfg_init(stderr, configfile);
> +    if (!config) {
> +        fprintf(stderr, "Failed to allocate for configuration\n");
> +        exit(1);
> +    }
> +
> +    e = xlu_cfg_readdata(config, configfile_data, configfile_len);
> +    if (e) {
> +        fprintf(stderr, "Failed to parse config file: %s\n", strerror(e));
> +        exit(1);
> +    }
> +
> +    if (!xlu_cfg_get_long (config, "autoballoon", &l))
> +        autoballoon = l;
> +
> +    xlu_cfg_destroy(config);
> +}
> + 
>  int main(int argc, char **argv)
>  {
>      int opt = 0;
>      char *cmd = 0;
>      struct cmd_spec *cspec;
>      int ret;
> +    const char *config_file = "/etc/xen/xl.conf";
> +    void *config_data = 0;
> +    int config_len = 0;
>  
>      while ((opt = getopt(argc, argv, "+v")) >= 0) {
>          switch (opt) {
> @@ -69,6 +100,14 @@ int main(int argc, char **argv)
>          exit(1);
>      }
>  
> +    /* Read global config file options */
> +    ret = libxl_read_file_contents(&ctx, config_file,
> +            &config_data, &config_len);
> +    if (ret)
> +        fprintf(stderr, "Failed to read config file: %s: %s\n",
> +                config_file, strerror(errno));
> +    parse_global_config(config_file, config_data, config_len);
> +
>      /* Reset options for per-command use of getopt. */
>      argv += optind;
>      argc -= optind;
> diff -r 88da46b5c142 tools/libxl/xl.h
> --- a/tools/libxl/xl.h        Wed Aug 25 19:56:47 2010 +0100
> +++ b/tools/libxl/xl.h        Wed Aug 25 20:05:34 2010 +0100
> @@ -90,4 +90,7 @@ struct cmd_spec *cmdtable_lookup(const c
>  extern libxl_ctx ctx;
>  extern xentoollog_logger_stdiostream *logger;
>  
> +/* global options */
> +extern int autoballoon;
> +
>  #endif /* XL_H */
>
> _______________________________________________
> Xen-devel mailing list
> Xen-devel@xxxxxxxxxxxxxxxxxxx
> http://lists.xensource.com/xen-devel


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel