xen: xm/create mac selection
PATCH 3/5 xen: xm/create mac selection
Check for duplicate supplied vif MACs, and make sure that randomly generated MACs for a domain are all different
Signed-off-by Jody Belka <[email protected]>
diffstat:
create.py | 11 +++++++++++ 1 files changed, 11 insertions(+)
tools/python/xen/xm/create.py +11 -0
@@ -279,10 +279,15 @@ vifs = vals.vif vifs_n = max(vals.nics, len(vifs)) + macs = [] + mac_vifs = {} + for idx in range(0, vifs_n): if idx < len(vifs): d = vifs[idx] mac = d.get('mac') + if mac in macs: + gopts.err('Duplicate MAC: %s selected for both vif%i and vif%i' % (mac, mac_vifs[mac], idx + 1)) if not mac: mac = randomMAC() bridge = d.get('bridge')
@@ -295,6 +300,12 @@ script = None backend = None ip = None + + while mac in macs: + mac = randomMAC() + macs.append(mac) + mac_vifs[mac] = idx + 1 + config_vif = ['vif'] config_vif.append(['mac', mac]) if bridge:
-------------------------------------------------------
This SF.Net email is sponsored by: IntelliVIEW -- Interactive Reporting Tool for open source databases. Create drag-&-drop reports. Save time by over 75%! Publish reports on the web. Export to DOC, XLS, RTF, etc. Download a FREE copy at http://www.intelliview.com/go/osdn_nl