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']
|