dom0+vm/qvm-usb: intermediate
This commit is contained in:
parent
73d8922e25
commit
db4d49b19c
@ -25,6 +25,9 @@ In usbvm, after each reboot:
|
|||||||
In appvms, after each reboot:
|
In appvms, after each reboot:
|
||||||
sudo ./install-pvusb-frontend.sh
|
sudo ./install-pvusb-frontend.sh
|
||||||
|
|
||||||
|
In dom0, after each usbvm and appvm reboot (FIXME):
|
||||||
|
sudo initpv.py <backend-id> <frontend-id> <device-id>
|
||||||
|
|
||||||
Attach
|
Attach
|
||||||
~~~~~~
|
~~~~~~
|
||||||
|
|
||||||
|
@ -532,6 +532,9 @@ def usb_check_attached(backend_vm, device):
|
|||||||
if dev == device:
|
if dev == device:
|
||||||
frontend = "%s-%s" % (frontend_dev, port)
|
frontend = "%s-%s" % (frontend_dev, port)
|
||||||
vm_name = xl_ctx.domid_to_name(int(vm))
|
vm_name = xl_ctx.domid_to_name(int(vm))
|
||||||
|
if vm_name is None:
|
||||||
|
# FIXME: should we wipe references to frontends running on nonexistent VMs?
|
||||||
|
continue
|
||||||
attached_dev = {"xid":int(vm), "frontend": frontend, "devid": device, "vm": vm_name}
|
attached_dev = {"xid":int(vm), "frontend": frontend, "devid": device, "vm": vm_name}
|
||||||
break
|
break
|
||||||
xs.transaction_end(xs_trans)
|
xs.transaction_end(xs_trans)
|
||||||
|
@ -16,9 +16,9 @@ if len(sys.argv)!=3:
|
|||||||
device=sys.argv[2]
|
device=sys.argv[2]
|
||||||
if sys.argv[1] == 'bind':
|
if sys.argv[1] == 'bind':
|
||||||
vusb_util.bind_usb_device(device)
|
vusb_util.bind_usb_device(device)
|
||||||
elif sys.argv[1] == 'ubind':
|
elif sys.argv[1] == 'unbind':
|
||||||
vusb_util.unbind_usb_device(device)
|
vusb_util.unbind_usb_device(device)
|
||||||
else
|
else:
|
||||||
print "Invalid command, must be 'bind' or 'unbind'"
|
print "Invalid command, must be 'bind' or 'unbind'"
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
|
@ -1,26 +1,39 @@
|
|||||||
#!/usr/bin/python
|
#!/usr/bin/python
|
||||||
from xen.util import vusb_util
|
|
||||||
|
##
|
||||||
|
## This script is for dom0
|
||||||
|
## The syntax is modelled after "xl block-attach"
|
||||||
|
##
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
import os
|
import os
|
||||||
|
import xen.lowlevel.xl
|
||||||
|
|
||||||
if len(sys.argv)!=5:
|
|
||||||
print 'usage: xl-qvm-usb-attach.py domain device frontend backend'
|
# parse command line
|
||||||
|
if (len(sys.argv)<4) or (len(sys.argv)>5):
|
||||||
|
print 'usage: xl-qvm-usb-attach.py <frontendvm-xid> <backendvm-device> <frontendvm-device> [<backendvm-xid>]'
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
domain=sys.argv[1]
|
frontendvm_xid=sys.argv[1]
|
||||||
device=sys.argv[2]
|
backendvm_device=sys.argv[2]
|
||||||
|
|
||||||
frontend=sys.argv[3].split('-')
|
frontend=sys.argv[3].split('-')
|
||||||
if len(frontend)!=2:
|
if len(frontend)!=2:
|
||||||
print 'frontend in controller/port format'
|
print 'Error: frontendvm-device must be in <controller>-<port> format'
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
(controller, port)=frontend
|
(controller, port)=frontend
|
||||||
|
|
||||||
backend=sys.argv[4]
|
backendvm_xid=0
|
||||||
|
if len(sys.argv)>4:
|
||||||
|
backendvm_xid=sys.argv[4]
|
||||||
|
|
||||||
|
# determine the name of the backend-vm
|
||||||
|
backendvm_name=xen.lowlevel.xl.ctx().domid_to_name(int(backendvm_xid))
|
||||||
|
|
||||||
# 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))
|
% (backendvm_xid, frontendvm_xid, controller, port, backendvm_device))
|
||||||
|
|
||||||
# FIXME: should this happen in the backend domain?
|
# FIXME: vm.run
|
||||||
vusb_util.bind_usb_device(device)
|
print "### qvm-run %s sudo /usr/lib/qubes/vusb-ctl.py unbind %s" % (backendvm_name, backendvm_device)
|
||||||
|
Loading…
Reference in New Issue
Block a user