ia64/xen-unstable

changeset 15822:2f13d0f2b07c

xend: Add blktap disk type check

Print the following error when you give a wrong disk type to xm commands:
# xm create /xen/vm1.conf disk='tap:xxx:/xen/root-vm1.img,hda1,w'
Using config file "/xen/vm1.conf".
Error: tap:xxx not a valid disk type

# xm block-attach vm2 tap:yyy:/xen/second.img hdb1 w
Error: tap:yyy not a valid disk type
Usage: xm block-attach <Domain> <BackDev> <FrontDev> <Mode>
[BackDomain]

Signed-off-by: Masaki Kanno <kanno.masaki@jp.fujitsu.com>
author kfraser@localhost.localdomain
date Fri Aug 31 14:11:15 2007 +0100 (2007-08-31)
parents 06ac4c740c4a
children 5ee379a1f0d0
files tools/python/xen/xend/XendConfig.py tools/python/xen/xend/server/BlktapController.py
line diff
     1.1 --- a/tools/python/xen/xend/XendConfig.py	Fri Aug 31 14:09:05 2007 +0100
     1.2 +++ b/tools/python/xen/xend/XendConfig.py	Fri Aug 31 14:11:15 2007 +0100
     1.3 @@ -28,6 +28,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.BlktapController import blktap_disk_types
     1.8  from xen.xend.server.netif import randomMAC
     1.9  from xen.util.blkif import blkdev_name_to_number
    1.10  from xen.util import xsconstants
    1.11 @@ -1084,6 +1085,11 @@ class XendConfig(dict):
    1.12                  else:
    1.13                      dev_info['driver'] = 'paravirtualised'
    1.14  
    1.15 +            if dev_type == 'tap':
    1.16 +                if dev_info['uname'].split(':')[1] not in blktap_disk_types:
    1.17 +                    raise XendConfigError("tap:%s not a valid disk type" %
    1.18 +                                    dev_info['uname'].split(':')[1])
    1.19 +
    1.20              if dev_type == 'vif':
    1.21                  if not dev_info.get('mac'):
    1.22                      dev_info['mac'] = randomMAC()
     2.1 --- a/tools/python/xen/xend/server/BlktapController.py	Fri Aug 31 14:09:05 2007 +0100
     2.2 +++ b/tools/python/xen/xend/server/BlktapController.py	Fri Aug 31 14:11:15 2007 +0100
     2.3 @@ -7,6 +7,14 @@ from xen.xend.XendLogging import log
     2.4  phantomDev = 0;
     2.5  phantomId = 0;
     2.6  
     2.7 +blktap_disk_types = [
     2.8 +    'aio',
     2.9 +    'sync',
    2.10 +    'vmdk',
    2.11 +    'ram',
    2.12 +    'qcow'
    2.13 +    ]
    2.14 +
    2.15  class BlktapController(BlkifController):
    2.16      def __init__(self, vm):
    2.17          BlkifController.__init__(self, vm)