WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-changelog

[Xen-changelog] [xen-unstable] xend: Fix duplicate random MAC generation

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] [xen-unstable] xend: Fix duplicate random MAC generation.
From: Xen patchbot-unstable <patchbot-unstable@xxxxxxxxxxxxxxxxxxx>
Date: Thu, 14 Jun 2007 12:51:11 -0700
Delivery-date: Thu, 14 Jun 2007 15:23:50 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-changelog-request@lists.xensource.com?subject=help>
List-id: BK change log <xen-changelog.lists.xensource.com>
List-post: <mailto:xen-changelog@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=unsubscribe>
Reply-to: xen-devel@xxxxxxxxxxxxxxxxxxx
Sender: xen-changelog-bounces@xxxxxxxxxxxxxxxxxxx
# HG changeset patch
# User kfraser@xxxxxxxxxxxxxxxxxxxxx
# Date 1181553752 -3600
# Node ID ebe4140fe4f859696a57cd21b02d0bd2a5a3d989
# Parent  31ee1768e911336c227d13fd1519961d07cdc562
xend: Fix duplicate random MAC generation.

Ensure that HVMImageHandler and NetifController see the same random
MAC address.

Signed-off-by: David Edmondson <dme@xxxxxxx>
---
 tools/python/xen/xend/XendConfig.py   |   10 ++++++++--
 tools/python/xen/xend/image.py        |    3 +--
 tools/python/xen/xend/server/netif.py |    2 +-
 3 files changed, 10 insertions(+), 5 deletions(-)

diff -r 31ee1768e911 -r ebe4140fe4f8 tools/python/xen/xend/XendConfig.py
--- a/tools/python/xen/xend/XendConfig.py       Mon Jun 11 10:21:11 2007 +0100
+++ b/tools/python/xen/xend/XendConfig.py       Mon Jun 11 10:22:32 2007 +0100
@@ -27,6 +27,7 @@ from xen.xend.XendDevices import XendDev
 from xen.xend.XendDevices import XendDevices
 from xen.xend.PrettyPrint import prettyprintstring
 from xen.xend.XendConstants import DOM_STATE_HALTED
+from xen.xend.server.netif import randomMAC
 
 log = logging.getLogger("xend.XendConfig")
 log.setLevel(logging.WARN)
@@ -993,6 +994,10 @@ class XendConfig(dict):
                 else:
                     dev_info['driver'] = 'paravirtualised'
 
+            if dev_type == 'vif':
+                if not dev_info.get('mac'):
+                    dev_info['mac'] = randomMAC()
+
             # create uuid if it doesn't exist
             dev_uuid = dev_info.get('uuid', None)
             if not dev_uuid:
@@ -1051,8 +1056,9 @@ class XendConfig(dict):
             dev_info = {}
             dev_uuid = ''
             if dev_type == 'vif':
-                if cfg_xenapi.get('MAC'): # don't add if blank
-                    dev_info['mac'] = cfg_xenapi.get('MAC')
+                dev_info['mac'] = cfg_xenapi.get('MAC')
+                if not dev_info['mac']:
+                    dev_info['mac'] = randomMAC()
                 # vifname is the name on the guest, not dom0
                 # TODO: we don't have the ability to find that out or
                 #       change it from dom0
diff -r 31ee1768e911 -r ebe4140fe4f8 tools/python/xen/xend/image.py
--- a/tools/python/xen/xend/image.py    Mon Jun 11 10:21:11 2007 +0100
+++ b/tools/python/xen/xend/image.py    Mon Jun 11 10:22:32 2007 +0100
@@ -27,7 +27,6 @@ from xen.xend.XendError import VmError, 
 from xen.xend.XendError import VmError, XendError, HVMRequired
 from xen.xend.XendLogging import log
 from xen.xend.XendOptions import instance as xenopts
-from xen.xend.server.netif import randomMAC
 from xen.xend.xenstore.xswatch import xswatch
 from xen.xend import arch
 
@@ -351,7 +350,7 @@ class HVMImageHandler(ImageHandler):
             nics += 1
             mac = devinfo.get('mac')
             if mac is None:
-                mac = randomMAC()
+                raise VmError("MAC address not specified or generated.")
             bridge = devinfo.get('bridge', 'xenbr0')
             model = devinfo.get('model', 'rtl8139')
             ret.append("-net")
diff -r 31ee1768e911 -r ebe4140fe4f8 tools/python/xen/xend/server/netif.py
--- a/tools/python/xen/xend/server/netif.py     Mon Jun 11 10:21:11 2007 +0100
+++ b/tools/python/xen/xend/server/netif.py     Mon Jun 11 10:22:32 2007 +0100
@@ -112,7 +112,7 @@ class NetifController(DevController):
             typ = xoptions.netback_type
 
         if not mac:
-            mac = randomMAC()
+            raise VmError("MAC address not specified or generated.")
 
         devid = self.allocateDeviceID()
 

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-changelog] [xen-unstable] xend: Fix duplicate random MAC generation., Xen patchbot-unstable <=