From 5d4cf00899a14d7dc2cf1cf4b4964946195d80fc Mon Sep 17 00:00:00 2001 From: Alexandre Bezroutchko Date: Sun, 21 Oct 2012 15:10:40 +0200 Subject: [PATCH] dvp/qvm-usb: converted installer scripts into RPM --- README.pvusb | 46 +++++++++++---------------------------- install-pvusb-backend.sh | 23 -------------------- install-pvusb-dom0.sh | 13 ----------- install-pvusb-frontend.sh | 8 ------- install-pvusb.sh | 37 ------------------------------- misc/qubes_core.modules | 1 + rpm_spec/core-dom0.spec | 12 ++++++++++ rpm_spec/core-vm.spec | 9 ++++++++ 8 files changed, 35 insertions(+), 114 deletions(-) delete mode 100755 install-pvusb-backend.sh delete mode 100755 install-pvusb-dom0.sh delete mode 100755 install-pvusb-frontend.sh delete mode 100755 install-pvusb.sh diff --git a/README.pvusb b/README.pvusb index 380a480e..419737a7 100644 --- a/README.pvusb +++ b/README.pvusb @@ -13,35 +13,6 @@ In dom0, once: After each dom0 reboot: qvm-start usbvm -Confirm it finds all the devices - -Installation (short way) -~~~~~~~~~~~~~~~~~~~~~~~~ - -Check install-pvusb.sh, change parameters on the top. Defaults are: - - dom0_usbvm=y # deploy pvusb backend in dom0 - usbvms="usbvm" # deploy pvusb backend in these domUs - appvms="netvm qdvp" # deploy pvusb frontend in these domUs - -Run it in dom0 (it will use sudo inside as needed): - ./install-pvusb.sh - -Installation (long way) -~~~~~~~~~~~~~~~~~~~~~~~ - -In dom0, after each dom0 reboot: - sudo ./install-pvusb-dom0.sh -FIXME: merge the installer into some rpm - -In usbvm, after each reboot: - sudo ./install-pvusb-backend.sh -FIXME: convert the installer into "qubes-pvusb-backend" rpm? - -In appvms, after each reboot: - sudo ./install-pvusb-frontend.sh -FIXME: convert the installer into "qubes-pvusb-frontend" rpm? - List ~~~~ @@ -75,15 +46,24 @@ Example: 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. +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. -* The content of backend/vusb does not get cleaned on domain shutdown (?) * 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. +* 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. +* 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. diff --git a/install-pvusb-backend.sh b/install-pvusb-backend.sh deleted file mode 100755 index fedd2717..00000000 --- a/install-pvusb-backend.sh +++ /dev/null @@ -1,23 +0,0 @@ -#!/bin/sh -xe - -## -## Run this script in usbvm as root. -## FIXME: this has to be done after each reboot -## - -# Copy files -cp misc/usb_add_change /usr/lib/qubes/usb_add_change -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: need better way to deploy libraries needed by xen.vusb_util -[ -d /usr/lib64/python2.7/site-packages ] && - tar xzf install-pvusb-xen.tgz -C /usr/lib64/python2.7/site-packages - -# Load PVUSB backend -modprobe xen-usbback - -# Configure udevd and make it re-populate xenstore -udevadm control --reload-rules -udevadm trigger --action=change diff --git a/install-pvusb-dom0.sh b/install-pvusb-dom0.sh deleted file mode 100755 index aaf1a568..00000000 --- a/install-pvusb-dom0.sh +++ /dev/null @@ -1,13 +0,0 @@ -#!/bin/sh -xe - -## -## Run this script in dom0 -## FIXME: this has to be done after each reboot -## - -# Copy files -cp misc/xl-qvm-usb-attach.py /usr/lib/qubes/xl-qvm-usb-attach.py -cp misc/xl-qvm-usb-detach.py /usr/lib/qubes/xl-qvm-usb-detach.py -cp dom0/qvm-core/qubesutils.py /usr/lib64/python2.6/site-packages/qubes/qubesutils.py -cp dom0/qvm-core/qubes.py /usr/lib64/python2.6/site-packages/qubes/qubes.py -cp dom0/qvm-tools/qvm-usb /usr/bin/qvm-usb diff --git a/install-pvusb-frontend.sh b/install-pvusb-frontend.sh deleted file mode 100755 index 14e65866..00000000 --- a/install-pvusb-frontend.sh +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/sh -xe - -## -## Run this script in appvm as root -## FIXME: now this has to be done after each reboot -## - -modprobe xen-usbfront diff --git a/install-pvusb.sh b/install-pvusb.sh deleted file mode 100755 index 8d960437..00000000 --- a/install-pvusb.sh +++ /dev/null @@ -1,37 +0,0 @@ -#!/bin/sh -xe - -dom0_usbvm=y -usbvms="usbvm" -appvms="netvm qdvp" - -# --- Copy files --------------------------------------------------------- -for vm in $usbvms $appvms ; do - (cd .. && tar c qubes-core) | qvm-run -p $vm 'tar x' -done - -# --- Init dom0 ---------------------------------------------------------- -sudo ./install-pvusb-dom0.sh - -# --- Init dom0 as usbvm ------------------------------------------------- -if [ "$dom0_usbvm" = "y" ] ; then - sudo ./install-pvusb-backend.sh -fi - -# --- Init usbvms -------------------------------------------------------- -for usbvm in $usbvms ; do - usbvm_xid=`xl list | awk "(\\$1==\"$usbvm\"){print \\$2}"` - if [ -z "$usbvm_xid" ] ; then - echo "Can't determine xid for $usbvm" - else - xenstore-write /local/domain/${usbvm_xid}/qubes-usb-devices '' - xenstore-chmod /local/domain/${usbvm_xid}/qubes-usb-devices n0 b${usbvm_xid} - fi - - qvm-run -p $usbvm 'script -qc "cd qubes-core && sudo ./install-pvusb-backend.sh" /dev/null' -done - -# --- Init appvm --------------------------------------------------------- -for appvm in $appvms ; do - qvm-run -p $appvm 'script -qc "cd qubes-core && sudo ./install-pvusb-frontend.sh" /dev/null' -done - diff --git a/misc/qubes_core.modules b/misc/qubes_core.modules index 9f39e795..42ce0fb3 100755 --- a/misc/qubes_core.modules +++ b/misc/qubes_core.modules @@ -1,2 +1,3 @@ modprobe evtchn 2>/dev/null || modprobe xen-evtchn modprobe xen-blkback 2> /dev/null || modprobe blkbk +modprobe xen-usbfront 2> /dev/null diff --git a/rpm_spec/core-dom0.spec b/rpm_spec/core-dom0.spec index 0f50e0d9..07654515 100644 --- a/rpm_spec/core-dom0.spec +++ b/rpm_spec/core-dom0.spec @@ -80,6 +80,7 @@ ln -s block-snapshot $RPM_BUILD_ROOT/etc/xen/scripts/block-origin mkdir -p $RPM_BUILD_ROOT/etc/udev/rules.d cp ../misc/qubes_block.rules $RPM_BUILD_ROOT/etc/udev/rules.d/99-qubes_block.rules +cp ../misc/qubes_usb.rules $RPM_BUILD_ROOT/etc/udev/rules.d/99-qubes_usb.rules mkdir -p $RPM_BUILD_ROOT%{python_sitearch}/qubes cp qvm-core/qubes.py $RPM_BUILD_ROOT%{python_sitearch}/qubes @@ -117,6 +118,11 @@ cp qubes_rpc/qubes-receive-updates $RPM_BUILD_ROOT/usr/lib/qubes/ cp ../misc/block_add_change $RPM_BUILD_ROOT/usr/lib/qubes/ cp ../misc/block_remove $RPM_BUILD_ROOT/usr/lib/qubes/ cp ../misc/block_cleanup $RPM_BUILD_ROOT/usr/lib/qubes/ +cp ../misc/usb_add_change $RPM_BUILD_ROOT/usr/lib/qubes/ +cp ../misc/usb_remove $RPM_BUILD_ROOT/usr/lib/qubes/ +cp ../misc/vusb-ctl.py $RPM_BUILD_ROOT/usr/lib/qubes/ +cp ../misc/xl-qvm-usb-attach.py $RPM_BUILD_ROOT/usr/lib/qubes/ +cp ../misc/xl-qvm-usb-detach.py $RPM_BUILD_ROOT/usr/lib/qubes/ cp aux-tools/block_cleaner_daemon.py $RPM_BUILD_ROOT/usr/lib/qubes/ cp aux-tools/fix_dir_perms.sh $RPM_BUILD_ROOT/usr/lib/qubes/ @@ -367,6 +373,11 @@ fi /usr/lib/qubes/block_remove /usr/lib/qubes/block_cleanup /usr/lib/qubes/block_cleaner_daemon.py* +/usr/lib/qubes/usb_add_change +/usr/lib/qubes/usb_remove +/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 %attr(4750,root,qubes) /usr/lib/qubes/qfile-dom0-unpacker %attr(770,root,qubes) %dir /var/lib/qubes @@ -429,6 +440,7 @@ fi /etc/xdg/autostart/qubes-guid.desktop /etc/security/limits.d/99-qubes.conf /etc/udev/rules.d/99-qubes_block.rules +/etc/udev/rules.d/99-qubes_usb.rules /etc/cron.daily/qubes-dom0-updates.cron /etc/cron.d/qubes-sync-clock.cron /etc/dracut.conf.d/* diff --git a/rpm_spec/core-vm.spec b/rpm_spec/core-vm.spec index 7b202d37..202c4dba 100644 --- a/rpm_spec/core-vm.spec +++ b/rpm_spec/core-vm.spec @@ -113,9 +113,11 @@ install -D misc/xenstore-watch $RPM_BUILD_ROOT/usr/bin/xenstore-watch-qubes install -d $RPM_BUILD_ROOT/etc/udev/rules.d install -m 0644 misc/qubes_memory.rules $RPM_BUILD_ROOT/etc/udev/rules.d/50-qubes_memory.rules install -m 0644 misc/qubes_block.rules $RPM_BUILD_ROOT/etc/udev/rules.d/99-qubes_block.rules +install -m 0644 misc/qubes_usb.rules $RPM_BUILD_ROOT/etc/udev/rules.d/99-qubes_usb.rules install -d $RPM_BUILD_ROOT/usr/lib/qubes/ install misc/qubes_download_dom0_updates.sh $RPM_BUILD_ROOT/usr/lib/qubes/ install misc/{block_add_change,block_remove,block_cleanup} $RPM_BUILD_ROOT/usr/lib/qubes/ +install misc/{usb_add_change,usb_remove} $RPM_BUILD_ROOT/usr/lib/qubes/ install misc/qubes_trigger_sync_appmenus.sh $RPM_BUILD_ROOT/usr/lib/qubes/ install -D -m 0644 misc/qubes_trigger_sync_appmenus.action $RPM_BUILD_ROOT/etc/yum/post-actions/qubes_trigger_sync_appmenus.action mkdir -p $RPM_BUILD_ROOT/usr/lib/qubes @@ -312,6 +314,10 @@ do continue fi + if [ $(basename $f) == "99-qubes_usb.rules" ] ; then + continue + fi + if [ $(basename $f) == "90-hal.rules" ] ; then continue fi @@ -383,6 +389,7 @@ rm -rf $RPM_BUILD_ROOT /etc/udev/rules.d/50-qubes_memory.rules /etc/udev/rules.d/99-qubes_block.rules /etc/udev/rules.d/99-qubes_network.rules +/etc/udev/rules.d/99-qubes_usb.rules /etc/xen/scripts/vif-route-qubes /etc/yum.conf.d/qubes-proxy.conf /etc/yum.repos.d/qubes.repo @@ -399,6 +406,8 @@ rm -rf $RPM_BUILD_ROOT /usr/lib/qubes/block_add_change /usr/lib/qubes/block_cleanup /usr/lib/qubes/block_remove +/usr/lib/qubes/usb_add_change +/usr/lib/qubes/usb_remove /usr/lib/qubes/dispvm-prerun.sh /usr/lib/qubes/sync-ntp-clock /usr/lib/qubes/prepare-suspend