xl/libxl: add gatewaydev/netdev to vif specification
PATCH v3 1/4 xl/libxl: add gatewaydev/netdev to vif specification
This option is used by the vif-route hotplug script. A new more descriptive name is used, "gatewaydev", but "netdev" is also supported as a deprecated backwards compatible option.
This option was supported in the past, according to
http://wiki.xen.org/wiki/Vif-route, so we should also support it in libxl.
---
Changes since v1:
* Don't pass a NULL as a value of a env variable
* Change netdev to gatewaydev
--- docs/misc/xl-network-configuration.markdown | 10 ++++++++++ tools/libxl/libxl.c | 6 +++++- tools/libxl/libxl_linux.c | 9 ++++++++- tools/libxl/libxl_types.idl | 1 + tools/libxl/xl_cmdimpl.c | 14 ++++++++++++++ 5 files changed, 38 insertions(+), 2 deletions(-)
docs/misc/xl-network-configuration.markdown +10 -0
@@ -67,6 +67,15 @@ added to. The default is `xenbr0`. The bridge must be configured using your distribution's network configuration tools. See the [wiki][net] for guidance and examples. +### gatewaydev + +Specifies the name of the network interface which has an IP and which +is in the network the VIF should communicate with. This is used in the host +by the vif-route hotplug script. See [wiki][vifroute] for guidance and +examples. + +NOTE: netdev is a deprecated alias of this option. + ### type This keyword is valid for HVM guests only.
@@ -158,3 +167,4 @@ on the underlying netback implementation. [oui]: http://en.wikipedia.org/wiki/Organizationally_Unique_Identifier [net]: http://wiki.xen.org/wiki/HostConfiguration/Networking +[vifroute]: http://wiki.xen.org/wiki/Vif-route
tools/libxl/libxl.c +5 -1
@@ -2826,7 +2826,7 @@ void libxl__device_nic_add(libxl__egc *egc, uint32_t domid,if (rc) goto out; front =flexarray_make (gc,16 ,1 ); - back =flexarray_make (gc,16 ,1 ); + back =flexarray_make (gc,18 ,1 );if (nic->devid ==-1 ) {if ((nic->devid =libxl__device_nextid (gc, domid,"vif" ) <0 )) {
@@ -2862,6 +2862,10 @@ void libxl__device_nic_add(libxl__egc *egc, uint32_t domid,flexarray_append (back,"ip" );flexarray_append (back,libxl__strdup (gc, nic->ip)); } +if (nic->gatewaydev) { +flexarray_append (back,"gatewaydev" ); +flexarray_append (back,libxl__strdup (gc, nic->gatewaydev)); + }if (nic->rate_interval_usecs >0 ) {flexarray_append (back,"rate" );
tools/libxl/libxl_linux.c +8 -1
@@ -84,11 +84,16 @@ static char **get_hotplug_env(libxl__gc *gc, char *script, libxl__device *dev) {const char *type =libxl__device_kind_to_string (dev->backend_kind); +char *be_path =libxl__device_backend_path (gc, dev);char **env; +char *gatewaydev;int nr =0 ;libxl_nic_type nictype; -const int arraysize =13 ; + gatewaydev =libxl__xs_read (gc,XBT_NULL ,GCSPRINTF ("%s/%s" , be_path, +"gatewaydev" )); + +const int arraysize =15 ;GCNEW_ARRAY (env, arraysize); env[nr++] ="script" ; env[nr++] = script;
@@ -98,6 +103,8 @@ static char **get_hotplug_env(libxl__gc *gc, env[nr++] =GCSPRINTF ("backend/%s/%u/%d" , type, dev->domid, dev->devid); env[nr++] ="XENBUS_BASE_PATH" ; env[nr++] ="backend" ; + env[nr++] ="netdev" ; + env[nr++] = gatewaydev ? :"" ;if (dev->backend_kind ==LIBXL__DEVICE_KIND_VIF ) {if (libxl__nic_type (gc, dev, &nictype)) {LOG (ERROR ,"unable to get nictype" );
tools/libxl/libxl_types.idl +1 -0
@@ -385,6 +385,7 @@ libxl_device_nic = Struct("device_nic", [ ("nictype", libxl_nic_type), ("rate_bytes_per_interval", uint64), ("rate_interval_usecs", uint32), + ("gatewaydev", string), ]) libxl_device_pci = Struct("device_pci", [
tools/libxl/xl_cmdimpl.c +14 -0
@@ -1210,6 +1210,14 @@ static void parse_config_data(const char *config_source,parse_vif_rate (&config, (p2 +1 ), nic); }else if (!strcmp (p,"accel" )) {fprintf (stderr,"the accel parameter for vifs is currently not supported\n" ); + }else if (!strcmp (p,"netdev" )) { +fprintf (stderr,"the netdev parameter is deprecated, " +"please use gatewaydev instead\n" ); +free (nic->gatewaydev); + nic->gatewaydev =strdup (p2 +1 ); + }else if (!strcmp (p,"gatewaydev" )) { +free (nic->gatewaydev); + nic->gatewaydev =strdup (p2 +1 ); } }while ((p =strtok (NULL ,"," )) !=NULL ); skip_nic:
@@ -5494,6 +5502,12 @@ int main_networkattach(int argc, char **argv) } }else if (MATCH_OPTION ("bridge" , *argv, oparg)) {replace_string (&nic.bridge, oparg); + }else if (MATCH_OPTION ("netdev" , *argv, oparg)) { +fprintf (stderr,"the netdev parameter is deprecated, " +"please use gatewaydev instead\n" ); +replace_string (&nic.gatewaydev, oparg); + }else if (MATCH_OPTION ("gatewaydev" , *argv, oparg)) { +replace_string (&nic.gatewaydev, oparg); }else if (MATCH_OPTION ("ip" , *argv, oparg)) {replace_string (&nic.ip, oparg); }else if (MATCH_OPTION ("script" , *argv, oparg)) {
Signature · 7 lines
1.7.7.5 (Apple Git-26) _______________________________________________ Xen-devel mailing list [email protected] http://lists.xen.org/xen-devel
PATCH v3 2/4 xl: allow specifying a default gatewaydev in xl.conf
This adds a new global option in the xl configuration file called "vif.default.gatewaydev", that is used to specify the default gatewaydev to use when none is passed in the vif specification.
---
Changes since v1:
* Rename defaultnetdev to vif.default.gatewaydev
Changes since v2:
* Added a comment describing the nomenclature used in default options
--- docs/man/xl.conf.pod.5 | 6 ++++++ tools/examples/xl.conf | 3 +++ tools/libxl/xl.c | 14 ++++++++++++++ tools/libxl/xl.h | 1 + tools/libxl/xl_cmdimpl.c | 5 +++++ 5 files changed, 29 insertions(+), 0 deletions(-)
docs/man/xl.conf.pod.5 +6 -0
@@ -82,6 +82,12 @@ Configures the default bridge to set for virtual network devices. Default: C<xenbr0> +=item B<vif.default.gatewaydev="NAME"> + +Configures the default gateway device to set for virtual network devices. + +Default: C<None> + =item B<output_format="json|sxp"> Configures the default output format used by xl when printing "machine
tools/examples/xl.conf +3 -0
@@ -20,3 +20,6 @@ # if disabled the old behaviour will be used, and hotplug scripts will be # launched by udev. #run_hotplug_scripts=1 + +# default gateway device to use with vif-route hotplug script +#vif.default.gatewaydev="eth0"
tools/libxl/xl.c +14 -0
@@ -43,6 +43,7 @@ int run_hotplug_scripts = 1;char *lockfile;char *default_vifscript =NULL ;char *default_bridge =NULL ; +char *default_gatewaydev =NULL ;enum output_format default_output_format =OUTPUT_FORMAT_JSON ;static xentoollog_level minmsglevel =XTL_PROGRESS ;
@@ -85,12 +86,25 @@ static void parse_global_config(const char *configfile,exit (1 ); } +/* +* For global options that are related to a specific type of device +* we use the following nomenclature: +* +* <device type>.default.<option name> +* +* This allows us to keep the default options classified for the +* different device kinds. +*/ +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,"vif.default.gatewaydev" , &buf,0 )) + default_gatewaydev =strdup (buf); +if (!xlu_cfg_get_string (config,"output_format" , &buf,0 )) {if (!strcmp (buf,"json" )) default_output_format =OUTPUT_FORMAT_JSON ;
tools/libxl/xl.h +1 -0
@@ -148,6 +148,7 @@ extern int dryrun_only;extern char *lockfile;extern char *default_vifscript;extern char *default_bridge; +extern char *default_gatewaydev;extern char *blkdev_start;enum output_format {
tools/libxl/xl_cmdimpl.c +5 -0
@@ -1146,6 +1146,11 @@ static void parse_config_data(const char *config_source, nic->bridge =strdup (default_bridge); } +if (default_gatewaydev) { +free (nic->gatewaydev); + nic->gatewaydev =strdup (default_gatewaydev); + } + p =strtok (buf2,"," );if (!p) goto skip_nic;
Signature · 7 lines
1.7.7.5 (Apple Git-26) _______________________________________________ Xen-devel mailing list [email protected] http://lists.xen.org/xen-devel
PATCH v3 3/4 xl: add vif.default.bridge
In reply to Roger Pau MonneThis is a replacement for defaultbridge xl.conf option. The now deprecated defaultbridge is still supported.
---
Changes since v2:
* Changed bridge0 to the more common xenbr0
* Changed defaultbridge in xl.conf man page to vif.default.bridge
--- docs/man/xl.conf.pod.5 | 4 +++- tools/examples/xl.conf | 3 +++ tools/libxl/xl.c | 13 +++++++++++-- 3 files changed, 17 insertions(+), 3 deletions(-)
docs/man/xl.conf.pod.5 +3 -1
@@ -76,10 +76,12 @@ Configures the default hotplug script used by virtual network devices. Default: C</etc/xen/scripts/vif-bridge> -=item B<defaultbridge="NAME"> +=item B<vif.default.bridge="NAME"> Configures the default bridge to set for virtual network devices. +The old B<defaultbridge> option is deprecated and should not be used. + Default: C<xenbr0> =item B<vif.default.gatewaydev="NAME">
tools/examples/xl.conf +3 -0
@@ -23,3 +23,6 @@ # default gateway device to use with vif-route hotplug script #vif.default.gatewaydev="eth0" + +# default bridge device to use with vif-bridge hotplug scripts +#vif.default.bridge="xenbr0"
tools/libxl/xl.c +11 -2
@@ -99,8 +99,17 @@ 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,"defaultbridge" , &buf,0 )) { +fprintf (stderr,"the global config option defaultbridge is deprecated, " +"please switch to vif.default.bridge\n" ); +free (default_bridge); + default_bridge =strdup (buf); + } + +if (!xlu_cfg_get_string (config,"vif.default.bridge" , &buf,0 )) { +free (default_bridge); + default_bridge =strdup (buf); + }if (!xlu_cfg_get_string (config,"vif.default.gatewaydev" , &buf,0 )) default_gatewaydev =strdup (buf);
Signature · 7 lines
1.7.7.5 (Apple Git-26) _______________________________________________ Xen-devel mailing list [email protected] http://lists.xen.org/xen-devel
PATCH v3 4/4 xl: add vif.default.script
In reply to Roger Pau MonneReplace vifscript with vif.default.script. The old config option is kept for backwards compatibility.
--- docs/man/xl.conf.pod.5 | 4 +++- tools/libxl/xl.c | 11 ++++++++++- 2 files changed, 13 insertions(+), 2 deletions(-)
docs/man/xl.conf.pod.5 +3 -1
@@ -70,10 +70,12 @@ operations (primarily domain creation). Default: C</var/lock/xl> -=item B<vifscript="PATH"> +=item B<vif.default.script="PATH"> Configures the default hotplug script used by virtual network devices. +The old B<vifscript> option is deprecated and should not be used. + Default: C</etc/xen/scripts/vif-bridge> =item B<vif.default.bridge="NAME">
tools/libxl/xl.c +10 -1
@@ -96,8 +96,17 @@ static void parse_global_config(const char *configfile,* different device kinds. */ -if (!xlu_cfg_get_string (config,"vifscript" , &buf,0 )) +if (!xlu_cfg_get_string (config,"vifscript" , &buf,0 )) { +fprintf (stderr,"the global config option vifscript is deprecated, " +"please switch to vif.default.script\n" ); +free (default_vifscript); default_vifscript =strdup (buf); + } + +if (!xlu_cfg_get_string (config,"vif.default.script" , &buf,0 )) { +free (default_vifscript); + default_vifscript =strdup (buf); + }if (!xlu_cfg_get_string (config,"defaultbridge" , &buf,0 )) { fprintf(stderr, "the global config option defaultbridge is deprecated, "
Signature · 7 lines
1.7.7.5 (Apple Git-26) _______________________________________________ Xen-devel mailing list [email protected] http://lists.xen.org/xen-devel
Ian Jackson
AppliedRe: [PATCH v3 1/4] xl/libxl: add gatewaydev/netdev to vif specification [and 3 more messages]
In reply to Roger Pau MonneRoger Pau Monne writes ("[Xen-devel] [PATCH v3 1/4] xl/libxl: add gatewaydev/netdev to vif specification"):
Quoted 3 lines
This option is used by the vif-route hotplug script. A new more descriptive name is used, "gatewaydev", but "netdev" is also supported as a deprecated backwards compatible option.
I have applied all four of these, thanks.
I have a comment for possible future improvement:
Quoted 1 line
+=item B<vif.default.gatewaydev="NAME">
...
Review
Quoted 3 lines
(quoted diff) +3
-0+ if (!xlu_cfg_get_string (config, "vif.default.gatewaydev", &buf, 0)) + default_gatewaydev = strdup(buf); +
Maybe we should make it a general rule that you can write
default.<something>
in the global config file ?
Ian.