From 2e7f483a60aa6850dfcd174faa93a31c16d86975 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Marczykowski-G=C3=B3recki?= Date: Thu, 11 May 2017 21:54:40 +0200 Subject: [PATCH] Remove old pvusb handling code --- doc/README.pvusb | 69 ------------------- linux/aux-tools/Makefile | 3 - linux/aux-tools/vusb-ctl.py | 24 ------- linux/aux-tools/xl-qvm-usb-attach.py | 48 ------------- linux/aux-tools/xl-qvm-usb-detach.py | 49 ------------- rpm_spec/core-dom0.spec | 3 - tests/pvusb-001-mouse-kbd-attached | 14 ---- ...pvusb-002-mouse-kbd-usbstick-wlan-attached | 18 ----- tests/pvusb-003-list-attach-use-detach | 67 ------------------ 9 files changed, 295 deletions(-) delete mode 100644 doc/README.pvusb delete mode 100755 linux/aux-tools/vusb-ctl.py delete mode 100755 linux/aux-tools/xl-qvm-usb-attach.py delete mode 100755 linux/aux-tools/xl-qvm-usb-detach.py delete mode 100755 tests/pvusb-001-mouse-kbd-attached delete mode 100755 tests/pvusb-002-mouse-kbd-usbstick-wlan-attached delete mode 100755 tests/pvusb-003-list-attach-use-detach diff --git a/doc/README.pvusb b/doc/README.pvusb deleted file mode 100644 index a2f4e492..00000000 --- a/doc/README.pvusb +++ /dev/null @@ -1,69 +0,0 @@ -Dedicated usbvm (optional) -~~~~~~~~~~~~~~~~~~~~~~~~~~ - -In dom0, once: - qvm-create -l red usbvm - - # FIXME: use your own PCI device IDs - qvm-pci -a usbvm 00:1d.0 - qvm-pci -a usbvm 00:1d.1 - qvm-pci -a usbvm 00:1d.2 - qvm-pci -a usbvm 00:1d.7 - -After each dom0 reboot: - qvm-start usbvm - -List -~~~~ - -In dom0: - qvm-usb -l - -Example output: - dom0:7-4 0718:061a TDKMedia_Trans-It_Drive_070326AE8AF92D95 (attached to qdvp:0-1) - dom0:7-5 0b05:1706 ASUS_802.11g_WLAN_Drive (attached to sys-net:0-1) - dom0:1-1 045e:0084 Microsoft_Basic_Optical_Mouse - usbvm:4-6 05e3:0723 Generic_USB_Storage (attached to qdvp:1-1) - -Attach -~~~~~~ - -In dom0: - qvm-usb -a [--no-auto-detach] :- - -Example: - qvm-usb -a sys-net usbvm:4-1 - -Detach -~~~~~~ - -In dom0: - qvm-usb -d :- - -Example: - qvm-usb -d sys-net:0-1 - -Known issues -~~~~~~~~~~~~ - -List/attach/detach operations seem to work ok, devices are recognized by the target VM etc. -But actual usage of the attached devices is unstable at best. In fact the only working device -I saw was one USB stick (and this only after it took a minute to time out and reset the bus -couple times). Kernel crashes are normal as well. I have not investigated these issues yet, -I had similar experience with Marek's scripts. - -* System keyboard / mouse are listed and can be detached away -* Virtual USB devices (ones created by PVUSB frontend) may be listed -* The installation/configuration is not persistent, not retained between reboots -* No debugging / logging / audit trail -* When an attached device is physically unplugged, USB port remains mapped but not displayed -in the list. If device is plugged back it continues to work. Unlisted device cannot be detached. -* We are not attaching actual devices, but USB ports (different behavior from VMWare, might be confusing) -* After device is detached from the frontend and returned back to the backend it is not alwayws usable there -* Code changing configuration of pvusb fe/be and vusb bind/unbind helper are located -misc/xl-qvm-usb-attach.py misc/xl-qvm-usb-detach.py misc/vusb-ctl.py. These helpers are -deployed into the backend domain. The initialization code is qubesutils.py in usb_setup(), -should probably also be moved into an external helper. Perhaps the functionality of these -external helpers should be merged into libxl? The is one catch is invokation of vusb helper -in the backend domain -- now it relies on qubes-specific API. -* After reboot attached USB devices are not listed by 'qvm-usb -l' until replugged. diff --git a/linux/aux-tools/Makefile b/linux/aux-tools/Makefile index 123845da..646de262 100644 --- a/linux/aux-tools/Makefile +++ b/linux/aux-tools/Makefile @@ -7,8 +7,5 @@ install: cp cleanup-dispvms $(DESTDIR)/usr/lib/qubes cp startup-misc.sh $(DESTDIR)/usr/lib/qubes cp prepare-volatile-img.sh $(DESTDIR)/usr/lib/qubes - cp vusb-ctl.py $(DESTDIR)/usr/lib/qubes/ - cp xl-qvm-usb-attach.py $(DESTDIR)/usr/lib/qubes/ - cp xl-qvm-usb-detach.py $(DESTDIR)/usr/lib/qubes/ cp block-cleaner-daemon.py $(DESTDIR)/usr/lib/qubes/ cp fix-dir-perms.sh $(DESTDIR)/usr/lib/qubes/ diff --git a/linux/aux-tools/vusb-ctl.py b/linux/aux-tools/vusb-ctl.py deleted file mode 100755 index eae621c8..00000000 --- a/linux/aux-tools/vusb-ctl.py +++ /dev/null @@ -1,24 +0,0 @@ -#!/usr/bin/python - -## -## Python script wrapper around xen.util.vusb_util bind_usb_device() and unbind_usb_device() methods -## Run as root in usbvm -## - -from xen.util import vusb_util -import sys -import os - -if len(sys.argv)!=3: - print 'usage: vusb-ctl device' - sys.exit(1) - -device=sys.argv[2] -if sys.argv[1] == 'bind': - vusb_util.bind_usb_device(device) -elif sys.argv[1] == 'unbind': - vusb_util.unbind_usb_device(device) -else: - print "Invalid command, must be 'bind' or 'unbind'" - sys.exit(1) - diff --git a/linux/aux-tools/xl-qvm-usb-attach.py b/linux/aux-tools/xl-qvm-usb-attach.py deleted file mode 100755 index 58ac2a8c..00000000 --- a/linux/aux-tools/xl-qvm-usb-attach.py +++ /dev/null @@ -1,48 +0,0 @@ -#!/usr/bin/python - -## -## This script is for dom0 -## The syntax is modelled after "xl block-attach" -## - -import sys -import os -import xen.lowlevel.xl - - -# parse command line -if (len(sys.argv)<4) or (len(sys.argv)>5): - print 'usage: xl-qvm-usb-attach.py []' - sys.exit(1) - -frontendvm_xid=sys.argv[1] -backendvm_device=sys.argv[2] - -frontend=sys.argv[3].split('-') -if len(frontend)!=2: - print 'Error: frontendvm-device must be in - format' - sys.exit(1) -(controller, port)=frontend - -if len(sys.argv)>4: - 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)) - -cmd = "/usr/lib/qubes/vusb-ctl.py bind '%s'" % backendvm_device -if backendvm_xid == 0: - os.system("sudo %s" % cmd) -else: - 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(cmd, user="root") diff --git a/linux/aux-tools/xl-qvm-usb-detach.py b/linux/aux-tools/xl-qvm-usb-detach.py deleted file mode 100755 index e32fe479..00000000 --- a/linux/aux-tools/xl-qvm-usb-detach.py +++ /dev/null @@ -1,49 +0,0 @@ -#!/usr/bin/python - -## -## This script is for dom0 -## The syntax is modelled after "xl block-attach" -## FIXME: should be modelled after block-detach instead -## - -import sys -import os -import xen.lowlevel.xl - -# parse command line -if (len(sys.argv)<4) or (len(sys.argv)>5): - print 'usage: xl-qvm-usb-detach.py []' - sys.exit(1) - -frontendvm_xid=sys.argv[1] -backendvm_device=sys.argv[2] - -frontend=sys.argv[3].split('-') -if len(frontend)!=2: - print 'Error: frontendvm-device must be in - format' - sys.exit(1) -(controller, port)=frontend - -if len(sys.argv)>4: - backendvm_xid=int(sys.argv[4]) - backendvm_name=xen.lowlevel.xl.ctx().domid_to_name(backendvm_xid) -else: - backendvm_xid=0 - -cmd = "/usr/lib/qubes/vusb-ctl.py unbind '%s'" % backendvm_device -if backendvm_xid == 0: - os.system("sudo %s" % cmd) -else: - 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(cmd, user="root") - -# FIXME: command injection -os.system("xenstore-write /local/domain/%s/backend/vusb/%s/%s/port/%s ''" - % (backendvm_xid, frontendvm_xid, controller, port)) - diff --git a/rpm_spec/core-dom0.spec b/rpm_spec/core-dom0.spec index 95829cac..15555a1e 100644 --- a/rpm_spec/core-dom0.spec +++ b/rpm_spec/core-dom0.spec @@ -376,9 +376,6 @@ fi /usr/lib/qubes/unbind-pci-device.sh /usr/lib/qubes/cleanup-dispvms /usr/lib/qubes/block-cleaner-daemon.py* -/usr/lib/qubes/vusb-ctl.py* -/usr/lib/qubes/xl-qvm-usb-attach.py* -/usr/lib/qubes/xl-qvm-usb-detach.py* /usr/lib/qubes/fix-dir-perms.sh /usr/lib/qubes/startup-misc.sh /usr/lib/qubes/prepare-volatile-img.sh diff --git a/tests/pvusb-001-mouse-kbd-attached b/tests/pvusb-001-mouse-kbd-attached deleted file mode 100755 index ec51861e..00000000 --- a/tests/pvusb-001-mouse-kbd-attached +++ /dev/null @@ -1,14 +0,0 @@ -#!/bin/sh - -tmpf=`mktemp` - -sudo xenstore-ls -f qubes-usb-devices | sort > $tmpf - -cat << 'END' | diff -u - $tmpf -qubes-usb-devices/2-1 = "" -qubes-usb-devices/2-1/desc = "046a:0021 046a_0021" -qubes-usb-devices/2-2 = "" -qubes-usb-devices/2-2/desc = "045e:0745 Microsoft_Microsoft\xc2\xae_Nano_Transceiver_v1.0" -END - -rm $tmpf diff --git a/tests/pvusb-002-mouse-kbd-usbstick-wlan-attached b/tests/pvusb-002-mouse-kbd-usbstick-wlan-attached deleted file mode 100755 index 67053299..00000000 --- a/tests/pvusb-002-mouse-kbd-usbstick-wlan-attached +++ /dev/null @@ -1,18 +0,0 @@ -#!/bin/sh - -tmpf=`mktemp` - -sudo xenstore-ls -f qubes-usb-devices | sort > $tmpf - -cat << 'END' | diff -u - $tmpf -qubes-usb-devices/2-1 = "" -qubes-usb-devices/2-1/desc = "046a:0021 046a_0021" -qubes-usb-devices/2-2 = "" -qubes-usb-devices/2-2/desc = "045e:0745 Microsoft_Microsoft\xc2\xae_Nano_Transceiver_v1.0" -qubes-usb-devices/7-1 = "" -qubes-usb-devices/7-1/desc = "07d1:3c0a Ralink_11n_Adapter_1.0" -qubes-usb-devices/7-5 = "" -qubes-usb-devices/7-5/desc = "0781:5530 SanDisk_Cruzer_1942531DB09038A6" -END - -rm $tmpf diff --git a/tests/pvusb-003-list-attach-use-detach b/tests/pvusb-003-list-attach-use-detach deleted file mode 100755 index e0036de0..00000000 --- a/tests/pvusb-003-list-attach-use-detach +++ /dev/null @@ -1,67 +0,0 @@ -#!/bin/sh - -tmpf=`mktemp` -domu='qdvp' - -## === List -echo 'qvm-usb -l' -qvm-usb -l | sort > $tmpf - -cat <<'END' | diff -bu - $tmpf -dom0:2-1 046a:0021 046a_0021 -dom0:2-2 045e:0745 Microsoft_Microsoft®_Nano_Transceiver_v1.0 -dom0:7-1 07d1:3c0a Ralink_11n_Adapter_1.0 -dom0:7-5 0781:5530 SanDisk_Cruzer_1942531DB09038A6 -END - -## === Attach -echo 'qvm-usb -a' -qvm-usb -a $domu dom0:7-5 | diff -bu /dev/null - -#echo 'pvusb-script/usb-attach.py' -#sudo /home/abb/pvusb-scripts/usb-attach.py 7-5 3 1 - -## === List again -echo 'qvm-usb -l' -qvm-usb -l | sort > $tmpf - -# FIXME -cat <<'END' | diff -bu - $tmpf -dom0:2-1 046a:0021 046a_0021 -dom0:2-2 045e:0745 Microsoft_Microsoft®_Nano_Transceiver_v1.0 -dom0:7-1 07d1:3c0a Ralink_11n_Adapter_1.0 -dom0:7-5 0781:5530 SanDisk_Cruzer_1942531DB09038A6 -END - -read -p 'Press ENTER to continue' - -## === Use: try ls -echo 'qvm-run $domu ls /dev/sda' -qvm-run -p $domu 'ls /dev/sda' > $tmpf -cat <<'END' | diff -bu - $tmpf -/dev/sda -END - -## === Use: try fdisk -echo 'qvm-run $domu fdisk' -qvm-run -p $domu 'su - root -c "fdisk -l /dev/sda"' > $tmpf - -cat <<'END' | diff -bu - $tmpf - -Disk /dev/sda: 4022 MB, 4022337024 bytes -124 heads, 62 sectors/track, 1021 cylinders, total 7856127 sectors -Units = sectors of 1 * 512 = 512 bytes -Sector size (logical/physical): 512 bytes / 512 bytes -I/O size (minimum/optimal): 512 bytes / 512 bytes -Disk identifier: 0x3963a77b - - Device Boot Start End Blocks Id System -/dev/sda1 * 62 7849447 3924693 c W95 FAT32 (LBA) -END - -## === Detach -#echo 'qvm-usb -d' -#qvm-usb -d $domu:7-5 | diff -bu /dev/null - -echo 'pvusb-script/usb-detach.py' -sudo /home/abb/pvusb-scripts/usb-detach.py 7-5 4 1 - -rm $tmpf