ia64/xen-unstable
changeset 15308:ebe4140fe4f8
xend: Fix duplicate random MAC generation.
Ensure that HVMImageHandler and NetifController see the same random
MAC address.
Signed-off-by: David Edmondson <dme@sun.com>
Ensure that HVMImageHandler and NetifController see the same random
MAC address.
Signed-off-by: David Edmondson <dme@sun.com>
author | kfraser@localhost.localdomain |
---|---|
date | Mon Jun 11 10:22:32 2007 +0100 (2007-06-11) |
parents | 31ee1768e911 |
children | f1c6de438b83 |
files | tools/python/xen/xend/XendConfig.py tools/python/xen/xend/image.py tools/python/xen/xend/server/netif.py |
line diff
1.1 --- a/tools/python/xen/xend/XendConfig.py Mon Jun 11 10:21:11 2007 +0100 1.2 +++ b/tools/python/xen/xend/XendConfig.py Mon Jun 11 10:22:32 2007 +0100 1.3 @@ -27,6 +27,7 @@ from xen.xend.XendError import VmError 1.4 from xen.xend.XendDevices import XendDevices 1.5 from xen.xend.PrettyPrint import prettyprintstring 1.6 from xen.xend.XendConstants import DOM_STATE_HALTED 1.7 +from xen.xend.server.netif import randomMAC 1.8 1.9 log = logging.getLogger("xend.XendConfig") 1.10 log.setLevel(logging.WARN) 1.11 @@ -993,6 +994,10 @@ class XendConfig(dict): 1.12 else: 1.13 dev_info['driver'] = 'paravirtualised' 1.14 1.15 + if dev_type == 'vif': 1.16 + if not dev_info.get('mac'): 1.17 + dev_info['mac'] = randomMAC() 1.18 + 1.19 # create uuid if it doesn't exist 1.20 dev_uuid = dev_info.get('uuid', None) 1.21 if not dev_uuid: 1.22 @@ -1051,8 +1056,9 @@ class XendConfig(dict): 1.23 dev_info = {} 1.24 dev_uuid = '' 1.25 if dev_type == 'vif': 1.26 - if cfg_xenapi.get('MAC'): # don't add if blank 1.27 - dev_info['mac'] = cfg_xenapi.get('MAC') 1.28 + dev_info['mac'] = cfg_xenapi.get('MAC') 1.29 + if not dev_info['mac']: 1.30 + dev_info['mac'] = randomMAC() 1.31 # vifname is the name on the guest, not dom0 1.32 # TODO: we don't have the ability to find that out or 1.33 # change it from dom0
2.1 --- a/tools/python/xen/xend/image.py Mon Jun 11 10:21:11 2007 +0100 2.2 +++ b/tools/python/xen/xend/image.py Mon Jun 11 10:22:32 2007 +0100 2.3 @@ -27,7 +27,6 @@ from xen.xend.XendConstants import REVER 2.4 from xen.xend.XendError import VmError, XendError, HVMRequired 2.5 from xen.xend.XendLogging import log 2.6 from xen.xend.XendOptions import instance as xenopts 2.7 -from xen.xend.server.netif import randomMAC 2.8 from xen.xend.xenstore.xswatch import xswatch 2.9 from xen.xend import arch 2.10 2.11 @@ -351,7 +350,7 @@ class HVMImageHandler(ImageHandler): 2.12 nics += 1 2.13 mac = devinfo.get('mac') 2.14 if mac is None: 2.15 - mac = randomMAC() 2.16 + raise VmError("MAC address not specified or generated.") 2.17 bridge = devinfo.get('bridge', 'xenbr0') 2.18 model = devinfo.get('model', 'rtl8139') 2.19 ret.append("-net")
3.1 --- a/tools/python/xen/xend/server/netif.py Mon Jun 11 10:21:11 2007 +0100 3.2 +++ b/tools/python/xen/xend/server/netif.py Mon Jun 11 10:22:32 2007 +0100 3.3 @@ -112,7 +112,7 @@ class NetifController(DevController): 3.4 typ = xoptions.netback_type 3.5 3.6 if not mac: 3.7 - mac = randomMAC() 3.8 + raise VmError("MAC address not specified or generated.") 3.9 3.10 devid = self.allocateDeviceID() 3.11