WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

答复: [Xen-devel][PATCH]add usb-ver format check to avoid usb-list error a

To: <xen-devel@xxxxxxxxxxxxxxxxxxx>,"Chun Yan Liu" <CYLiu@xxxxxxxxxx>
Subject: 答复: [Xen-devel][PATCH]add usb-ver format check to avoid usb-list error and incorrect usb-ver saved into config file
From: "Chun Yan Liu" <cyliu@xxxxxxxxxx>
Date: Sun, 08 Aug 2010 20:08:47 -0600
Cc:
Delivery-date: Sun, 08 Aug 2010 19:09:45 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
In-reply-to: <4C5C74B00200006600016C85@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx>
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
References: <4C5C74B00200006600016C85@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
oh, sorry, I've posted the wrong patch. Make an update here.
 
Add usb-ver format check to "usb-hc-create" to fix the bug that incorrect usb-ver saved into config file and usb-list error.
 
diff -r 8992134dcfd0 tools/python/xen/xm/main.py
--- a/tools/python/xen/xm/main.py Wed Aug 04 19:24:17 2010 +0100
+++ b/tools/python/xen/xm/main.py Mon Aug 09 09:57:54 2010 +0800
@@ -225,8 +225,8 @@
     'usb-list'    :  ('<Domain>',
                         'List domain\'s attachment state of all virtual port .'),
     'usb-list-assignable-devices' : ('', 'List all the assignable usb devices'),
-    'usb-hc-create'  :  ('<Domain> <USBSpecVer> <NumberOfPorts>',
-                        'Create a domain\'s new virtual USB host controller.'),
+    'usb-hc-create'  :  ('<Domain> <USBSpecVer> <NumberOfPorts>\n       ## <USBSpecVer>: 2 (for USB2.0), 1 (for USB1.1)',
+                         'Create a domain\'s new virtual USB host controller.'),
     'usb-hc-destroy'  :  ('<Domain> <DevId>',
                         'Destroy a domain\'s virtual USB host controller.'),
 
@@ -3064,6 +3064,9 @@
     ver = args[1]
     num = args[2]
     vusb_config = ['vusb']
+    if not re.match('^\d{1}$', ver):
+        err("Invalid usb-ver format '%s'" % ver)
+        usage('usb-hc-create')
     vusb_config.append(['usb-ver', str(ver)])
     vusb_config.append(['num-ports', str(num)])
     port_config = ['port']


>>> "Chun Yan Liu" <cyliu@xxxxxxxxxx> 2010/8/6 18:46 >>>
Add usb-ver format check to "usb-hc-create".
 
In original file, "usb-hc-create" allows usb-ver parameter as "2/2.0/2.0aaa". In low level hc create, it only uses the integer part (that is "2"), so there is no problem. But 2/2.0/2.0aaa will be saved into VM config.
After that, while doing "usb-list", it cannot handle "2.0/2.0aaa" and will cause error like this:.
Idx BE  state usb-ver  BE-path
Error: Invalid argument.
Usage: xm usb-list <Domain>

To avoid this, we need either change "usb-list" code or "usb-hc-create" code.
This patch adds usb-ver format check to "usb-hc-create", do not allow 2.0/2.0aaa format. And add description in its HELP.
 
diff -r 8992134dcfd0 tools/python/xen/xm/main.py
--- a/tools/python/xen/xm/main.py Wed Aug 04 19:24:17 2010 +0100
+++ b/tools/python/xen/xm/main.py Fri Aug 06 18:02:33 2010 +0800
@@ -225,8 +225,8 @@
     'usb-list'    :  ('<Domain>',
                         'List domain\'s attachment state of all virtual port .'),
     'usb-list-assignable-devices' : ('', 'List all the assignable usb devices'),
-    'usb-hc-create'  :  ('<Domain> <USBSpecVer> <NumberOfPorts>',
-                        'Create a domain\'s new virtual USB host controller.'),
+    'usb-hc-create'  :  ('<Domain> <USBSpecVer> <NumberOfPorts>\n       ## <USBSpecVer>: 2 (for USB2.0), 1 (for USB1.1)',
+                         'Create a domain\'s new virtual USB host controller.'),
     'usb-hc-destroy'  :  ('<Domain> <DevId>',
                         'Destroy a domain\'s virtual USB host controller.'),
 
@@ -3064,6 +3064,8 @@
     ver = args[1]
     num = args[2]
     vusb_config = ['vusb']
+    if not re.match('^\d{1}$', ver):
+ print "Invalid usb-ver format '%s'" % ver
     vusb_config.append(['usb-ver', str(ver)])
     vusb_config.append(['num-ports', str(num)])
     port_config = ['port']


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel
<Prev in Thread] Current Thread [Next in Thread>