xen/usb-list.patch

46 lines
1.7 KiB
Diff

"usb-hc-create" does not check usb-ver parameter. It allows 2/2.0/2.0usb/2.0aaa. While low level
driver doing hc create, it gets an integer by vssanf %d from usb-ver string, so there is no problem.
But 2/2.0/2.0usb/2.0aaa will be saved into VM config.
After that, while doing "usb-list", it cannot handle "2.0/2.0usb/2.0aaa" and will cause error:
Idx BE state usb-ver BE-path
Error: Invalid argument.
Usage: xm usb-list <Domain>
This patch is to let "usb-list" handle all usb-ver cases as low level driver does and won't cause error.
About this problem, I've submitted two patches to upstream before, but got no response. Information
could be referred to:
http://www.gossamer-threads.com/lists/xen/devel/178406?search_string=usb-list;#178406
http://www.gossamer-threads.com/lists/xen/devel/181021?search_string=usb-list;#181021
Index: xen-4.0.1-testing/tools/python/xen/xm/main.py
===================================================================
--- xen-4.0.1-testing.orig/tools/python/xen/xm/main.py
+++ xen-4.0.1-testing/tools/python/xen/xm/main.py
@@ -2545,10 +2545,22 @@ def xm_usb_list(args):
ni = parse_dev_info(x[1])
ni['idx'] = int(x[0])
usbver = sxp.child_value(x[1], 'usb-ver')
+
+ substr = re.search("^\d{1,}", usbver)
+ if substr:
+ usbver = substr.group()
+ else:
+ print "Unknown usb-ver"
+ continue
+
if int(usbver) == 1:
ni['usb-ver'] = 'USB1.1'
- else:
+ elif int(usbver) == 2:
ni['usb-ver'] = 'USB2.0'
+ else:
+ print "Unknown usb-ver"
+ continue
+
print "%(idx)-3d %(backend-id)-3d %(state)-5d %(usb-ver)-7s %(be-path)-30s " % ni
ports = sxp.child(x[1], 'port')