Skip to content

Commit

Permalink
xenserver: Merge upstream changes and drop pre-5.6.100 support.
Browse files Browse the repository at this point in the history
Citrix have made modifications to the various interface configuration scripts
that OVS replaces, so at present those modifications are lost when OVS is
installed on e.g. XenServer 5.6.100. This commit applies those changes while
preserving OVS-specific modifications that have been made in the interim.

One major change introduced by these updates is the removal of support for
XenServer releases prior to 5.6.100.

This commit also updates the OVS-supplied xen-bugtool in similar fashion. We
will soon remove xen-bugtool from OVS altogether and move the added OVS
functionality to an XML extension as described in the Supplemental Pack DDK
guide.
  • Loading branch information
Andrew Evans committed Feb 11, 2011
1 parent f48f70b commit 404c169
Show file tree
Hide file tree
Showing 11 changed files with 144 additions and 126 deletions.
2 changes: 1 addition & 1 deletion INSTALL.Linux
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

This document describes how to build and install Open vSwitch on a
generic Linux host. If you want to install Open vSwitch on a Citrix
XenServer version 5.5.0, see INSTALL.XenServer instead.
XenServer, see INSTALL.XenServer instead.

This version of Open vSwitch may be built manually with "configure"
and "make", as described below. You may also build Debian packages by
Expand Down
5 changes: 2 additions & 3 deletions INSTALL.XenServer
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ This document describes how to build and install Open vSwitch on a
Citrix XenServer host. If you want to install Open vSwitch on a
generic Linux host, see INSTALL.Linux instead.

These instructions have been tested with XenServer versions 5.5.0,
5.5.0-24648p (Update 1), 5.5.0-25727p (Update 2), and 5.6.0.
These instructions have been tested with XenServer 5.6 FP1.

Building Open vSwitch for XenServer
-----------------------------------
Expand Down Expand Up @@ -38,7 +37,7 @@ where:
name of the Open vSwitch tarball, e.g. 0.90.0.

<Xen kernel version> is the version number of the Xen kernel,
e.g. 2.6.18-128.1.1.el5.xs5.5.0.487.1006xen. This version number
e.g. 2.6.32.12-0.7.1.xs5.6.100.307.170586xen. This version number
appears as the name of a directory in /lib/modules inside the VM.
It always ends in "xen".

