From 3d2a94ced883aa693614268c081f5811967e5c4a Mon Sep 17 00:00:00 2001 From: Ben Pfaff Date: Wed, 20 May 2009 16:18:45 -0700 Subject: [PATCH] xenserver: Fix VLANs on virtual interfaces. --- xenserver/etc_xensource_scripts_vif | 4 ++-- .../opt_xensource_libexec_interface-reconfigure | 12 ++++++++++++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/xenserver/etc_xensource_scripts_vif b/xenserver/etc_xensource_scripts_vif index 6051d9a2..3a8d264a 100755 --- a/xenserver/etc_xensource_scripts_vif +++ b/xenserver/etc_xensource_scripts_vif @@ -72,8 +72,8 @@ add_to_bridge() logger -t scripts-vif "Adding ${vif} to ${bridge} with address ${address}" vid= - if [ -e "/etc/sysconfig/network-scripts/ifcfg-$bridge" ]; then - . "/etc/sysconfig/network-scripts/ifcfg-$bridge" + if [ -e "/etc/sysconfig/vswitch/br-$bridge" ]; then + . "/etc/sysconfig/vswitch/br-$bridge" if [ -n "$VLAN_SLAVE" -a -n "$VLAN_VID" ]; then bridge=$VLAN_SLAVE vid="--add=vlan.$vif.tag=$VLAN_VID" diff --git a/xenserver/opt_xensource_libexec_interface-reconfigure b/xenserver/opt_xensource_libexec_interface-reconfigure index 27c8f502..d29d1cf6 100755 --- a/xenserver/opt_xensource_libexec_interface-reconfigure +++ b/xenserver/opt_xensource_libexec_interface-reconfigure @@ -70,6 +70,7 @@ db = None management_pif = None dbcache_file = "/etc/vswitch.dbcache" +vswitch_config_dir = "/etc/sysconfig/vswitch" class Usage(Exception): def __init__(self, msg): @@ -762,6 +763,7 @@ def configure_bond(pif): def action_up(pif): pifrec = db.get_pif_record(pif) + bridge = bridge_name(pif) interface = interface_name(pif) ipdev = ipdev_name(pif) datapath = datapath_name(pif) @@ -829,6 +831,16 @@ def action_up(pif): # xapi insists that its attempts to create the bridge succeed, # so force that to happen. argv += ['--add=iface.%s.fake-bridge=true' % (ipdev)] + + # /etc/xensource/scripts/vif needs to know where to add VIFs. + if not os.path.exists(vswitch_config_dir): + os.mkdir(vswitch_config_dir) + f = ConfigurationFile("br-%s" % bridge, vswitch_config_dir) + f.write("VLAN_SLAVE=%s\n" % datapath) + f.write("VLAN_VID=%s\n" % pifrec['VLAN']) + f.close() + f.apply() + f.commit() if bond_master: argv += configure_bond(bond_master) modify_config(argv) -- 2.30.2