ia64/xen-unstable

changeset 16640:e08c4cab65c8

xend: Fix device duplicate check.

Signed-off-by: Yosuke Iwamatsu <y-iwamatsu@ab.jp.nec.com>
author Keir Fraser <keir.fraser@citrix.com>
date Wed Dec 19 14:51:02 2007 +0000 (2007-12-19)
parents ca461349620a
children b0c85bc56f9e
files tools/python/xen/xend/XendConfig.py
line diff
     1.1 --- a/tools/python/xen/xend/XendConfig.py	Wed Dec 19 14:50:37 2007 +0000
     1.2 +++ b/tools/python/xen/xend/XendConfig.py	Wed Dec 19 14:51:02 2007 +0000
     1.3 @@ -31,7 +31,7 @@ from xen.xend.XendConstants import DOM_S
     1.4  from xen.xend.xenstore.xstransact import xstransact
     1.5  from xen.xend.server.BlktapController import blktap_disk_types
     1.6  from xen.xend.server.netif import randomMAC
     1.7 -from xen.util.blkif import blkdev_name_to_number
     1.8 +from xen.util.blkif import blkdev_name_to_number, blkdev_uname_to_file
     1.9  from xen.util import xsconstants
    1.10  import xen.util.auxbin
    1.11  
    1.12 @@ -981,7 +981,7 @@ class XendConfig(dict):
    1.13      def device_duplicate_check(self, dev_type, dev_info, defined_config):
    1.14          defined_devices_sxpr = self.all_devices_sxpr(target = defined_config)
    1.15          
    1.16 -        if dev_type == 'vbd':
    1.17 +        if dev_type == 'vbd' or dev_type == 'tap':
    1.18              dev_uname = dev_info.get('uname')
    1.19              blkdev_name = dev_info.get('dev')
    1.20              devid = self._blkdev_name_to_number(blkdev_name)
    1.21 @@ -989,10 +989,13 @@ class XendConfig(dict):
    1.22                  return
    1.23              
    1.24              for o_dev_type, o_dev_info in defined_devices_sxpr:
    1.25 -                if dev_type == o_dev_type:
    1.26 -                    if dev_uname == sxp.child_value(o_dev_info, 'uname'):
    1.27 -                        raise XendConfigError('The uname "%s" is already defined' %
    1.28 -                                              dev_uname)
    1.29 +                if o_dev_type == 'vbd' or o_dev_type == 'tap':
    1.30 +                    blkdev_file = blkdev_uname_to_file(dev_uname)
    1.31 +                    o_dev_uname = sxp.child_value(o_dev_info, 'uname')
    1.32 +                    o_blkdev_file = blkdev_uname_to_file(o_dev_uname)
    1.33 +                    if blkdev_file == o_blkdev_file:
    1.34 +                        raise XendConfigError('The file "%s" is already used' %
    1.35 +                                              blkdev_file)
    1.36                      o_blkdev_name = sxp.child_value(o_dev_info, 'dev')
    1.37                      o_devid = self._blkdev_name_to_number(o_blkdev_name)
    1.38                      if o_devid != None and devid == o_devid:
    1.39 @@ -1004,7 +1007,7 @@ class XendConfig(dict):
    1.40              
    1.41              for o_dev_type, o_dev_info in defined_devices_sxpr:
    1.42                  if dev_type == o_dev_type:
    1.43 -                    if dev_mac == sxp.child_value(o_dev_info, 'mac'):
    1.44 +                    if dev_mac.lower() == sxp.child_value(o_dev_info, 'mac').lower():
    1.45                          raise XendConfigError('The mac "%s" is already defined' %
    1.46                                                dev_mac)
    1.47