Expand Down
14 changes: 14 additions & 0 deletions tests/interface-reconfigure.at
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ EOF
<xenserver-network-configuration>
<pif ref="OpaqueRef:e0955887-571f-17fc-a971-61c1ec7d81b6">
<VLAN_slave_of/>
<tunnel_access_PIF_of/>
<management>
False
</management>
Expand Down Expand Up @@ -120,6 +121,7 @@ EOF
</pif>
<pif ref="OpaqueRef:eea8da94-a5e6-18fc-34a7-5e9b5a235806">
<VLAN_slave_of/>
<tunnel_access_PIF_of/>
<management>
False
</management>
Expand Down Expand Up @@ -167,6 +169,7 @@ EOF
</pif>
<pif ref="OpaqueRef:2956e6c8-487e-981c-85ff-c84796418768">
<VLAN_slave_of/>
<tunnel_access_PIF_of/>
<management>
False
</management>
Expand Down Expand Up @@ -214,6 +217,7 @@ EOF
</pif>
<pif ref="OpaqueRef:d2d1e51e-4da9-3163-8f57-bb683429335e">
<VLAN_slave_of/>
<tunnel_access_PIF_of/>
<management>
False
</management>
Expand Down Expand Up @@ -265,6 +269,7 @@ EOF
OpaqueRef:e623e1d6-cd02-be8d-820d-49d65c710297
</master>
</VLAN_slave_of>
<tunnel_access_PIF_of/>
<management>
False
</management>
Expand Down Expand Up @@ -312,6 +317,7 @@ EOF
</pif>
<pif ref="OpaqueRef:205d1186-2cd1-d5e6-45e4-ea1698ea6e15">
<VLAN_slave_of/>
<tunnel_access_PIF_of/>
<management>
True
</management>
Expand Down Expand Up @@ -359,6 +365,7 @@ EOF
</pif>
<pif ref="OpaqueRef:8e3e37e6-ebb9-087e-0201-f6a56bf554c3">
<VLAN_slave_of/>
<tunnel_access_PIF_of/>
<management>
False
</management>
Expand Down Expand Up @@ -410,6 +417,7 @@ EOF
OpaqueRef:4c0eb823-4d96-da1d-e75f-411b85badb0c
</master>
</VLAN_slave_of>
<tunnel_access_PIF_of/>
<management>
False
</management>
Expand Down Expand Up @@ -656,6 +664,7 @@ Applying changes to /etc/sysconfig/network-scripts/route-xenbr2 configuration
Applying changes to /etc/sysconfig/network configuration
Applying changes to /etc/sysconfig/network-scripts/ifcfg-xenbr2 configuration
/sbin/ifconfig eth2 up mtu 1500
/sbin/ethtool -K eth2 gro off lro off
/usr/bin/ovs-vsctl --timeout=20
--with-iface --if-exists del-port eth2
--may-exist add-br xenbr2
Expand Down Expand Up @@ -720,6 +729,7 @@ configure_datapath: extra bonds - []
Applying changes to /etc/sysconfig/network-scripts/route-xapi3 configuration
Applying changes to /etc/sysconfig/network-scripts/ifcfg-xapi3 configuration
/sbin/ifconfig eth3 up mtu 1500
/sbin/ethtool -K eth3 gro off lro off
/usr/bin/ovs-vsctl --timeout=20
--with-iface --if-exists del-port eth3
--may-exist add-br xenbr3
Expand Down Expand Up @@ -800,7 +810,9 @@ netdev: down: device xenbr1 does not exist, ignoring
Applying changes to /etc/sysconfig/network-scripts/route-xapi1 configuration
Applying changes to /etc/sysconfig/network-scripts/ifcfg-xapi1 configuration
/sbin/ifconfig eth0 up mtu 1500
/sbin/ethtool -K eth0 gro off lro off
/sbin/ifconfig eth1 up mtu 1500
/sbin/ethtool -K eth1 gro off lro off
/usr/bin/ovs-vsctl --timeout=20
--if-exists del-br xenbr0
--if-exists del-br xenbr1
Expand Down Expand Up @@ -882,7 +894,9 @@ netdev: down: device xenbr1 does not exist, ignoring
Applying changes to /etc/sysconfig/network-scripts/route-xapi2 configuration
Applying changes to /etc/sysconfig/network-scripts/ifcfg-xapi2 configuration
/sbin/ifconfig eth0 up mtu 1500
/sbin/ethtool -K eth0 gro off lro off
/sbin/ifconfig eth1 up mtu 1500
/sbin/ethtool -K eth1 gro off lro off
/usr/bin/ovs-vsctl --timeout=20
--if-exists del-br xenbr0
--if-exists del-br xenbr1
Expand Down
2 changes: 1 addition & 1 deletion vswitchd/vswitch.xml
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@
<column name="system_version">
<p>
The version of the system identified by <ref column="system_type"/>,
e.g. <code>5.5.0-24648p</code> on XenServer 5.5.0 build 24648.
e.g. <code>5.6.100-39265p</code> on XenServer 5.6.100 build 39265.
</p>
<p>
System integrators are responsible for choosing and setting an
Expand Down
6 changes: 3 additions & 3 deletions xenserver/README
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@ files are:
uuid.py

This is uuid.py from Python 2.5. It is installed into the
Open vSwitch RPM because XenServer 5.5 and 5.6 use Python 2.4,
which do not have uuid.py.
Open vSwitch RPM because XenServer uses Python 2.4, which does
not have uuid.py.

To install, build the Open vSwitch RPM with a command like this:

