dom0+vm/qvm-usb: cosmetic: removed debugging code, adjusted fixmes

This commit is contained in:
Alexandre Bezroutchko 2012-10-09 23:33:17 +02:00
parent d9055bda3f
commit 81ca750403
3 changed files with 10 additions and 15 deletions

View File

@ -439,31 +439,25 @@ def usb_list():
return devices_list return devices_list
def usb_check_attached(backend_vm, device): def usb_check_attached(backend_vm, device):
# example: /local/domain/0/backend/vusb/4/0/port/1 = "7-5" # sample xs content: /local/domain/0/backend/vusb/4/0/port/1 = "7-5"
##print "*** usb_check_attached(%s, %s) called" % (str(backend_vm), str(device)) # FIXME: use XS transaction
# FIXME use XS transaction
xs_trans = '' xs_trans = ''
vms = xs.ls(xs_trans, '/local/domain/%d/backend/vusb' % backend_vm) vms = xs.ls(xs_trans, '/local/domain/%d/backend/vusb' % backend_vm)
##print "*** usb_check_attached: vms=%s" % str(vms)
if vms is None: if vms is None:
return None return None
for vm in vms: for vm in vms:
# FIXME validate vm? # FIXME: validate vm?
frontend_devs = xs.ls(xs_trans, '/local/domain/%d/backend/vusb/%s' % (backend_vm, vm)) frontend_devs = xs.ls(xs_trans, '/local/domain/%d/backend/vusb/%s' % (backend_vm, vm))
##print "*** usb_check_attached: frontend_devs=%s" % str(frontend_devs)
if frontend_devs is None: if frontend_devs is None:
continue continue
for frontend_dev in frontend_devs: for frontend_dev in frontend_devs:
# FIXME validate frontend_dev? # FIXME: validate frontend_dev?
##print '>>>/local/domain/%d/backend/vusb/%s/%s/port' % (backend_vm, vm, frontend_dev)
ports = xs.ls(xs_trans, '/local/domain/%d/backend/vusb/%s/%s/port' % (backend_vm, vm, frontend_dev)) ports = xs.ls(xs_trans, '/local/domain/%d/backend/vusb/%s/%s/port' % (backend_vm, vm, frontend_dev))
##print "*** usb_check_attached: ports=%s" % str(ports)
if ports is None: if ports is None:
continue continue
for port in ports: for port in ports:
# FIXME validate ports? # FIXME: validate ports?
dev = xs.read(xs_trans, '/local/domain/%d/backend/vusb/%s/%s/port/%s' % (backend_vm, vm, frontend_dev, port)) dev = xs.read(xs_trans, '/local/domain/%d/backend/vusb/%s/%s/port/%s' % (backend_vm, vm, frontend_dev, port))
##print "*** usb_check_attached: port=%s, device=%s" % (port, str(dev))
if dev == device: if dev == device:
frontend = "%s-%s" % (frontend_dev, port) frontend = "%s-%s" % (frontend_dev, port)
return {"xid":int(vm), "frontend": frontend, "devid": device, "vm": "FIXME"} return {"xid":int(vm), "frontend": frontend, "devid": device, "vm": "FIXME"}
@ -473,14 +467,14 @@ def usb_check_frontend_busy(vm, front_dev, port):
devport = frontend.split("-") devport = frontend.split("-")
if len(devport) != 2: if len(devport) != 2:
raise QubesException("Malformed frontend syntax, must be in device-port format") raise QubesException("Malformed frontend syntax, must be in device-port format")
# FIXME # FIXME:
# return xs.read('', '/local/domain/%d/device/vusb/%d/state' % (vm.xid, frontend)) == '4' # return xs.read('', '/local/domain/%d/device/vusb/%d/state' % (vm.xid, frontend)) == '4'
return False return False
def usb_find_unused_frontend(vm): def usb_find_unused_frontend(vm):
front_dev = 0 front_dev = 0
port = 1 port = 1
# FIXME raise QubesException("No unused frontend found") # FIXME: raise QubesException("No unused frontend found")
return '%d-%d' % (front_dev, port) return '%d-%d' % (front_dev, port)
def usb_attach(vm, backend_vm, device, frontend=None, auto_detach=False, wait=True): def usb_attach(vm, backend_vm, device, frontend=None, auto_detach=False, wait=True):

View File

@ -8,7 +8,7 @@
## running in dom0. ## running in dom0.
## ##
# FIXME: Ignore USB hubs and other wierd devices. # FIXME: Ignore USB hubs and other wierd devices (see also in usb_remove).
[ "$DEVNUM" = "001" ] && exit 0 [ "$DEVNUM" = "001" ] && exit 0
[ "$DEVTYPE" != "usb_device" ] && exit 0 [ "$DEVTYPE" != "usb_device" ] && exit 0

View File

@ -18,8 +18,9 @@ if len(frontend)!=2:
backend=sys.argv[4] backend=sys.argv[4]
# FIXME command injection # FIXME: command injection
os.system("xenstore-write /local/domain/%s/backend/vusb/%s/%s/port/%s %s" os.system("xenstore-write /local/domain/%s/backend/vusb/%s/%s/port/%s %s"
% (backend, domain, controller, port, device)) % (backend, domain, controller, port, device))
# FIXME: should this happen in the backend domain?
vusb_util.bind_usb_device(device) vusb_util.bind_usb_device(device)