dom+vm/qvm-usb: improve handling devices like "2-1.4"
xenstore doesn't allow '.' in key name, so translate it to '_'
This commit is contained in:
parent
b2a784d35f
commit
4b44a149c1
@ -463,7 +463,7 @@ def usb_list():
|
||||
name = <name of backend domain>:<frontend device number>-<frontend port number>
|
||||
desc = description
|
||||
"""
|
||||
device_re = re.compile(r"^[0-9]+-[0-9]+$")
|
||||
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}$")
|
||||
|
||||
@ -486,6 +486,8 @@ def usb_list():
|
||||
if not desc_re.match(device_desc):
|
||||
print >> sys.stderr, "Invalid %s device desc in VM '%s'" % (device, vm_name)
|
||||
continue
|
||||
# xenstore doesn't allow dot in key names - was translated to underscore
|
||||
device = device.replace('_', '.')
|
||||
visible_name = "%s:%s" % (vm_name, device)
|
||||
devices_list[visible_name] = {"name": visible_name, "xid":int(xid),
|
||||
"vm": vm_name, "device":device,
|
||||
|
@ -12,7 +12,8 @@
|
||||
[ "$DEVNUM" = "001" ] && exit 0
|
||||
[ "$DEVTYPE" != "usb_device" ] && exit 0
|
||||
|
||||
NAME=`basename ${DEVPATH}`
|
||||
# xenstore doesn't allow dot in key name
|
||||
NAME=`basename ${DEVPATH} | tr . _`
|
||||
# FIXME: For some devices (my Cherry keyboard) ID_SERIAL does not
|
||||
# contain proper human-readable name, should find better method to
|
||||
# build devide description.
|
||||
|
@ -3,7 +3,7 @@
|
||||
# FIXME: Ignore USB hubs.
|
||||
[ "$DEVNUM" = "001" ] && exit 0
|
||||
|
||||
NAME=`basename ${DEVPATH}`
|
||||
NAME=`basename ${DEVPATH} | tr . _`
|
||||
XS_KEY="qubes-usb-devices/$NAME"
|
||||
|
||||
xenstore-rm "$XS_KEY"
|
||||
|
Loading…
Reference in New Issue
Block a user