From 5ef47c66ccea09dca098a1803803ea7f3c0013c4 Mon Sep 17 00:00:00 2001 From: Ben Pfaff Date: Thu, 10 Dec 2009 15:53:03 -0800 Subject: [PATCH] xenserver: Make basic VM networking work. Tested by starting and stopping a VM that has a single VIF and verifying that the VM could get an IP address via DHCP and access the network and that the VIF's external-ids were set to plausible values. --- xenserver/etc_xensource_scripts_vif | 17 +------------- ...usr_share_vswitch_scripts_dump-vif-details | 22 ++++++++++--------- 2 files changed, 13 insertions(+), 26 deletions(-) diff --git a/xenserver/etc_xensource_scripts_vif b/xenserver/etc_xensource_scripts_vif index c649e926..a9b62ff4 100755 --- a/xenserver/etc_xensource_scripts_vif +++ b/xenserver/etc_xensource_scripts_vif @@ -21,7 +21,6 @@ # Keep other-config/ keys in sync with device.ml:vif_udev_keys -cfg_mod="/usr/bin/ovs-cfg-mod" vsctl="/usr/bin/ovs-vsctl" dump_vif_details="/usr/share/vswitch/scripts/dump-vif-details" service="/sbin/service" @@ -81,13 +80,6 @@ add_to_bridge() fi logger -t scripts-vif "Adding ${vif} to ${bridge} with address ${address}" - local VLAN_ID=$($vsctl br-to-vlan $bridge) - local vid= - if [ "$VLAN_ID" -ne 0 ] ; then - bridge=$($vsctl br-to-parent $bridge) - vid="--add=vlan.${vif}.tag=${VLAN_ID}" - fi - ${IP} link set "${vif}" down || logger -t scripts-vif "Failed to ip link set ${vif} down" ${IP} link set "${vif}" arp off || logger -t scripts-vif "Failed to ip link set ${vif} arp off" ${IP} link set "${vif}" multicast off || logger -t scripts-vif "Failed to ip link set ${vif} multicast off" @@ -99,14 +91,7 @@ add_to_bridge() logger -t scripts-vif "Failed to retrieve vif details for vswitch" fi - $cfg_mod -F /etc/ovs-vswitchd.conf \ - --del-match="bridge.*.port=$vif" \ - --del-match="vlan.$vif.trunks=*" \ - --del-match="vlan.$vif.tag=*" \ - --del-match="port.$vif.[!0-9]*" \ - --add="bridge.$bridge.port=$vif" \ - $vid $vif_details -c - $service vswitch reload + $vsctl add-port $bridge $vif $vif_details ${IP} link set "${vif}" up || logger -t scripts-vif "Failed to ip link set ${vif} up" } diff --git a/xenserver/usr_share_vswitch_scripts_dump-vif-details b/xenserver/usr_share_vswitch_scripts_dump-vif-details index 7ce8bf78..1340addd 100755 --- a/xenserver/usr_share_vswitch_scripts_dump-vif-details +++ b/xenserver/usr_share_vswitch_scripts_dump-vif-details @@ -25,7 +25,6 @@ def get_vif_ref(domid, devid): # Query XAPI for the information we need using the vif's opaque reference def dump_vif_info(domid, devid, vif_ref): - vif_info = [] session = XenAPI.xapi_local() session.xenapi.login_with_password("root", "") try: @@ -34,11 +33,14 @@ def dump_vif_info(domid, devid, vif_ref): vm_uuid = session.xenapi.VM.get_uuid(vif_rec["VM"]) # Data to allow vNetManager to associate VIFs with xapi data - add_port = '--add=port.vif%s.%s' % (domid, devid) - vif_info.append('%s.net-uuid=%s' % (add_port, net_rec["uuid"])) - vif_info.append('%s.vif-mac=%s' % (add_port, vif_rec["MAC"])) - vif_info.append('%s.vif-uuid=%s' % (add_port, vif_rec["uuid"])) - vif_info.append('%s.vm-uuid=%s' % (add_port, vm_uuid)) + vif_info = [] + vif_info.append(('xs-network-uuid', net_rec["uuid"])) + vif_info.append(('xs-vif-mac', vif_rec["MAC"])) + vif_info.append(('xs-vif-uuid', vif_rec["uuid"])) + vif_info.append(('xs-vm-uuid', vm_uuid)) + for key, value in vif_info: + print("-- iface-set-external-id vif%s.%s %s %s" + % (domid, devid, key, value)) # vNetManager needs to know the network UUID(s) associated with # each datapath. Normally interface-reconfigure adds them, but @@ -51,13 +53,13 @@ def dump_vif_info(domid, devid, vif_ref): # ovs-vswitchd connection to vNetManager and setting this # configuration variable, but vNetManager can tolerate that. if not net_rec['PIFs']: - key = 'bridge.%s.xs-network-uuids' % net_rec['bridge'] + bridge = net_rec['bridge'] + key = "xs-network-uuids" value = net_rec['uuid'] - vif_info.append('--del-match=%s=*' % key) - vif_info.append('--add=%s=%s' % (key, value)) + print("-- bridge-set-external-id %s %s %s" + % (bridge, key, value)) finally: session.xenapi.session.logout() - print ' '.join(vif_info) if __name__ == '__main__': if len(sys.argv) != 3: -- 2.30.2