dom0/qvm-usb: attach works again for dom0 backend

This commit is contained in:
Alexandre Bezroutchko 2012-10-11 02:10:47 +02:00
parent db4d49b19c
commit d613d6a04d
3 changed files with 16 additions and 9 deletions

View File

@ -26,7 +26,11 @@ In appvms, after each reboot:
sudo ./install-pvusb-frontend.sh
In dom0, after each usbvm and appvm reboot (FIXME):
sudo initpv.py <backend-id> <frontend-id> <device-id>
sudo ../pvusb-scripts/initpv.py <backend-id> <frontend-id> <device-id>
After the above is done:
'qvm-usb -l' in usbvm displays a list of local USB devices
'lsusb' in appvm displays an entry for the root hub
Attach
~~~~~~

View File

@ -574,8 +574,8 @@ def do_usb_attach(vm, backend_vm, device, frontend, auto_detach, wait):
else:
raise QubesException("Device %s from %s already connected to VM %s as %s" % (device, backend_vm.name, attached_vm['vm'], attached_vm['frontend']))
# FIXME sudo
xl_cmd = [ 'sudo', '/usr/lib/qubes/xl-qvm-usb-attach.py', str(vm.xid), device, frontend, str(backend_vm.xid) ]
# Run helper script
xl_cmd = [ '/usr/lib/qubes/xl-qvm-usb-attach.py', str(vm.xid), device, frontend, str(backend_vm.xid) ]
subprocess.check_call(xl_cmd)
def usb_detach(vm, frontend, vm_xid = None):

View File

@ -24,16 +24,19 @@ if len(frontend)!=2:
sys.exit(1)
(controller, port)=frontend
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))
backendvm_xid=int(sys.argv[4])
backendvm_name=xen.lowlevel.xl.ctx().domid_to_name(backendvm_xid)
else:
backendvm_xid=0
# FIXME: command injection
os.system("xenstore-write /local/domain/%s/backend/vusb/%s/%s/port/%s %s"
% (backendvm_xid, frontendvm_xid, controller, port, backendvm_device))
# FIXME: vm.run
print "### qvm-run %s sudo /usr/lib/qubes/vusb-ctl.py unbind %s" % (backendvm_name, backendvm_device)
cmd = "sudo /usr/lib/qubes/vusb-ctl.py bind %s" % backendvm_device
if backendvm_xid == 0:
os.system(cmd)
else:
os.system("qvm-run -p %s '%s'" % (backendvm_name, cmd))