hotplug: add openvswitch script
PATCH 1/1 hotplug: add openvswitch script
Based on Waldi's RFC at
http://lists.xen.org/archives/html/xen-devel/2012-09/msg00943.html
To use it set vif.default.script="vif-openvswitch" in /etc/xen/xl.conf or use script=vif-openvswitch in the vif configuration.
Appears to do the right thing for PV and HVM guests (including tap devices) and with stubdomains.
In order to support VLAN tagging and trunking the "bridge" specified in the configuration can have a special syntax, that is:
BRIDGE_NAME[.VLAN][:TRUNK,TRUNK]
e.g.
- xenbr0.99
add the VIF to VLAN99 on xenbr0
- xenbr0:99,100,101
add the VIF to xenbr0 as a trunk port receiving VLANs 99, 100 & 101
Waldi, can you confirm if I have correctly reverse engineered the syntax from the regexp please ;-)
--- tools/examples/xl.conf | 2 +- tools/hotplug/Linux/Makefile | 1 + tools/hotplug/Linux/vif-openvswitch | 99 +++++++++++++++++++++++++++++++++++ 3 files changed, 101 insertions(+), 1 deletions(-) create mode 100644 tools/hotplug/Linux/vif-openvswitch
tools/examples/xl.conf +1 -1
@@ -9,7 +9,7 @@ #lockfile="/var/lock/xl" # default vif script -#vifscript="vif-bridge" +vifscript="vif-openvswitch" # default output format used by "xl list -l" #output_format="json"
tools/hotplug/Linux/Makefile +1 -0
@@ -13,6 +13,7 @@ XENCOMMONS_SYSCONFIG = init.d/sysconfig.xencommons XEN_SCRIPTS = network-bridge vif-bridge XEN_SCRIPTS += network-route vif-route XEN_SCRIPTS += network-nat vif-nat +XEN_SCRIPTS += vif-openvswitch XEN_SCRIPTS += vif2 XEN_SCRIPTS += vif-setup XEN_SCRIPTS += block
tools/hotplug/Linux/vif-openvswitch new file +99 -0
99 lines not on this page · raw message
Signature · 1 line
1.7.2.5
Quoted 14 lines · Ian Campbell
Based on Waldi's RFC at
http://lists.xen.org/archives/html/xen-devel/2012-09/msg00943.htmlTo use it set vif.default.script="vif-openvswitch" in
/etc/xen/xl.confor use script=vif-openvswitch in the vif configuration.Appears to do the right thing for PV and HVM guests (including tap devices) and with stubdomains.
In order to support VLAN tagging and trunking the "bridge" specified in the configuration can have a special syntax, that is:
BRIDGE_NAME[.VLAN][:TRUNK,TRUNK]
Quoted 8 lines
e.g.
- xenbr0.99
add the VIF to VLAN99 on xenbr0
- xenbr0:99,100,101
add the VIF to xenbr0 as a trunk port receiving VLANs 99, 100 & 101Waldi, can you confirm if I have correctly reverse engineered the syntax from the regexp please ;-)
I've done this as a Xen patch, but in principal this could also be maintained in the openvswitch tree (I've added their list to the CC, having forgotten it with the initial posting). Anyone have any strong preference for one home over the other?
If we do go with the Xen tree then WRT the feature freeze, this can pretty obviously only break things if you enable it.
Quoted 4 lines
Signed-off-by Ian Campbell <[email protected]>--- tools/examples/xl.conf | 2 +-
This change was an unintentional artefact of my local testing, please ignore...
Quoted 135 lines
tools/hotplug/Linux/Makefile | 1 + tools/hotplug/Linux/vif-openvswitch | 99 +++++++++++++++++++++++++++++++++++ 3 files changed, 101 insertions(+), 1 deletions(-) create mode 100644 tools/hotplug/Linux/vif-openvswitchtools/examples/xl.conf +1
-1@@ -9,7 +9,7 @@ #lockfile="/var/lock/xl" # default vif script -#vifscript="vif-bridge" +vifscript="vif-openvswitch" # default output format used by "xl list -l" #output_format="json"tools/hotplug/Linux/Makefile +1
-0@@ -13,6 +13,7 @@ XENCOMMONS_SYSCONFIG = init.d/sysconfig.xencommons XEN_SCRIPTS = network-bridge vif-bridge XEN_SCRIPTS += network-route vif-route XEN_SCRIPTS += network-nat vif-nat +XEN_SCRIPTS += vif-openvswitch XEN_SCRIPTS += vif2 XEN_SCRIPTS += vif-setup XEN_SCRIPTS += blocktools/hotplug/Linux/vif-openvswitch new file +99
-0@@ -0,0 +1,99 @@ +#!/bin/bash +#============================================================================ +# ${XEN_SCRIPT_DIR}/vif-openvswitch +# +# Script for configuring a vif in openvswitch mode. +# The hotplugging system will call this script if it is specified either in +# the device configuration given to Xend, or the default Xend configuration +# in ${XEN_CONFIG_DIR}/xend-config.sxp. If the script is specified in +# neither of those places, then this script is the default. +# +# Usage: +# vif-openvswitch (add|remove|online|offline) +# +# Environment vars: +# vif vif interface name (required). +# XENBUS_PATH path to this device's details in the XenStore (required). +# +# Read from the store: +# bridge openvswitch to add the vif to (required). +# ip list of IP networks for the vif, space-separated (optional). +# +# up: +# Enslaves the vif interface to the bridge and adds iptables rules +# for its ip addresses (if any). +# +# down: +# Removes the vif interface from the bridge and removes the iptables +# rules for its ip addresses (if any). +#============================================================================ + +dir=$(dirname "$0") +. "$dir/vif-common.sh" + +openvswitch_external_id() { + local dev=$1 + local key=$2 + local value=$3 + + echo "-- set interface $dev external-ids:\"$key\"=\"$value\"" +} + +openvswitch_external_id_all() { + local dev=$1 + local frontend_id=$(xenstore_read "$XENBUS_PATH/frontend-id") + local vm_path=$(xenstore_read "/local/domain/${frontend_id}/vm") + local name=$(xenstore_read "${vm_path}/name") + openvswitch_external_id $dev "xen-vm-name" "$name" + local uuid=$(xenstore_read "${vm_path}/uuid") + openvswitch_external_id $dev "xen-vm-uuid" "$uuid" + local mac=$(xenstore_read "$XENBUS_PATH/mac") + openvswitch_external_id $dev "attached-mac" "$mac" +} + +add_to_openvswitch () { + local dev=$1 + local bridge="$(xenstore_read_default "$XENBUS_PATH/bridge" "$bridge")" + local tag trunk + + if [[ $bridge =~ ^([^.:]+)(\.([[:digit:]]+))?(:([[:digit:]]+(:[[:digit:]]+)*))?$ ]]; then + bridge="${BASH_REMATCH[1]}" + tag="${BASH_REMATCH[3]}" + trunk="${BASH_REMATCH[5]//:/,}" + else + fatal "No valid bridge was specified" + fi + + if [ $trunk ]; then + local trunk_arg="trunk=$trunk" + fi + + if [ $tag ]; then + local tag_arg="tag=$tag" + fi + + local vif_details="$(openvswitch_external_id_all $dev)" + + ovs-vsctl --timeout=30 -- --if-exists del-port $dev -- add-port "$bridge" $dev $tag_arg $trunk_arg $vif_details + ip link set $dev up +} + +case "$command" in + add|online) + setup_virtual_bridge_port $dev + add_to_openvswitch $dev + ;; + + offline) + ovs-vsctl --timeout=30 -- --if-exists del-port $dev + ;; +esac + +if [ "$type_if" = vif ]; then + handle_iptable +fi + +log debug "Successful vif-openvswitch $command for $dev." +if [ "$type_if" = vif -a "$command" = "online" ]; then + success +fi
Quoted 3 lines · Ian Campbell
Based on Waldi's RFC at
http://lists.xen.org/archives/html/xen-devel/2012-09/msg00943.html
BRIDGE_NAME[.VLAN][:TRUNK,TRUNK]
This needs to be BRIDGE_NAME[.VLAN][:TRUNK:TRUNK]. "," is already taken as delimiter.
Quoted 2 lines
- xenbr0.99
add the VIF to VLAN99 on xenbr0
- xenbr0:99:100:101
Quoted 1 line
add the VIF to xenbr0 as a trunk port receiving VLANs 99, 100 & 101
Bastian
Quoted 1 line
Signed-off-by Ian Campbell <[email protected]>
tools/examples/xl.conf line 12
Quoted 10 lines
tools/examples/xl.conf +1
-1@@ -9,7 +9,7 @@ #lockfile="/var/lock/xl" # default vif script -#vifscript="vif-bridge" +vifscript="vif-openvswitch"
Do you really want to change the default in this patch?
Bastian
Signature · 2 lines
Vulcans believe peace should not depend on force. -- Amanda, "Journey to Babel", stardate 3842.3
(adding ovs list to this subthread too)
Quoted 7 lines · Bastian Blank
Quoted 3 lines · Ian Campbell
Based on Waldi's RFC at
http://lists.xen.org/archives/html/xen-devel/2012-09/msg00943.html
BRIDGE_NAME[.VLAN][:TRUNK,TRUNK]This needs to be BRIDGE_NAME[.VLAN][:TRUNK:TRUNK]. "," is already taken as delimiter.
Thanks -- I tested the regex in isolation in a test script and forgot that it was part of a larger syntax. I've adjusted the commit message.
Quoted 9 lines
Quoted 2 lines
- xenbr0.99
add the VIF to VLAN99 on xenbr0- xenbr0:99:100:101
Quoted 1 line
add the VIF to xenbr0 as a trunk port receiving VLANs 99, 100 & 101
Bastian
Quoted 1 line
Signed-off-by Ian Campbell <[email protected]>Signed-off-by Bastian Blank <[email protected]>
Thanks!
Quoted 8 lines
Quoted 8 lines
tools/examples/xl.conf +0
-0@@ -9,7 +9,7 @@ #lockfile="/var/lock/xl"
Quoted 5 lines
tools/examples/xl.conf line 12
Quoted 3 lines
tools/examples/xl.conf +1
-1# default vif script -#vifscript="vif-bridge" +vifscript="vif-openvswitch"Do you really want to change the default in this patch?
Nope, I called this out in my early reply-to-self as a mistake.
Ian.
tools/hotplug/Linux/vif-openvswitch line 88
Quoted 2 lines · Ian Campbell
tools/hotplug/Linux/vif-openvswitch new file +2
-0+ ovs-vsctl --timeout=30 -- --if-exists del-port $dev -- add-port "$bridge" $dev $tag_arg $trunk_arg $vif_details + ovs-vsctl --timeout=30 -- --if-exists del-port $dev
There is some error handling missing. Not sure how to do that correctly.
Bastian
Signature · 3 lines
There's a way out of any cage.
-- Captain Christopher Pike, "The Menagerie" ("The Cage"),
stardate unknown.Quoted 5 lines · Bastian Blank
tools/hotplug/Linux/vif-openvswitch line 88
Quoted 2 lines · Ian Campbell
tools/hotplug/Linux/vif-openvswitch new file +2
-0+ ovs-vsctl --timeout=30 -- --if-exists del-port $dev -- add-port "$bridge" $dev $tag_arg $trunk_arg $vif_details + ovs-vsctl --timeout=30 -- --if-exists del-port $devThere is some error handling missing. Not sure how to do that correctly.
Possibly should either call fatal on error or use the do_or_die helper?
A message that is not in the archive (sent off-list or not yet received): [email protected]
Quoted 23 lines · Ian Campbell
Quoted 14 lines · Ian Campbell
Based on Waldi's RFC at
http://lists.xen.org/archives/html/xen-devel/2012-09/msg00943.htmlTo use it set vif.default.script="vif-openvswitch" in
/etc/xen/xl.confor use script=vif-openvswitch in the vif configuration.Appears to do the right thing for PV and HVM guests (including tap devices) and with stubdomains.
In order to support VLAN tagging and trunking the "bridge" specified in the configuration can have a special syntax, that is:
BRIDGE_NAME[.VLAN][:TRUNK,TRUNK]
Quoted 8 lines
e.g.
- xenbr0.99
add the VIF to VLAN99 on xenbr0
- xenbr0:99,100,101
add the VIF to xenbr0 as a trunk port receiving VLANs 99, 100 & 101Waldi, can you confirm if I have correctly reverse engineered the syntax from the regexp please ;-)
Quoted 7 lines
I've done this as a Xen patch, but in principal this could also be maintained in the openvswitch tree (I've added their list to the CC, having forgotten it with the initial posting). Anyone have any strong preference for one home over the other?
If we do go with the Xen tree then WRT the feature freeze, this can pretty obviously only break things if you enable it.
Sure; but we don't want to have a bunch of shiny-looking new features that are in fact crappy and unreliable, just because they weren't there before. :-)
Just to be clear, I'm not saying this will be unreliable; it looks pretty simple and straightforward. I'm just saying we still need to consider whether we'll find bugs before the release or not, even if it doesn't break existing functionality.
How about something like this: We add a warning in the script saying it's tech-preview. When we start RC's, I'll write a blog specifically asking people to test it and give their feedback. If I get a certain number of people saying they've tested it on their systems and that it seems to work (10 or so?) then we can take the warning out and call it a plain feature.
What do you think?
-George
Quoted 41 lines · George Dunlap
Quoted 23 lines · Ian Campbell
Quoted 14 lines · Ian Campbell
Based on Waldi's RFC at
http://lists.xen.org/archives/html/xen-devel/2012-09/msg00943.htmlTo use it set vif.default.script="vif-openvswitch" in
/etc/xen/xl.confor use script=vif-openvswitch in the vif configuration.Appears to do the right thing for PV and HVM guests (including tap devices) and with stubdomains.
In order to support VLAN tagging and trunking the "bridge" specified in the configuration can have a special syntax, that is:
BRIDGE_NAME[.VLAN][:TRUNK,TRUNK]
Quoted 8 lines
e.g.
- xenbr0.99
add the VIF to VLAN99 on xenbr0
- xenbr0:99,100,101
add the VIF to xenbr0 as a trunk port receiving VLANs 99, 100 & 101Waldi, can you confirm if I have correctly reverse engineered the syntax from the regexp please ;-)
Quoted 7 lines
I've done this as a Xen patch, but in principal this could also be maintained in the openvswitch tree (I've added their list to the CC, having forgotten it with the initial posting). Anyone have any strong preference for one home over the other?
If we do go with the Xen tree then WRT the feature freeze, this can pretty obviously only break things if you enable it.
Sure; but we don't want to have a bunch of shiny-looking new features that are in fact crappy and unreliable, just because they weren't there before. :-)
Just to be clear, I'm not saying this will be unreliable; it looks pretty simple and straightforward. I'm just saying we still need to consider whether we'll find bugs before the release or not, even if it doesn't break existing functionality.
Quoted 8 lines
How about something like this: We add a warning in the script saying it's tech-preview. When we start RC's, I'll write a blog specifically asking people to test it and give their feedback. If I get a certain number of people saying they've tested it on their systems and that it seems to work (10 or so?) then we can take the warning out and call it a plain feature.
What do you think?
No one will ever see the output from the hotplug scripts so I think that's a bit of a waste of time.
We could call it out specifically in the call for testing for rc1 etc and position it as appropriate in the release notes based on the feedback we get.
Ian.
Quoted 3 lines
-George
Quoted 48 lines · Ian Campbell
Quoted 47 lines · George Dunlap
Quoted 23 lines · Ian Campbell
Quoted 14 lines · Ian Campbell
Based on Waldi's RFC at
http://lists.xen.org/archives/html/xen-devel/2012-09/msg00943.htmlTo use it set vif.default.script="vif-openvswitch" in
/etc/xen/xl.confor use script=vif-openvswitch in the vif configuration.Appears to do the right thing for PV and HVM guests (including tap devices) and with stubdomains.
In order to support VLAN tagging and trunking the "bridge" specified in the configuration can have a special syntax, that is:
BRIDGE_NAME[.VLAN][:TRUNK,TRUNK]
Quoted 8 lines
e.g.
- xenbr0.99
add the VIF to VLAN99 on xenbr0
- xenbr0:99,100,101
add the VIF to xenbr0 as a trunk port receiving VLANs 99, 100 & 101Waldi, can you confirm if I have correctly reverse engineered the syntax from the regexp please ;-)
Quoted 7 lines
I've done this as a Xen patch, but in principal this could also be maintained in the openvswitch tree (I've added their list to the CC, having forgotten it with the initial posting). Anyone have any strong preference for one home over the other?
If we do go with the Xen tree then WRT the feature freeze, this can pretty obviously only break things if you enable it.
Sure; but we don't want to have a bunch of shiny-looking new features that are in fact crappy and unreliable, just because they weren't there before. :-)
Just to be clear, I'm not saying this will be unreliable; it looks pretty simple and straightforward. I'm just saying we still need to consider whether we'll find bugs before the release or not, even if it doesn't break existing functionality.
How about something like this: We add a warning in the script saying it's tech-preview. When we start RC's, I'll write a blog specifically asking people to test it and give their feedback. If I get a certain number of people saying they've tested it on their systems and that it seems to work (10 or so?) then we can take the warning out and call it a plain feature.
Quoted 7 lines
Quoted 1 line
What do you think?
No one will ever see the output from the hotplug scripts so I think that's a bit of a waste of time.
We could call it out specifically in the call for testing for rc1 etc and position it as appropriate in the release notes based on the feedback we get.
Sure, sounds good.
-George
Quoted 21 lines · Ian Campbell
Quoted 20 lines · Ian Campbell
Based on Waldi's RFC at
http://lists.xen.org/archives/html/xen-devel/2012-09/msg00943.htmlTo use it set vif.default.script="vif-openvswitch" in
/etc/xen/xl.confor use script=vif-openvswitch in the vif configuration.Appears to do the right thing for PV and HVM guests (including tap devices) and with stubdomains.
In order to support VLAN tagging and trunking the "bridge" specified in the configuration can have a special syntax, that is:
BRIDGE_NAME[.VLAN][:TRUNK,TRUNK]
e.g.
- xenbr0.99
add the VIF to VLAN99 on xenbr0
- xenbr0:99,100,101
add the VIF to xenbr0 as a trunk port receiving VLANs 99, 100 & 101
Quoted 7 lines
Quoted 2 lines
Waldi, can you confirm if I have correctly reverse engineered the syntax from the regexp please ;-)
I've done this as a Xen patch, but in principal this could also be maintained in the openvswitch tree (I've added their list to the CC, having forgotten it with the initial posting). Anyone have any strong preference for one home over the other?
It looks to me like the proposed script uses only Open vSwitch interfaces (via ovs-vsctl) that have been stable for a long time. My guess is that Xen users will be more likely to easily find this script if it is in the Xen distribution than if it is in the Open vSwitch one. So I would be inclined to believe that Xen is the right place for it.
That said, we'd be happy to include it with OVS if you think the balance falls the other way.
Thanks,
Ben.
A message that is not in the archive (sent off-list or not yet received): [email protected]
Quoted 25 lines · Ben Pfaff
Quoted 24 lines · Ian Campbell
Quoted 22 lines · Ian Campbell
Based on Waldi's RFC at
http://lists.xen.org/archives/html/xen-devel/2012-09/msg00943.htmlTo use it set vif.default.script="vif-openvswitch" in
/etc/xen/xl.confor use script=vif-openvswitch in the vif configuration.Appears to do the right thing for PV and HVM guests (including tap devices) and with stubdomains.
In order to support VLAN tagging and trunking the "bridge" specified in the configuration can have a special syntax, that is:
BRIDGE_NAME[.VLAN][:TRUNK,TRUNK]
e.g.
- xenbr0.99
add the VIF to VLAN99 on xenbr0
- xenbr0:99,100,101
add the VIF to xenbr0 as a trunk port receiving VLANs 99, 100 & 101Waldi, can you confirm if I have correctly reverse engineered the syntax from the regexp please ;-)
Quoted 7 lines
Quoted 4 lines
I've done this as a Xen patch, but in principal this could also be maintained in the openvswitch tree (I've added their list to the CC, having forgotten it with the initial posting). Anyone have any strong preference for one home over the other?
It looks to me like the proposed script uses only Open vSwitch interfaces (via ovs-vsctl) that have been stable for a long time.
I must confess it never even occurred to me to consider the stability of this interface, but thanks for considering it and confirming!
Quoted 7 lines
My
guess is that Xen users will be more likely to easily find this script if it is in the Xen distribution than if it is in the Open vSwitch one. So I would be inclined to believe that Xen is the right place for it.That said, we'd be happy to include it with OVS if you think the balance falls the other way.
I think you are correct in your guess. Lets take it into the Xen tree then.
Thanks,
Ian.