ia64/xen-unstable

changeset 8471:5b30599761b3

Fix VMX disk config string parse (allow leading whitespace).

Signed-off-by: Xin Li <xin.b.li@intel.com>
author kaf24@firebug.cl.cam.ac.uk
date Mon Jan 02 11:35:29 2006 +0100 (2006-01-02)
parents 121ff5042eb3
children cd914808acf1 9fedfb8cb1b2 412995d28a07
files tools/python/xen/xend/image.py tools/python/xen/xend/server/blkif.py
line diff
     1.1 --- a/tools/python/xen/xend/image.py	Sun Jan 01 11:29:17 2006 +0100
     1.2 +++ b/tools/python/xen/xend/image.py	Mon Jan 02 11:35:29 2006 +0100
     1.3 @@ -272,44 +272,44 @@ class VmxImageHandler(ImageHandler):
     1.4          nics = 0
     1.5          for (name, info) in deviceConfig:
     1.6              if name == 'vbd':
     1.7 -               uname = sxp.child_value(info, 'uname')
     1.8 -               typedev = sxp.child_value(info, 'dev')
     1.9 -               (_, vbdparam) = string.split(uname, ':', 1)
    1.10 -               if re.match('^ioemu:', typedev):
    1.11 -                  (emtype, vbddev) = string.split(typedev, ':', 1)
    1.12 -               else:
    1.13 -                  emtype = 'vbd'
    1.14 -                  vbddev = typedev
    1.15 -               if emtype != 'ioemu':
    1.16 -                  continue;
    1.17 -               vbddev_list = ['hda', 'hdb', 'hdc', 'hdd']
    1.18 -               if vbddev not in vbddev_list:
    1.19 -                  raise VmError("vmx: for qemu vbd type=file&dev=hda~hdd")
    1.20 -               ret.append("-%s" % vbddev)
    1.21 -               ret.append("%s" % vbdparam)
    1.22 +                uname = sxp.child_value(info, 'uname')
    1.23 +                typedev = sxp.child_value(info, 'dev')
    1.24 +                (_, vbdparam) = string.split(uname, ':', 1)
    1.25 +                if 'ioemu:' in typedev:
    1.26 +                    (emtype, vbddev) = string.split(typedev, ':', 1)
    1.27 +                else:
    1.28 +                    emtype = 'vbd'
    1.29 +                    vbddev = typedev
    1.30 +                if emtype == 'vbd':
    1.31 +                    continue;
    1.32 +                vbddev_list = ['hda', 'hdb', 'hdc', 'hdd']
    1.33 +                if vbddev not in vbddev_list:
    1.34 +                    raise VmError("vmx: for qemu vbd type=file&dev=hda~hdd")
    1.35 +                ret.append("-%s" % vbddev)
    1.36 +                ret.append("%s" % vbdparam)
    1.37              if name == 'vif':
    1.38 -               type = sxp.child_value(info, 'type')
    1.39 -               if type != 'ioemu':
    1.40 -                   continue
    1.41 -               nics += 1
    1.42 -               if mac != None:
    1.43 -                   continue
    1.44 -               mac = sxp.child_value(info, 'mac')
    1.45 -               bridge = sxp.child_value(info, 'bridge')
    1.46 -               if mac == None:
    1.47 -                   mac = randomMAC()
    1.48 -               if bridge == None:
    1.49 -                   bridge = 'xenbr0'
    1.50 -               ret.append("-macaddr")
    1.51 -               ret.append("%s" % mac)
    1.52 -               ret.append("-bridge")
    1.53 -               ret.append("%s" % bridge)
    1.54 +                type = sxp.child_value(info, 'type')
    1.55 +                if type != 'ioemu':
    1.56 +                    continue
    1.57 +                nics += 1
    1.58 +                if mac != None:
    1.59 +                    continue
    1.60 +                mac = sxp.child_value(info, 'mac')
    1.61 +                bridge = sxp.child_value(info, 'bridge')
    1.62 +                if mac == None:
    1.63 +                    mac = randomMAC()
    1.64 +                if bridge == None:
    1.65 +                    bridge = 'xenbr0'
    1.66 +                ret.append("-macaddr")
    1.67 +                ret.append("%s" % mac)
    1.68 +                ret.append("-bridge")
    1.69 +                ret.append("%s" % bridge)
    1.70              if name == 'vtpm':
    1.71 -               instance = sxp.child_value(info, 'pref_instance')
    1.72 -               ret.append("-instance")
    1.73 -               ret.append("%s" % instance)
    1.74 +                instance = sxp.child_value(info, 'pref_instance')
    1.75 +                ret.append("-instance")
    1.76 +                ret.append("%s" % instance)
    1.77          ret.append("-nics")
    1.78 -        ret.append("%d" % nics) 
    1.79 +        ret.append("%d" % nics)
    1.80          return ret
    1.81  
    1.82      def configVNC(self, config):
     2.1 --- a/tools/python/xen/xend/server/blkif.py	Sun Jan 01 11:29:17 2006 +0100
     2.2 +++ b/tools/python/xen/xend/server/blkif.py	Mon Jan 02 11:35:29 2006 +0100
     2.3 @@ -31,7 +31,7 @@ class BlkifController(DevController):
     2.4      """Block device interface controller. Handles all block devices
     2.5      for a domain.
     2.6      """
     2.7 -    
     2.8 +
     2.9      def __init__(self, vm):
    2.10          """Create a block device controller.
    2.11          """
    2.12 @@ -40,9 +40,9 @@ class BlkifController(DevController):
    2.13  
    2.14      def getDeviceDetails(self, config):
    2.15          """@see DevController.getDeviceDetails"""
    2.16 -        
    2.17 +
    2.18          dev = sxp.child_value(config, 'dev')
    2.19 -        if re.match('^ioemu:', dev):
    2.20 +        if 'ioemu:' in dev:
    2.21              return (None,{},{})
    2.22  
    2.23          devid = blkif.blkdev_name_to_number(dev)