Skip to contentSkip to conversation

Add syntax checking for xm block-attach

PATCH RESEND In review Masaki Kanno 2 participants 3 messages Sep 8, 2006 – Sep 11, 2006

lore
Share & tools
lore
#0 lore raw

PATCH RESEND 1/1 Add syntax checking for xm block-attach

Hi,

This patch adds syntax checking for "xm block-attach" command. The character string that can be specified for "mode" is "r", "w", and "w!".

Best regards,
Kan

tools/python/xen/xend/server/blkif.py +8 -1
diff -r 1de184deaa9c tools/python/xen/xend/server/blkif.py
@@ -64,10 +64,17 @@ class BlkifController(DevController):
             except ValueError:
                 (typ, params) = ("", "")
 
+        # 'r'  : read-only mode
+        # 'w'  : read-write mode
+        # 'w!' : read-write and it is safe to have multiple writers on this device
+        mode = sxp.child_value(config, 'mode', 'r')
+        if mode != 'r' and mode != 'w' and mode != 'w!':
+            raise VmError('Invalid mode')
+
         back = { 'dev'    : dev,
                  'type'   : typ,
                  'params' : params,
-                 'mode'   : sxp.child_value(config, 'mode', 'r')
+                 'mode'   : mode
                }
 
         if security.on():

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

#1 lore raw

tools/python/xen/xend/server/blkif.py class BlkifController(DevController): · line 72

Quoted 6 lines · Masaki Kanno
tools/python/xen/xend/server/blkif.py +6 -0
+        # 'r'  : read-only mode
+        # 'w'  : read-write mode
+        # 'w!' : read-write and it is safe to have multiple writers on this device
+        mode = sxp.child_value(config, 'mode', 'r')
+        if mode != 'r' and mode != 'w' and mode != 'w!':
+            raise VmError('Invalid mode')

I don't think the comments are necessary; those are pretty standard.

Also, try this for your test:

	if mode not in ('r', 'w', 'w!'):
		raise VmError('Invalid mode')
Signature · 2 lines
Hollis Blanchard
IBM Linux Technology Center
#2 lore raw

Re: [PATCH][RESEND] Add syntax checking for xmblock-attach

Quoted 10 lines · Masaki Kanno

tools/python/xen/xend/server/blkif.py class BlkifController(DevController): · line 72

Quoted 7 lines
tools/python/xen/xend/server/blkif.py +3 -0
+        # 'r'  : read-only mode
+        # 'w'  : read-write mode
+        # 'w!' : read-write and it is safe to have multiple writers on 

this device

tools/python/xen/xend/server/blkif.py +3 -0
+        mode = sxp.child_value(config, 'mode', 'r')
+        if mode != 'r' and mode != 'w' and mode != 'w!':
+            raise VmError('Invalid mode')
Quoted 5 lines

I don't think the comments are necessary; those are pretty standard.

Also, try this for your test:

	if mode not in ('r', 'w', 'w!'):
		raise VmError('Invalid mode')

Hi Hollis,

Thanks for your comments and example codes.

Best regards,
Kan

Quoted 10 lines
Signature · 9 lines
-- 
Hollis Blanchard
IBM Linux Technology Center


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