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 f8f04f4b38
commit a0e3e55787
2 changed files with 14 additions and 7 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

@ -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))