Skip to contentSkip to conversation

Add argument check for xm network-attach command

PATCH Superseded Masaki Kanno 1 participant 1 message Feb 16, 2007

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Add argument check for xm network-attach command

Hi,

The xm network-attach command does not check the arguments of second and later. (e.g. type=, mac=, bridge=, etc...) This patch adds the argument check for the xm network-attach command. It checks only the key of the arguments. It does not check the value of the arguments.

Best regards,
Kan

tools/python/xen/xm/main.py +10 -3
diff -r 9af0c7e4ff51 tools/python/xen/xm/main.py
@@ -153,7 +153,7 @@ SUBCOMMAND_HELP = {
                         'List virtual block devices for a domain.'),
     'network-attach':  ('<Domain> [type=<type>] [mac=<mac>] [bridge=<bridge>] '
                         '[ip=<ip>] [script=<script>] [backend=<BackDomain>] '
-                        '[vifname=<name>]',
+                        '[vifname=<name>] [rate=<rate>] [model=<model>]',
                         'Create a new virtual network device.'),
     'network-detach':  ('<Domain> <DevId> [-f|--force]',
                         'Destroy a domain\'s virtual network device.'),
@@ -1566,13 +1566,20 @@ def xm_block_configure(args):
 
 
 def xm_network_attach(args):
-    arg_check(args, 'network-attach', 1, 10000)
+    arg_check(args, 'network-attach', 1, 10)
 
     dom = args[0]
     vif = ['vif']
+    vif_params = ['type', 'mac', 'bridge', 'ip', 'script', \
+                  'backend', 'vifname', 'rate', 'model']
 
     for a in args[1:]:
-        vif.append(a.split("="))
+        vif_param = a.split("=")
+        if len(vif_param) != 2 or vif_param[1] == '' or \
+           vif_param[0] not in vif_params:
+            err("Invalid argument: %s" % a)
+            usage('network-attach')
+        vif.append(vif_param)
 
     server.xend.domain.device_create(dom, vif)
 

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel