From 2741201e24083f9eacee4064d25411365baab64f Mon Sep 17 00:00:00 2001 From: Alexandre Bezroutchko Date: Thu, 11 Oct 2012 21:57:12 +0200 Subject: [PATCH] dom0/qvm-usb: now use vm.run() to call vusb-ctl bind/unbind --- install-pvusb-backend.sh | 2 ++ misc/xl-qvm-usb-attach.py | 16 +++++++++++----- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/install-pvusb-backend.sh b/install-pvusb-backend.sh index ef0ea31..4e6f3bb 100755 --- a/install-pvusb-backend.sh +++ b/install-pvusb-backend.sh @@ -11,6 +11,8 @@ cp misc/usb_remove /usr/lib/qubes/usb_remove cp misc/vusb-ctl.py /usr/lib/qubes/vusb-ctl.py cp misc/qubes_usb.rules /etc/udev/rules.d/99-qubes_usb.rules +# FIXME: /usr/lib64/python2.6/site-packages/xen + # Load PVUSB backend modprobe xen-usbback diff --git a/misc/xl-qvm-usb-attach.py b/misc/xl-qvm-usb-attach.py index e3d837c..e854229 100755 --- a/misc/xl-qvm-usb-attach.py +++ b/misc/xl-qvm-usb-attach.py @@ -31,12 +31,18 @@ else: backendvm_xid=0 # 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'" % (backendvm_xid, frontendvm_xid, controller, port, backendvm_device)) -# FIXME: vm.run -cmd = "sudo /usr/lib/qubes/vusb-ctl.py bind %s" % backendvm_device +cmd = "/usr/lib/qubes/vusb-ctl.py bind '%s'" % backendvm_device if backendvm_xid == 0: - os.system(cmd) + os.system("sudo %s" % cmd) else: - os.system("qvm-run -p %s '%s'" % (backendvm_name, cmd)) + from qubes.qubes import QubesVmCollection + qvm_collection = QubesVmCollection() + qvm_collection.lock_db_for_reading() + qvm_collection.load() + qvm_collection.unlock_db() + + # launch + qvm_collection.get_vm_by_name(backendvm_name).run("root: %s" % cmd)