Expand All @@ -94,7 +94,7 @@ question and reboot them. (The openvswitch-dbg package that is also
produced need not be installed, but it is harmless to do so.)

----------------------------------------------------------------------
Copyright (C) 2009, 2010 Nicira Networks, Inc.
Copyright (C) 2009, 2010, 2011 Nicira Networks, Inc.

Copying and distribution of this file, with or without modification,
are permitted in any medium without royalty provided the copyright
Expand Down
38 changes: 2 additions & 36 deletions xenserver/etc_xensource_scripts_vif
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,6 @@ IP="/sbin/ip"

vsctl="/usr/bin/ovs-vsctl"

# XAPI before build 29381 (approximately) did not provide some of the
# data in XenStore that we rely on.
. /etc/xensource-inventory
if test "$PRODUCT_VERSION" = "5.5.0" || test "${BUILD_NUMBER%[a-z]}" -le 26131
then
xs550=true
else
xs550=false
fi

handle_promiscuous()
{
local arg=$(xenstore-read "${PRIVATE}/other-config/promiscuous" 2>/dev/null)
Expand Down Expand Up @@ -96,43 +86,19 @@ handle_vswitch_vif_details()
fi

local vif_uuid=$(xenstore-read "${PRIVATE}/vif-uuid" 2>/dev/null)
if $xs550 && [ -z "${vif_uuid}" ] && [ -n "${vm_uuid}" ]; then
vif_uuid=$(xe vif-list --minimal vm-uuid="${vm_uuid}" device=$DEVID)
fi
if [ -n "${vif_uuid}" ] ; then
set_vif_external_id "xs-vif-uuid" "${vif_uuid}"
set_vif_external_id "xs-vif-uuid" "${vif_uuid}"
fi

local vif_details=
local net_uuid=$(xenstore-read "${PRIVATE}/network-uuid" 2>/dev/null)
if $xs550 && [ -z "${net_uuid}" ] && [ -n "${vif_uuid}" ]; then
net_uuid=$(xe vif-param-get uuid="${vif_uuid}" param-name=network-uuid)
fi
if [ -n "${net_uuid}" ] ; then
set_vif_external_id "xs-network-uuid" "${net_uuid}"
set_vif_external_id "xs-network-uuid" "${net_uuid}"
fi

local address=$(xenstore-read "/local/domain/$DOMID/device/vif/$DEVID/mac" 2>/dev/null)
if [ -n "${address}" ] ; then
set_vif_external_id "attached-mac" "${address}"
fi

if $xs550; then
# vNetManager needs to know the network UUID(s) associated with each
# datapath. Normally interface-reconfigure adds them, but XAPI does
# not use interface-reconfigure for internal networks. Instead, XAPI
# calls the addbr ioctl internally, so we have to do it here instead
# for internal networks. This is only acceptable because xapi is lazy
# about creating internal networks: it only creates one just before it
# adds the first vif to it. There may still be a brief delay between
# the initial ovs-vswitchd connection to vNetManager and setting this
# configuration variable, but vNetManager can tolerate that.
local bridge=$1
if [ -n "${net_uuid}" ] ; then
logger -t scripts-vif "${bridge} xs-network-uuids ${net_uuid}"
echo "-- br-set-external-id $bridge xs-network-uuids ${net_uuid}"
fi
fi
}

add_to_bridge()
Expand Down
40 changes: 14 additions & 26 deletions xenserver/opt_xensource_libexec_InterfaceReconfigure.py
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ def _otherconfig_from_xml(n, attrs):
_NETWORK_XML_TAG = "network"
_POOL_XML_TAG = "pool"

_ETHTOOL_OTHERCONFIG_ATTRS = ['ethtool-%s' % x for x in 'autoneg', 'speed', 'duplex', 'rx', 'tx', 'sg', 'tso', 'ufo', 'gso' ]
_ETHTOOL_OTHERCONFIG_ATTRS = ['ethtool-%s' % x for x in 'autoneg', 'speed', 'duplex', 'rx', 'tx', 'sg', 'tso', 'ufo', 'gso', 'gro', 'lro' ]

