Skip to content

Commit

Permalink
Detach all devices before suspending
Browse files Browse the repository at this point in the history
Host controller drivers are detached on suspend, so all devices will be
detached anyway. Do it before any domain is actually suspended to avoid
deadlock.

Fixes QubesOS/qubes-issues#4657
  • Loading branch information
marmarek committed Oct 24, 2022
1 parent fa34c1f commit 0c7d8b7
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ install-vm:
install qubes-rpc/qubes.USB $(DESTDIR)/etc/qubes-rpc
install -d $(DESTDIR)/usr/lib/qubes
install src/usb-* $(DESTDIR)/usr/lib/qubes
install -d $(DESTDIR)/etc/qubes/suspend-pre.d
ln -s ../../../usr/lib/qubes/usb-detach-all \
$(DESTDIR)/etc/qubes/suspend-pre.d/usb-detach-all.sh

PYTHON2_SITELIB ?= $(shell python2 -c "from distutils.sysconfig import get_python_lib; print get_python_lib(0)")

Expand Down
3 changes: 2 additions & 1 deletion rpm_spec/qubes-usb-proxy.spec.in
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,13 @@ make install-vm DESTDIR=${RPM_BUILD_ROOT}

%files
#%%doc
/usr/lib/qubes/usb-import
/etc/qubes-rpc/qubes.USB
/etc/qubes-rpc/qubes.USBAttach
/etc/qubes-rpc/qubes.USBDetach
/etc/qubes/suspend-pre.d/usb-detach-all.sh
/usr/lib/qubes/usb-import
/usr/lib/qubes/usb-export
/usr/lib/qubes/usb-detach-all

%changelog
@CHANGELOG@
9 changes: 9 additions & 0 deletions src/usb-detach-all
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/sh

# Detach all devices before suspend

for dev in /sys/bus/usb/devices/*/usbip_sockfd; do
if [ -w "$dev" ]; then
echo -1 > "$dev"
fi
done

0 comments on commit 0c7d8b7

Please sign in to comment.