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/
Home Products Support Community News


[Xen-devel][PATCH]add usb-ver format check to avoid usb-list error and i

To: <xen-devel@xxxxxxxxxxxxxxxxxxx>
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: Fri, 06 Aug 2010 04:46:40 -0600
Delivery-date: Fri, 06 Aug 2010 03:47:47 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
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>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
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']

Attachment: usbver_check.patch
Description: Text document

Xen-devel mailing list
<Prev in Thread] Current Thread [Next in Thread>