From 986b77c0991375db253ca600ba532098108f7be8 Mon Sep 17 00:00:00 2001 From: Ben Pfaff Date: Thu, 11 Jun 2009 11:33:39 -0700 Subject: [PATCH] xenserver: Pass network UUID to controller for internal networks too. vNetManager needs to know the xapi UUIDs for the networks that correspond to OpenFlow connections. For some time now we have passed these to it over the management connection using bridge..xs-network-uuids configuration keys, but only now did we notice that this didn't get set for internal networks. The reason that it didn't get set is that interface-reconfigure is the script that sets up these configuration keys, but interface-reconfigure is never called for internal networks. Instead, xapi creates them itself using directly calls to bridge ioctls. So no amount of tweaks to interface-reconfigure will help. This commit fixes the problem by modifying the vif script instead. This works acceptably only because xapi is lazy about creating bridges for internal networks: it creates them only just before it is about to add the first vif to them. Thus, by setting up the configuration key in the vif script, it gets added just after the bridge itself is created. There is a race, of course, meaning that there may be a delay between the initial OpenFlow connection and the time when the configuration key is set up, but vNetManager can tolerate that. --- xenserver/root_vswitch_scripts_dump-vif-details | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/xenserver/root_vswitch_scripts_dump-vif-details b/xenserver/root_vswitch_scripts_dump-vif-details index 2e9aa039..8ec845f1 100755 --- a/xenserver/root_vswitch_scripts_dump-vif-details +++ b/xenserver/root_vswitch_scripts_dump-vif-details @@ -32,6 +32,7 @@ def dump_vif_info(domid, devid, vif_ref): net_rec = session.xenapi.network.get_record(vif_rec["network"]) vm_rec = session.xenapi.VM.get_record(vif_rec["VM"]) + # Data to allow vNetManager to associate VIFs with xapi data sys.stdout.write('--add=port.vif%s.%s.network-uuid=%s ' % (domid, devid, net_rec["uuid"])) sys.stdout.write('--add=port.vif%s.%s.vif-mac=%s ' @@ -40,6 +41,22 @@ def dump_vif_info(domid, devid, vif_ref): % (domid, devid, vif_rec["uuid"])) sys.stdout.write('--add=port.vif%s.%s.vm-uuid=%s ' % (domid, devid, vm_rec["uuid"])) + + # vNetManager needs to know the network UUID(s) associated with + # each datapath. Normally interface-reconfigure adds them, but + # interface-reconfigure never gets called for internal networks + # (xapi does 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. + if len(net_rec['PIFs']) == 0: + key = 'bridge.%s.xs-network-uuids' % net_rec['bridge'] + value = net_rec['uuid'] + sys.stdout.write('--del-match=%s=* ' % key) + sys.stdout.write('--add=%s=%s ' % (key, value)) finally: session.xenapi.session.logout() -- 2.30.2