ia64/xen-unstable

changeset 14143:45ddffd595a1

Add argument check for xm network-attach command

Signed-off-by: Masaki Kanno <kanno.masaki@jp.fujitsu.com>
author Ewan Mellor <ewan@xensource.com>
date Mon Feb 26 15:50:50 2007 +0000 (2007-02-26)
parents 0261e86db3b1
children 9e5e94942045
files tools/python/xen/xm/main.py
line diff
     1.1 --- a/tools/python/xen/xm/main.py	Mon Feb 26 15:41:35 2007 +0000
     1.2 +++ b/tools/python/xen/xm/main.py	Mon Feb 26 15:50:50 2007 +0000
     1.3 @@ -155,7 +155,7 @@ SUBCOMMAND_HELP = {
     1.4                          'List virtual block devices for a domain.'),
     1.5      'network-attach':  ('<Domain> [type=<type>] [mac=<mac>] [bridge=<bridge>] '
     1.6                          '[ip=<ip>] [script=<script>] [backend=<BackDomain>] '
     1.7 -                        '[vifname=<name>]',
     1.8 +                        '[vifname=<name>] [rate=<rate>] [model=<model>]',
     1.9                          'Create a new virtual network device.'),
    1.10      'network-detach':  ('<Domain> <DevId> [-f|--force]',
    1.11                          'Destroy a domain\'s virtual network device.'),
    1.12 @@ -1595,13 +1595,20 @@ def xm_block_configure(args):
    1.13  
    1.14  
    1.15  def xm_network_attach(args):
    1.16 -    arg_check(args, 'network-attach', 1, 10000)
    1.17 +    arg_check(args, 'network-attach', 1, 10)
    1.18  
    1.19      dom = args[0]
    1.20      vif = ['vif']
    1.21 +    vif_params = ['type', 'mac', 'bridge', 'ip', 'script', \
    1.22 +                  'backend', 'vifname', 'rate', 'model']
    1.23  
    1.24      for a in args[1:]:
    1.25 -        vif.append(a.split("="))
    1.26 +        vif_param = a.split("=")
    1.27 +        if len(vif_param) != 2 or vif_param[1] == '' or \
    1.28 +           vif_param[0] not in vif_params:
    1.29 +            err("Invalid argument: %s" % a)
    1.30 +            usage('network-attach')
    1.31 +        vif.append(vif_param)
    1.32  
    1.33      server.xend.domain.device_create(dom, vif)
    1.34