vusb-ctl.py 523 B

123456789101112131415161718192021222324
  1. #!/usr/bin/python
  2. ##
  3. ## Python script wrapper around xen.util.vusb_util bind_usb_device() and unbind_usb_device() methods
  4. ## Run as root in usbvm
  5. ##
  6. from xen.util import vusb_util
  7. import sys
  8. import os
  9. if len(sys.argv)!=3:
  10. print 'usage: vusb-ctl <bind|unbind> device'
  11. sys.exit(1)
  12. device=sys.argv[2]
  13. if sys.argv[1] == 'bind':
  14. vusb_util.bind_usb_device(device)
  15. elif sys.argv[1] == 'unbind':
  16. vusb_util.unbind_usb_device(device)
  17. else:
  18. print "Invalid command, must be 'bind' or 'unbind'"
  19. sys.exit(1)