2012-10-09 23:16:32 +02:00
|
|
|
#!/usr/bin/python
|
|
|
|
from xen.util import vusb_util
|
|
|
|
import sys
|
|
|
|
import os
|
|
|
|
|
|
|
|
if len(sys.argv)!=5:
|
|
|
|
print 'usage: xl-qvm-usb-attach.py domain device frontend backend'
|
|
|
|
sys.exit(1)
|
|
|
|
|
|
|
|
domain=sys.argv[1]
|
|
|
|
device=sys.argv[2]
|
|
|
|
|
|
|
|
frontend=sys.argv[3].split('-')
|
|
|
|
if len(frontend)!=2:
|
|
|
|
print 'frontend in controller/port format'
|
|
|
|
sys.exit(1)
|
|
|
|
(controller, port)=frontend
|
|
|
|
|
|
|
|
backend=sys.argv[4]
|
|
|
|
|
2012-10-09 23:33:17 +02:00
|
|
|
# FIXME: command injection
|
2012-10-09 23:16:32 +02:00
|
|
|
os.system("xenstore-write /local/domain/%s/backend/vusb/%s/%s/port/%s %s"
|
|
|
|
% (backend, domain, controller, port, device))
|
|
|
|
|
2012-10-09 23:33:17 +02:00
|
|
|
# FIXME: should this happen in the backend domain?
|
2012-10-09 23:16:32 +02:00
|
|
|
vusb_util.bind_usb_device(device)
|