xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Stefan Bader <stefan.bader@canonical.com>
To: Ian Campbell <Ian.Campbell@citrix.com>
Cc: "xen-devel@lists.xensource.com" <xen-devel@lists.xensource.com>
Subject: Re: Default bridge for xl
Date: Fri, 10 Feb 2012 18:38:41 +0100	[thread overview]
Message-ID: <4F355621.7050900@canonical.com> (raw)
In-Reply-To: <1328889108.6133.272.camel@zakaz.uk.xensource.com>

[-- Attachment #1: Type: text/plain, Size: 3777 bytes --]

On 10.02.2012 16:51, Ian Campbell wrote:
> On Fri, 2012-02-10 at 15:44 +0000, Stefan Bader wrote:
>> If I did not miss something, it looks to me like guests started with xl will use
>> the bridge specified in the guest config or xenbr0 as a default.
>> Just wondering whether adding a defaultbridge config option to xl.conf would be
>> considered a waste of time (because its not desired to have that) or some worth
>> of adding when I would come up with a patch?
> 
> Sounds useful enough to me.
> 
> Ian.
> 
> 
> 
> _______________________________________________
> Xen-devel mailing list
> Xen-devel@lists.xensource.com
> http://lists.xensource.com/xen-devel

So maybe the following is good. Hopefully not introduced any stupid typos while
moving it from the version where it was tested to HEAD.

-Stefan


>From d58ebda4fbe831b491d43a6988f3006b8f1a9825 Mon Sep 17 00:00:00 2001
From: Stefan Bader <stefan.bader@canonical.com>
Date: Fri, 10 Feb 2012 18:03:26 +0100
Subject: [PATCH] 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 <stefan.bader@canonical.com>
---
 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(+), 0 deletions(-)

diff --git a/docs/man/xl.conf.pod.5 b/docs/man/xl.conf.pod.5
index 8837eb1..85752fb 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</etc/xen/scripts/vif-bridge>

+=item B<defaultbridge="NAME">
+
+Configures the default bridge to set for virtual network devices.
+
+Default: C<xenbr0>
+
 =item B<output_format="json|sxp">

 Configures the default output format used by xl when printing "machine
diff --git a/tools/libxl/xl.c b/tools/libxl/xl.c
index 9dac998..df9b1e7 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 a852a43..702b208 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 61ca902..05d8ef3 100644
--- a/tools/libxl/xl_cmdimpl.c
+++ b/tools/libxl/xl_cmdimpl.c
@@ -842,6 +842,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;
-- 
1.7.5.4

[-- Attachment #2: 0001-Add-defaultbridge-config-option-for-xl.conf.patch --]
[-- Type: text/x-diff, Size: 2975 bytes --]

>From d58ebda4fbe831b491d43a6988f3006b8f1a9825 Mon Sep 17 00:00:00 2001
From: Stefan Bader <stefan.bader@canonical.com>
Date: Fri, 10 Feb 2012 18:03:26 +0100
Subject: [PATCH] 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 <stefan.bader@canonical.com>
---
 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(+), 0 deletions(-)

diff --git a/docs/man/xl.conf.pod.5 b/docs/man/xl.conf.pod.5
index 8837eb1..85752fb 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</etc/xen/scripts/vif-bridge>
 
+=item B<defaultbridge="NAME">
+
+Configures the default bridge to set for virtual network devices.
+
+Default: C<xenbr0>
+
 =item B<output_format="json|sxp">
 
 Configures the default output format used by xl when printing "machine
diff --git a/tools/libxl/xl.c b/tools/libxl/xl.c
index 9dac998..df9b1e7 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 a852a43..702b208 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 61ca902..05d8ef3 100644
--- a/tools/libxl/xl_cmdimpl.c
+++ b/tools/libxl/xl_cmdimpl.c
@@ -842,6 +842,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;
-- 
1.7.5.4


[-- Attachment #3: Type: text/plain, Size: 138 bytes --]

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

  reply	other threads:[~2012-02-10 17:38 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-02-10 15:44 Default bridge for xl Stefan Bader
2012-02-10 15:51 ` Ian Campbell
2012-02-10 17:38   ` Stefan Bader [this message]
2012-02-13 17:45     ` Ian Jackson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4F355621.7050900@canonical.com \
    --to=stefan.bader@canonical.com \
    --cc=Ian.Campbell@citrix.com \
    --cc=xen-devel@lists.xensource.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).