_PIF_OTHERCONFIG_ATTRS = [ 'domain', 'peerdns', 'defaultroute', 'mtu', 'static-routes' ] + \
[ 'bond-%s' % x for x in 'mode', 'miimon', 'downdelay',
Expand Down Expand Up @@ -391,21 +391,15 @@ def __get_pif_records_from_xapi(self, session, host):
continue
self.__pifs[p] = {}
for f in _PIF_ATTRS:
if f in [ "tunnel_access_PIF_of", "tunnel_transport_PIF_of" ] and f not in rec:
# XenServer 5.5 network records did not have
# these fields, so allow them to be missing.
pass
else:
self.__pifs[p][f] = rec[f]
self.__pifs[p][f] = rec[f]
self.__pifs[p]['other_config'] = {}
for f in _PIF_OTHERCONFIG_ATTRS:
if not rec['other_config'].has_key(f): continue
self.__pifs[p]['other_config'][f] = rec['other_config'][f]

def __get_vlan_records_from_xapi(self, session):
self.__vlans = {}
for v in session.xenapi.VLAN.get_all():
rec = session.xenapi.VLAN.get_record(v)
for (v,rec) in session.xenapi.VLAN.get_all_records().items():
if not self.__pif_on_host(rec['untagged_PIF']):
continue
self.__vlans[v] = {}
Expand All @@ -424,8 +418,7 @@ def __get_tunnel_records_from_xapi(self, session):

def __get_bond_records_from_xapi(self, session):
self.__bonds = {}
for b in session.xenapi.Bond.get_all():
rec = session.xenapi.Bond.get_record(b)
for (b,rec) in session.xenapi.Bond.get_all_records().items():
if not self.__pif_on_host(rec['master']):
continue
self.__bonds[b] = {}
Expand All @@ -434,8 +427,7 @@ def __get_bond_records_from_xapi(self, session):

def __get_network_records_from_xapi(self, session):
self.__networks = {}
for n in session.xenapi.network.get_all():
rec = session.xenapi.network.get_record(n)
for (n,rec) in session.xenapi.network.get_all_records().items():
self.__networks[n] = {}
for f in _NETWORK_ATTRS:
if f == "PIFs":
Expand Down Expand Up @@ -512,13 +504,7 @@ def __init__(self, session_ref=None, cache_file=None):

self.__get_pif_records_from_xapi(session, host)

try:
self.__get_tunnel_records_from_xapi(session)
except XenAPI.Failure, e:
error,details = e.details
if error == "MESSAGE_METHOD_UNKNOWN" and details == "tunnel.get_all":
pass

self.__get_tunnel_records_from_xapi(session)
self.__get_pool_records_from_xapi(session)
self.__get_vlan_records_from_xapi(session)
self.__get_bond_records_from_xapi(session)
Expand Down Expand Up @@ -677,8 +663,9 @@ def get_pool_record(self):
#
#
#
PIF_OTHERCONFIG_DEFAULTS = {'gro': 'off', 'lro': 'off'}

def ethtool_settings(oc):
def ethtool_settings(oc, defaults = {}):
settings = []
if oc.has_key('ethtool-speed'):
val = oc['ethtool-speed']
Expand All @@ -688,8 +675,8 @@ def ethtool_settings(oc):
log("Invalid value for ethtool-speed = %s. Must be 10|100|1000." % val)
if oc.has_key('ethtool-duplex'):
val = oc['ethtool-duplex']
if val in ["10", "100", "1000"]:
settings += ['duplex', 'val']
if val in ["half", "full"]:
settings += ['duplex', val]
else:
log("Invalid value for ethtool-duplex = %s. Must be half|full." % val)
if oc.has_key('ethtool-autoneg'):
Expand All @@ -701,7 +688,7 @@ def ethtool_settings(oc):
else:
log("Invalid value for ethtool-autoneg = %s. Must be on|true|off|false." % val)
offload = []
for opt in ("rx", "tx", "sg", "tso", "ufo", "gso"):
for opt in ("rx", "tx", "sg", "tso", "ufo", "gso", "gro", "lro"):
if oc.has_key("ethtool-" + opt):
val = oc["ethtool-" + opt]
if val in ["true", "on"]:
Expand All @@ -710,6 +697,8 @@ def ethtool_settings(oc):
offload += [opt, 'off']
else:
log("Invalid value for ethtool-%s = %s. Must be on|true|off|false." % (opt, val))
elif opt in defaults:
offload += [opt, defaults[opt]]
return settings,offload

# By default the MTU is taken from the Network.MTU setting for VIF,
Expand Down Expand Up @@ -882,8 +871,7 @@ def pif_get_vlan_masters(pif):
# Tunnel PIFs
#
def pif_is_tunnel(pif):
rec = db().get_pif_record(pif)
return rec.has_key('tunnel_access_PIF_of') and len(rec['tunnel_access_PIF_of']) > 0
return len(db().get_pif_record(pif)['tunnel_access_PIF_of']) > 0

#
# Datapath base class
Expand Down
7 changes: 4 additions & 3 deletions xenserver/opt_xensource_libexec_InterfaceReconfigureBridge.py
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,8 @@ def _configure_physical_interface(pif):
f.write("TYPE=Ethernet\n")
f.write("HWADDR=%(MAC)s\n" % pifrec)

settings,offload = ethtool_settings(pifrec['other_config'])
settings,offload = ethtool_settings(pifrec['other_config'],
PIF_OTHERCONFIG_DEFAULTS)
if len(settings):
f.write("ETHTOOL_OPTS=\"%s\"\n" % str.join(" ", settings))
if len(offload):
Expand Down Expand Up @@ -338,7 +339,7 @@ def _configure_bond_interface(pif):
if len(offload):
f.write("ETHTOOL_OFFLOAD_OPTS=\"%s\"\n" % str.join(" ", offload))

mtu = mtu_setting(pifrec['network'], "VLAN-PIF", pifrec['other_config'])
mtu = mtu_setting(pifrec['network'], "Bond-PIF", pifrec['other_config'])
if mtu:
f.write("MTU=%s\n" % mtu)

Expand Down Expand Up @@ -389,7 +390,7 @@ def _configure_vlan_interface(pif):
if len(offload):
f.write("ETHTOOL_OFFLOAD_OPTS=\"%s\"\n" % str.join(" ", offload))

mtu = mtu_setting(pifrec['network'], "Bond-PIF", pifrec['other_config'])
mtu = mtu_setting(pifrec['network'], "VLAN-PIF", pifrec['other_config'])
if mtu:
f.write("MTU=%s\n" % mtu)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -529,7 +529,7 @@ def configure(self):

netdev_up(dev, mtu)

settings, offload = ethtool_settings(oc)
settings, offload = ethtool_settings(oc, PIF_OTHERCONFIG_DEFAULTS)
if len(settings):
run_command(['/sbin/ethtool', '-s', dev] + settings)
if len(offload):
Expand Down
2 changes: 2 additions & 0 deletions xenserver/opt_xensource_libexec_interface-reconfigure
Original file line number Diff line number Diff line change
Expand Up @@ -527,6 +527,8 @@ def action_force_rewrite(bridge, config):
f.write('\t\t<VLAN_slave_of/>\n')
f.write('\t\t<VLAN_master_of>OpaqueRef:NULL</VLAN_master_of>\n')
f.write('\t\t<VLAN>-1</VLAN>\n')
f.write('\t\t<tunnel_access_PIF_of/>\n')
f.write('\t\t<tunnel_transport_PIF_of/>\n')
f.write('\t\t<device>%s</device>\n' % interface)
f.write('\t\t<MAC>%s</MAC>\n' % mac)
f.write('\t\t<other_config/>\n')
Expand Down
Loading

0 comments on commit 404c169

Please sign in to comment.