dom0+vm/usb: add USB version to device list displayed by qvm-usb -l'

This commit is contained in:
Alexandre Bezroutchko 2012-10-26 23:09:36 +02:00
parent d37efe031e
commit 14fff45ddd
3 changed files with 10 additions and 3 deletions

View File

@ -466,6 +466,7 @@ def usb_list():
device_re = re.compile(r"^[0-9]+-[0-9]+(_[0-9]+)?$")
# FIXME: any better idea of desc_re?
desc_re = re.compile(r"^.{1,255}$")
usb_ver_re = re.compile(r"^(1|2)$")
devices_list = {}
@ -489,9 +490,15 @@ def usb_list():
# xenstore doesn't allow dot in key names - was translated to underscore
device = device.replace('_', '.')
visible_name = "%s:%s" % (vm_name, device)
# grab version
usb_ver = xs.read(xs_trans, '/local/domain/%s/qubes-usb-devices/%s/usb-ver' % (xid, device))
if usb_ver is None or not usb_ver_re.match(usb_ver):
print >> sys.stderr, "Invalid %s device USB version in VM '%s'" % (device, vm_name)
continue
devices_list[visible_name] = {"name": visible_name, "xid":int(xid),
"vm": vm_name, "device":device,
"desc":device_desc}
"desc":device_desc,
"usb_ver":usb_ver}
xs.transaction_end(xs_trans)
return devices_list

View File

@ -131,7 +131,7 @@ def main():
attached_to_str = ""
if attached_to:
attached_to_str = " (attached to %s:%s)" % (attached_to['vm'], attached_to['frontend'])
print "%s\t%s%s" % (dev['name'], dev['desc'], attached_to_str)
print "%s\t%s%s (USBv%s)" % (dev['name'], dev['desc'], attached_to_str, dev['usb_ver'])
exit (0)
main()

View File

@ -35,7 +35,7 @@ fi
XS_KEY="qubes-usb-devices/$XSNAME"
xenstore-write "$XS_KEY/desc" "$DESC"
xenstore-write "$XS_KEY/version" "$VERSION"
xenstore-write "$XS_KEY/usb-ver" "$VERSION"
# Make sure PVUSB backend driver is loaded.
/sbin/modprobe xen-usbback 2> /dev/null || /sbin/modprobe usbbk