mirror of
https://github.com/ben-grande/qusal.git
synced 2025-02-14 06:01:24 -05:00
![Ben Grande](/assets/img/avatar_default.png)
- Add to qvm-run: - no-gui when command doesn't require a GUI - filter-escape-chars when pass-io is set and output is not a file, such as a pipe that could later be used to print information. - Change remaining echo to printf - Add end-of-options separator when possible
44 lines
1.4 KiB
Bash
Executable File
44 lines
1.4 KiB
Bash
Executable File
#!/bin/sh
|
|
|
|
# SPDX-FileCopyrightText: 2023 - 2025 Benjamin Grande M. S. <ben.grande.b@gmail.com>
|
|
#
|
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
## Credits: https://www.qubes-os.org/doc/how-to-use-pci-devices/#bringing-pci-devices-back-to-dom0
|
|
##
|
|
## After attaching a PCI device and detaching it, the device is not available
|
|
## in Dom0 anymore. This is an intended feature. A device which was previously
|
|
## assigned to a less trusted qube could attack dom0 if it were automatically
|
|
## reassigned there. In order to re-enable the device in dom0, either reboot
|
|
## physical machine or run the following script.
|
|
##
|
|
## This is useful for testing purposes when testing PCI devices, not
|
|
## recommended for users to attach a device to Dom0.
|
|
|
|
set -eu
|
|
|
|
usage(){
|
|
printf '%s\n' "Usage: ${0##*/} --i-like-danger <DEVICE>"
|
|
printf '%s\n' "Example: ${0##*/} --i-like-danger 0000:00:1b.0"
|
|
printf '%s\n' "Warning: Strongly discouraged to reattach PCI devices to"
|
|
printf '%s\n' "Warning: dom0, especially if it doesn't support resetting!"
|
|
exit 1
|
|
}
|
|
|
|
case "${1-}" in
|
|
--i-like-danger) ;;
|
|
*) usage;;
|
|
esac
|
|
case "${2-}" in
|
|
"") usage;;
|
|
*) device="${2}"
|
|
esac
|
|
|
|
uid="$(id -u)"
|
|
test "${uid}" = "0" || exec sudo "${0}"
|
|
|
|
printf '%s\n' "${device}" | tee -- /sys/bus/pci/drivers/pciback/unbind
|
|
modalias="$(cat -- "/sys/bus/pci/devices/${device}/modalias")"
|
|
module="$(modprobe -R "${modalias}" | head -n 1)"
|
|
printf '%s\n' "${device}" | tee -- "/sys/bus/pci/drivers/${module}/bind"
|