From ee31367567e0ad72ccf58f34b7991db8beb7eb16 Mon Sep 17 00:00:00 2001 From: Stefan Bader Date: Mon, 13 Feb 2012 17:45:13 +0000 Subject: [PATCH] xl: Add defaultbridge config option for xl.conf Currently guests created with the xl stack will have "xenbr0" written as their default into xenstore. It can be changed in the individual guest config files, but there is no way to have that default globally changed. Add a config option to xl.conf that allows to have a different default bridge name. Signed-off-by: Stefan Bader Acked-by: Ian Jackson Committed-by: Ian Jackson --- docs/man/xl.conf.pod.5 | 6 ++++++ tools/libxl/xl.c | 4 ++++ tools/libxl/xl.h | 1 + tools/libxl/xl_cmdimpl.c | 5 +++++ 4 files changed, 16 insertions(+) diff --git a/docs/man/xl.conf.pod.5 b/docs/man/xl.conf.pod.5 index 8837eb11e..85752fbf5 100644 --- a/docs/man/xl.conf.pod.5 +++ b/docs/man/xl.conf.pod.5 @@ -68,6 +68,12 @@ Configures the default hotplug script used by virtual network devices. Default: C +=item B + +Configures the default bridge to set for virtual network devices. + +Default: C + =item B Configures the default output format used by xl when printing "machine diff --git a/tools/libxl/xl.c b/tools/libxl/xl.c index 9dac99842..df9b1e752 100644 --- a/tools/libxl/xl.c +++ b/tools/libxl/xl.c @@ -38,6 +38,7 @@ int dryrun_only; int autoballoon = 1; char *lockfile; char *default_vifscript = NULL; +char *default_bridge = NULL; enum output_format default_output_format = OUTPUT_FORMAT_JSON; static xentoollog_level minmsglevel = XTL_PROGRESS; @@ -79,6 +80,9 @@ static void parse_global_config(const char *configfile, if (!xlu_cfg_get_string (config, "vifscript", &buf, 0)) default_vifscript = strdup(buf); + if (!xlu_cfg_get_string (config, "defaultbridge", &buf, 0)) + default_bridge = strdup(buf); + if (!xlu_cfg_get_string (config, "output_format", &buf, 0)) { if (!strcmp(buf, "json")) default_output_format = OUTPUT_FORMAT_JSON; diff --git a/tools/libxl/xl.h b/tools/libxl/xl.h index a852a43d3..702b208b1 100644 --- a/tools/libxl/xl.h +++ b/tools/libxl/xl.h @@ -110,6 +110,7 @@ extern int autoballoon; extern int dryrun_only; extern char *lockfile; extern char *default_vifscript; +extern char *default_bridge; enum output_format { OUTPUT_FORMAT_JSON, diff --git a/tools/libxl/xl_cmdimpl.c b/tools/libxl/xl_cmdimpl.c index efc03ceba..c58e9f3f2 100644 --- a/tools/libxl/xl_cmdimpl.c +++ b/tools/libxl/xl_cmdimpl.c @@ -840,6 +840,11 @@ static void parse_config_data(const char *configfile_filename_report, nic->script = strdup(default_vifscript); } + if (default_bridge) { + free(nic->bridge); + nic->bridge = strdup(default_bridge); + } + p = strtok(buf2, ","); if (!p) goto skip; -- 2.39.5