Skip to contentSkip to conversation

Add argument check for xm network-attach command

PATCH RESEND Applied Masaki Kanno 2 participants 2 messages Feb 26, 2007

lore
Share & tools
lore
#0 lore raw

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

Hi,

I resend the patch that I sent as follows.

http://lists.xensource.com/archives/html/xen-devel/2007-02/msg00681.html

I think that we should check the argument of the xm network attach command as well as the vif parameter of the xm create command. Could you possibly comment or apply the patch?

Best regards,
Kan

tools/python/xen/xm/main.py +10 -3
diff -r 2c3a13993b0d 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

Applied
#1 lore raw

On Mon, Feb 26, 2007 at 07:08:08PM +0900, Masaki Kanno wrote:

Content-Description: Mail message body

Quoted 4 lines

Hi,

I resend the patch that I sent as follows.

Quoted 8 lines

http://lists.xensource.com/archives/html/xen-devel/2007-02/msg00681.html

I think that we should check the argument of the xm network attach command as well as the vif parameter of the xm create command. Could you possibly comment or apply the patch?

Applied, thank you.

Ewan.