├── .gitignore ├── README.md ├── acpi-tables └── fake-battery.asl ├── default.conf ├── helper-iso-files ├── Autounattend.xml ├── RedHat.cer ├── mbpt-helper.bat └── scripts │ ├── chocolatey-install.ps1 │ ├── disable-mouse-acceleration.ps1 │ ├── gpu-check.ps1 │ ├── mbpt-startup.bat │ └── network-check.ps1 ├── live-iso-files ├── get-mbpt.sh └── mbpt.desktop ├── mbpt.sh ├── mock-data ├── 1-lshw.log ├── 1-lsiommu.log ├── 2-lshw ├── 2-lsiommu ├── 3-lshw ├── 3-lsiommu ├── 4-lshw ├── 4-lsiommu ├── 5-lshw ├── 5-lsiommu ├── 6-lshw ├── 6-lsiommu ├── 7-lshw ├── 7-lsiommu ├── 8-lshw └── 8-lsiommu ├── requirements.sh ├── screenshots └── example-output.png └── scripts ├── README.md ├── main ├── compatibility-check.sh ├── generate-helper-iso.sh ├── generate-live-iso.sh ├── generate-vm-config.sh ├── iommu-check.sh ├── setup.sh └── vm.sh └── utils ├── common ├── libs │ ├── cpu-check │ ├── gpu-check │ └── helpers ├── plugins │ ├── display-mode-1 │ ├── display-mode-2 │ ├── display-mode-3 │ ├── display-mode-4 │ └── display-mode-5 ├── setup │ ├── build-fake-battery-ssdt │ ├── extract-vbios │ ├── looking-glass-setup │ ├── ovmf-vbios-patch-setup │ └── vbios-finder-setup └── tools │ ├── commands-available │ ├── distro-info │ ├── download-windows-iso │ ├── driver-util │ ├── get-manager │ ├── get-missing-executables │ ├── get-missing-files │ ├── lsiommu │ ├── runtime-kernel-has-params │ └── vgpu-util ├── distro-specific └── Ubuntu │ ├── pre-package-info-update │ └── pre-package-install └── manager-specific ├── gui-terminal ├── gnome-terminal ├── konsole ├── st └── x-terminal-emulator ├── initramfs └── dracut ├── kernelparams └── grub ├── package ├── apt ├── dnf ├── emerge ├── pacman ├── yum └── zypper └── service ├── initctl ├── service └── systemd /.gitignore: -------------------------------------------------------------------------------- 1 | /logs 2 | /vm-files/vbios-roms 3 | /vm-files/vmshare 4 | /vm-files/*.fd 5 | /vm-files/*.iso 6 | /vm-files/*.img 7 | /vm-files/*.vfd 8 | /vm-files/*.aml 9 | /vm-files/patched-ovmf-files 10 | /vm-files/MAC_ADDRESS.txt 11 | /acpi-tables/*.aml 12 | /thirdparty 13 | /user.conf 14 | /helper-iso-files/bin 15 | /helper-iso-files/drivers 16 | /helper-iso-files/.checksum 17 | /live-iso-files/*.iso 18 | /live-iso-files/scripts/chocolatey-install.ps1 19 | /utils/nvflash_linux 20 | /tmp 21 | .*.swp 22 | .*.swo 23 | *.asc 24 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # MobilePassThrough 2 | 3 | ## Introduction 4 | The goal of this project is to make GPU passthrough on x64 notebooks/tablets as easy and accessible as possible. 5 | To achieve that goal I have written a collection of scripts [accessible via mbpt.sh](https://github.com/T-vK/MobilePassThrough#how-to-use-mbptsh) 6 | 7 | ### MBPT vs MBPT Live 8 | 9 | - You can either flash the MBPT Live ISO to a USB device and boot it to try it out without actually messing with your system. ([Download here](https://github.com/T-vK/MobilePassThrough/releases) or run `./mbpt.sh live build` to build it yourself.) 10 | - Or you can let `./mbpt.sh auto` set everything up on your exisitng Linux installation. 11 | 12 | Either way it is 100% automated, no user interaction required: 13 | 14 | ### On the host system (Linux): 15 | 16 | - [x] Automatically install the required dependencies 17 | - [x] Automatically configure the kernel parameters to support GPU passthrough 18 | - [ ] Automatically install Bumblebee and the Nvidia GPU driver if required (I removed this feature because it was too error-prone. Instead we'll just use nouveau or whatever is installed already.) 19 | - [x] Automatically check if and to what extend your device is compatible with GPU passthrough. 20 | - [x] Automatically create and configure a virtual machine that is fully configured for GPU passthrough. 21 | - [x] Automatically download the Windows 10 installation iso from Microsoft. 22 | - [x] Automatically compile/set up LookingGlass 23 | - [x] Automatically build an ACPI fake battery (to circumvent Nvidia's Error 43) 24 | - [x] Automatically patch OVMF with your vBIOS ROM (to circumvent Nvidia's Error 43) 25 | 26 | ### In the virtual machine (Windows) 27 | 28 | - [x] Automatically install the required drivers (ivshmem, other vfio drivers, Intel/Nvidia display drivers) 29 | - [x] Automatically compile/install/start LookingGlass 30 | - [x] Automatically configure the network 31 | - [x] Automatically set up RDP 32 | - [x] Automatically install and autostart LookingGlass 33 | 34 | And there is also a lot of advanced stuff that I managed to fully automate, like: 35 | 36 | - [x] Automatically rebinding the dGPU to the vfio drivers (when the VM starts) 37 | - [x] Automatically rebinding the dGPU to the nvidia/amd drivers (when the VM exits) 38 | - [x] Automatically creating a vGPU from the (Intel) iGPU (when the VM starts) to allow sharing the iGPU with the VM (aka "mediated iGPU passthough" using GVT-g) (So your VM can safe a ton of battery life when it doesn't need the dGPU.) 39 | 40 | ## Screenshot of the compatibility check (./mbpt.sh check) 41 | ![example output](screenshots/example-output.png) 42 | 43 | ## Currently supported distributions 44 | 45 | - Fedora 34 46 | - Ubuntu 21.04 (Currently not working. Some dependencies won't be installed automatically.) 47 | 48 | ## Limitations 49 | 50 | - The project is currently only really being tested on Fedora and Ubuntu (currently broken). But it has been written in a somewhat distribution-agnostic way, meaning it might just work on other distributions and if not, you might just have to add a new script to `scripts/utils/manager-specific/`. (For example the project currently supports the package managers `dnf` and `apt`, if your distro uses `pacman`, you have to add a pacman script that can be called the same way as the [apt script](scripts/utils/manager-specific/package/apt).) 51 | - This project currently only supports Windows 10 x64 VMs and hopefully Windows 11 x64 VMs at some point. (For older Windows versions you have to figure out the driver installation etc. on your own.) 52 | - Only tested for Intel+Nvidia and Intel+AMD systems. (Although the compatibility-check (./mbpt.sh check) should actually work on any hardware.) 53 | - Expect bugs. I have only tested this on a handful of devices and I have constantly changed the scripts without testing everything every time. 54 | - Automated vBIOS ROM extraction will fail in most cases. You might have to extract it from a BIOS update. (You may not need the vBIOS ROM though.) 55 | - This project takes a couple of measures to circumvent Nvidia's infamous Error 43, which you normally see in the Windows device manager when you pass a mobile Nvidia GPU through to a Windows VM. But even with these measures, some systems will still show Error 43. 56 | - Some AMD GPUs will give you an Error 43 as well (e.g. Radeon RX Vega M GL). I have no idea how to circumvent that one yet. 57 | 58 | ## Measures taken agains error 43 59 | 60 | - Hide that the VM is a VM 61 | - Change the vendor ID 62 | - Provide the VM with a fake battery 63 | - Provide the VM with the vBios ROMs 64 | - Patch OVMF, hardcoding your dGPU vBIOS ROM in it 65 | - Installing the latest Nvidia driver 66 | - (Another measure you can take yourself is installing a recent Nvidia driver in your VM. See [this](https://nvidia.custhelp.com/app/answers/detail/a_id/5173/~/geforce-gpu-passthrough-for-windows-virtual-machine-%28beta%29)) 67 | - Other projects that may help, but are very outdated and currently don't work: [NVIDIA-vBIOS-VFIO-Patcher](https://github.com/Matoking/NVIDIA-vBIOS-VFIO-Patcher), [nvidia-kvm-patcher](https://github.com/sk1080/nvidia-kvm-patcher). 68 | 69 | ## How to use? 70 | 71 | ### BIOS/UEFI configuration 72 | - Enable `Intel VT-x` / `AMD-V` as well as `Intel VT-d` / AMD's `IOMMU` in the BIOS / UEFI. 73 | - On some (gaming) notebooks the integrated graphics of the CPU are disabled. If that is the case for you, you need to enable them in the BIOS/UEFI. 74 | (Some vendors actually disable the CPU integrated GPU completely and don't offer UEFI options to enable it. Modding your BIOS could potentially fix that. See the "UEFI / BIOS modding" for more information on that.) 75 | - You might also have to disable secure boot in the UEFI. 76 | (Mainly to use Nvida's proprietary driver on Linux while your VM is not running.) 77 | - It might also be necessary to disable fastboot in the UEFI. 78 | - It is highly recommended to have your Linux installed/booted in UEFI mode (rather than in legacy mode). 79 | - If your drive doesn't show up during the installation in UEFI mode, make sure the SATA mode is set to AHCI in the UEFI, even if you don't use SATA. 80 | 81 | ### Installation and configuration 82 | - Open a terminal and install git and MobilePassThrough by typing the following, pressing enter after each line: 83 | ``` Bash 84 | sudo dnf install git -y # Install git 85 | git clone https://github.com/T-vK/MobilePassThrough.git # Clone the project 86 | cd MobilePassThrough # Enter the project directory 87 | ./mbpt.sh configure # Create a custom config file interactively (optional) 88 | ./mbpt.sh auto # Dependency installation; kernel param config; bumblebee / nvidia driver installation; windows ISO download; reboot to load new kernel params; create a helper iso with drivers and autounattended config for Windows; create and start VM; install Windows in the VM fully unattended; install drivers and looking glass in the VM automatically; check for error 43 automatically and show a warning if it occurs 89 | ``` 90 | - Once the installation finished you should be able to open Remmina and connect to `rdp://192.168.99.2` 91 | - Then in the second terminal run: 92 | ``` Bash 93 | cd MobilePassThrough # Enter the project directory 94 | cd ./thirdparty/LookingGlass/client/build/ # Enter the directoy containing the looking glass client executable 95 | ./looking-glass-client # Run the looking glass client 96 | ``` 97 | - From now on, start the VM with `./mbpt.sh start` 98 | 99 | ## How to use mbpt.sh 100 | 101 | ``` 102 | $ ./mbpt.sh help 103 | mbpt.sh COMMAND [ARG...] 104 | mbpt.sh [ -h | --help ] 105 | 106 | mbpt.sh is a wrapper script for a collection of tools that help with GPU passthrough on mobile devices like notebooks and convertibles. 107 | 108 | Options: 109 | -h, --help Print usage 110 | 111 | Commands: 112 | auto Automatically run check, setup and install 113 | configure Interactively guides you through the creation of your config file 114 | check Check if and to what degree your notebook is capable of running a GPU passthrough setup 115 | setup Install required dependencies and set required kernel parameters 116 | install Create and install the VM 117 | start Start the VM 118 | live Create / Flash a Live ISO image of this project 119 | vbios Dump the vBIOS ROM from the running system or extract it from a BIOS update 120 | 121 | Examples: 122 | # Install required dependencies and set required kernel parameters 123 | mbpt.sh setup 124 | 125 | # Check if and to what degree your notebook is capable of running a GPU passthrough setup 126 | mbpt.sh check 127 | 128 | # Interactively guides you through the creation of your config file 129 | mbpt.sh configure 130 | 131 | # Generate a helper iso file that contains required drivers and a helper-script for your Windows VM 132 | mbpt.sh iso 133 | 134 | # Create the VM and install Windows in it (Will overwrite an older instance if one exists!) 135 | mbpt.sh install 136 | 137 | # Start the VM 138 | mbpt.sh start 139 | 140 | # Create a Live ISO 141 | mbpt.sh live buid 142 | 143 | # Flash a Live ISO to the USB drive /dev/sdx 144 | mbpt.sh live flash /dev/sdx 145 | 146 | # Print the qemu command that would have been used to start the VM 147 | mbpt.sh start dry-run 148 | 149 | # Print the qemu command that would have been used to install the VM 150 | mbpt.sh install dry-run 151 | 152 | # Print the libvirt XML that would have been used to start the VM 153 | mbpt.sh start get-xml 154 | 155 | # Print the libvirt XML that would have been used to install the VM 156 | mbpt.sh install get-xml 157 | 158 | # Dump the vBIOS ROM of the GPU with the PCI address 01:00.0 to ./my-vbios.rom (This will most likely fail) 159 | mbpt.sh vbios dump 01:00.0 ./my-vbios.rom 160 | 161 | # Extract all the vBIOS ROMs of a given BIOS update to the directory ./my-roms 162 | mbpt.sh vbios extract /path/to/my-bios-update.exe ./my-roms 163 | ``` 164 | 165 | ## Hardware requirements to get GPU-passthrough to work on mobile 166 | 167 | - Device needs to be (mostly) compatible with Linux. 168 | Note: most Laptops should be these days 169 | 170 | - At least two GPUs (typically Intel's iGPU and an Nvidia GPU) 171 | Note: If you have Thunderbolt 3, you might be able to use an eGPU. See: https://egpu.io 172 | Note2: Theoretically it's possible to get this to work with only one GPU, but then you wouldn't be able to use your host system directly while running the VM, not to mention the like 50 other issues you'll run into. 173 | 174 | - CPU needs to support `Intel VT-x` / `AMD-V` 175 | Note: Unless your notebook is like 10 years old, the CPU should support this. 176 | Note2: If it supports `Intel VT-d` / AMD's `IOMMU` it should automatically also support `Intel VT-x` / `AMD-V`. 177 | - Chipset to support `Intel VT-x` / `AMD-V` 178 | Note: Unless your notebook is like 10 years old, it should support this. 179 | Note2: If it supports `Intel VT-d` / AMD's `IOMMU` it should automatically also support `Intel VT-x` / `AMD-V`. 180 | - BIOS/UEFI option to enable `Intel VT-x` / `AMD-V` must exist or it has to be enabled 181 | Note: Unless your notebook is like 10 years old, it should support this. 182 | Note2: If it supports `Intel VT-d` / AMD's `IOMMU` it should automatically also support `Intel VT-x` / `AMD-V`. 183 | Possible workaround: Modding your BIOS/UEFI using tools like UEFITool, AMIBCP etc. (See "UEFI / BIOS modding" below) 184 | 185 | - CPU needs to support `Intel VT-d` / AMD's `IOMMU` 186 | Note: If you have an Intel CPU, you can [check if it's in this list](https://ark.intel.com/Search/FeatureFilter?productType=processors&VTD=true&MarketSegment=Mobile). 187 | - Chipset to support `Intel VT-d` / AMD's `IOMMU` 188 | Note: If your CPU/chipset is from Intel, you search it in [this list](https://www.intel.com/content/www/us/en/products/chipsets/view-all.html) to check if it supports VT-d. 189 | - BIOS/UEFI needs to support `Intel VT-d` / AMD's `IOMMU` 190 | Possible workaround: Modding your BIOS/UEFI using tools like UEFITool, AMIBCP etc. (See "UEFI / BIOS modding" below) 191 | 192 | - When using an iGPU + dGPU setup, the iGPU needs to be enabled or the BIOS/UEFI needs to have an option to do so. 193 | Possible workaround: Modding your BIOS/UEFI using tools like UEFITool, AMIBCP etc. (See "UEFI / BIOS modding" below) 194 | 195 | - The GPU you want to pass through, has to be in an IOMMU group that doesn't have other devices in it that the host system needs. 196 | Possible workaround: You might be able to tear the groups further apart using the ACS override patch, but it's no magic cure, there are drawbacks. 197 | 198 | ## Potentially useful hardware tools 199 | 200 | [USB Programmer for BIOS/UEFI flashing or unbricking](https://www.aliexpress.com/item/4001045543107.html) 201 | EDID Dummy Plugs for [HDMI](https://www.aliexpress.com/item/-/32919567161.html) and [Mini DisplayPort](https://www.aliexpress.com/item/-/32822066472.html) can be used to make your dGPU write to the framebuffer so that you can use [Looking Glass](https://looking-glass.hostfission.com/). (Your dGPU needs to be connected to your external HDMI or Display Port for that to work though... [This may be possible with some UEFI/BIOS modding](https://github.com/jscinoz/optimus-vfio-docs/issues/2#issuecomment-471234538).) 202 | 203 | ## List of devices tested for GPU-passthrough compatibility 204 | 205 | Check out: https://gpu-passthrough.com/ 206 | 207 | ## UEFI / BIOS modding 208 | 209 | By modding your BIOS/UEFI, you can make features available and change settings that are hidden or non-existent by default. For example: show VT-d settings, show secure boot settings, show muxing related settings and much more. There is a good collection of modding tools on [this site here in the BIOS / UEFI tools section](https://forums.tweaktown.com/gigabyte/30530-overclocking-programs-system-info-benchmarking-stability-tools-post284763.html#post284763). 210 | There are many BIOS modding forums out there with lots of people who are more than willing to help even if you're a complete beginner. 211 | 212 | ## Credits 213 | 214 | Credits to [Wendell from Level1Techs](https:`//level1techs.com/) for his GPU passthrough guides/videos and [Misairu-G for his Optimus laptop dGPU passthrough guide](https://gist.github.com/Misairu-G/616f7b2756c488148b7309addc940b28). 215 | Without them I would have never even thought about creating this project. Thank you so much!! 216 | 217 | Credits to [korewaChino](https://github.com/T-vK/MobilePassThrough/pull/13) for adding support for Ubuntu! 218 | 219 | Credits to [Cole Robinson](https://blog.wikichoon.com/) for giving me a lot of incredibly valuable hard to find information on `virt-install`! 220 | 221 | ## TODO 222 | 223 | ### High prio 224 | - Fix for Ubuntu (Fix file dependency installation) 225 | - Document all the new features 226 | - Create a first Beta release 227 | - Test with an Nvidia notebook 228 | - Fix automatic Nvidia driver installation in the VM (fix chocolatey) 229 | - Fix RDP 230 | - Fix Samba sharing 231 | - Add virt-install version check because 2.2.1 doesn't seem to support the --xml flag 232 | - Get rid of the `--no-check-certificate` workaround for the win iso download 233 | - Install remix logo package inside of ISO 234 | - Disable autostart of install promt when booting Live ISO 235 | - Add pre-built Live ISO to the GitHub releases 236 | - Move to Fedora 35 237 | 238 | ### Low prio 239 | - Add nouveau driver compatibility 240 | - Allow the user to decide if he wants bumblebee or not (for Nvidia GPUs) 241 | - More detailed output about how the device is muxed 242 | - Test service auto reboot 243 | - Create packages (deb, rpm, etc) 244 | - Add compatibility for Arch, Debian, Pop OS etc... 245 | - Make this project work better on systems that already have a non-default GPU driver installed 246 | - Make it easy to uninstall the dependencies and undo the changes to the systm config (like kernel parameters) 247 | - Find a way to circumvent Error 43 for AMD GPUs like the `Radeon RX Vega M GL` 248 | - Reduce the size of the ovmf-vbios-patch Docker image or build it completely outside of docker 249 | - Make the USB passthrough device selection easier (i.e. display a list of devices that can be selected) 250 | - Look into hotplugging and check if the GPU can be hotplugged during VM runtime 251 | - Check if required dependencies are installed for each script 252 | - Add support for multiple VMs 253 | - Add support for Linux guests 254 | - Add support for Desktop PCs 255 | -------------------------------------------------------------------------------- /acpi-tables/fake-battery.asl: -------------------------------------------------------------------------------- 1 | DefinitionBlock ("", "SSDT", 1, "BOCHS", "BXPCSSDT", 0x00000001) 2 | { 3 | External (_SB_.PCI0, DeviceObj) 4 | 5 | Scope (_SB.PCI0) 6 | { 7 | Device (BAT0) 8 | { 9 | Name (_HID, EisaId ("PNP0C0A") /* Control Method Battery */) // _HID: Hardware ID 10 | Name (_UID, Zero) // _UID: Unique ID 11 | Method (_STA, 0, NotSerialized) // _STA: Status 12 | { 13 | Return (0x1F) 14 | } 15 | 16 | Method (_BIF, 0, NotSerialized) // _BIF: Battery Information 17 | { 18 | Return (Package (0x0D) 19 | { 20 | One, 21 | 0x1770, 22 | 0x1770, 23 | One, 24 | 0x39D0, 25 | 0x0258, 26 | 0x012C, 27 | 0x3C, 28 | 0x3C, 29 | "", 30 | "", 31 | "LION", 32 | "" 33 | }) 34 | } 35 | 36 | Method (_BST, 0, NotSerialized) // _BST: Battery Status 37 | { 38 | Return (Package (0x04) 39 | { 40 | Zero, 41 | Zero, 42 | 0x1770, 43 | 0x39D0 44 | }) 45 | } 46 | } 47 | } 48 | } -------------------------------------------------------------------------------- /default.conf: -------------------------------------------------------------------------------- 1 | # Predefined variables: PROJECT_DIR (contains the path to the MobilePassthrough project) 2 | 3 | # Variables that require a reinstall when changed (./mbpt.sh install) 4 | VM_NAME="MBPT_WindowsVM" # Can't be empty; no spaces allowed 5 | VM_FILES_DIR="${PROJECT_DIR}/vm-files" # The folder into which all files for your VM will be saved (Can't be an empty string) 6 | DRIVE_IMG="${VM_FILES_DIR}/${VM_NAME}.img" # The location of your VM disk (Can't be an empty string) 7 | VM_DISK_SIZE="40G" # Required once; changing this after the drive image has been created has no effect, unless you reinstall (E.g. "40G", "250G", ...); At least "40G" is highly recommended; "30G" will probably work, but Windows will break if you use it all 8 | INSTALL_IMG="${VM_FILES_DIR}/windows10.iso" # Path of Windows 10 ISO used during installation (Will be downloaded to that location if it doesn't exist; Can't be an empty string) 9 | 10 | # Variables that can be changed between VM starts (./mbpt.sh start) 11 | CPU_CORE_COUNT="auto" # "auto" is recommended (e.g. "8", "12" or "auto"); "auto" uses all, but one core, but no more than 16 12 | RAM_SIZE="auto" # "auto" is recommended (e.g. "8G", "10G" or "auto"); "auto" uses [all free RAM]-1GB, but no more than 16GB 13 | 14 | DGPU_PCI_ADDRESS="auto" # E.g. "01:00:0" or "auto", "auto" will use the fist dGPU it finds (if more than one, you will be asked which one to use; after 10 seconds it will timeout and use the fist one); see output of lspci 15 | IGPU_PCI_ADDRESS="auto" # Only Intel iGPUs supported atm; recommended to leave on "auto"; Use "" to disable or "auto" to automatically detect it (recommended); required for mediated iGPU passthrough. you can check your iGPU PCI address using lspci 16 | DGPU_PASSTHROUGH="auto" # "auto", "true" or "false" ("auto" Recommended) "auto" will enable it if the system has more than one GPU 17 | SHARE_IGPU="auto" # "auto", "true", or "false"; only works for Intel iGPUs atm; "auto" will enable it automatically if an Intel iGPU is detected; Recommended to save battery life (this is mediated iGPU passthrough using GVT-g) 18 | 19 | DGPU_ROM="" # Optional (Can help getting rid of error 43); Use "" to not load a vBIOS ROM or specify a path to one (e.g. "${VM_FILES_DIR}/vbios-roms/vbios.rom") 20 | IGPU_ROM="" # Optional (Can help getting rid of error 43); Use "" to not load a vBIOS ROM or specify a path to one (e.g. "${VM_FILES_DIR}/vbios-roms/igpu-vbios.rom") 21 | PATCH_OVMF_WITH_VROM="true" # "true" or "false"; Recommended to avoid Error 43; (Doesn't do anything, unless you specify a DGPU_ROM or IGPU_ROM) 22 | 23 | MAC_ADDRESS="auto" # Required (E.g. 00:11:22:33:44:55 or auto to generate a new one with every VM start) 24 | NETWORK_MODE="bridged" # Supports bridged or none 25 | SMB_SHARE_FOLDER="" # Optional; for example "${VM_FILES_DIR}/vmshare" or "" to not use it 26 | 27 | VIRTUAL_INPUT_TYPE="virtio" # "usb-tablet", "virtio" or "". If keyboard input doesn't work properly for you, you may want to use "virtio" instead of "usb-tablet" 28 | 29 | OVMF_CODE="/usr/share/OVMF/OVMF_CODE.fd" # Path to the unmodified OVMF_CODE image 30 | OVMF_VARS="/usr/share/OVMF/OVMF_VARS.fd" # Path to the unmodified OVMF_VARS image 31 | OVMF_VARS_VM="${VM_FILES_DIR}/OVMF_VARS_VM.fd" # Path to where a copy of the unmodified OVMF_VARS image will be created automatically 32 | 33 | HELPER_ISO="${VM_FILES_DIR}/mobile-passthrough-helper.iso" # Required for automated driver installation, looking glass setup, IP setup, remote desktop setup etc. inside of the VM 34 | 35 | LOOKING_GLASS_MAX_SCREEN_WIDTH="1920" # 1920 Recommended (bigger resolutions will result in a bigger buffer with worse performance) 36 | LOOKING_GLASS_MAX_SCREEN_HEIGHT="1080" # 1080 Recommended (bigger resolutions will result in a bigger buffer with worse performance) 37 | LOOKING_GLASS_VERSION="B4" # B4 Recommended 38 | 39 | DISPLAY_MODE="4" # ("4" is the only working one atm) Display mode to use (e.g. 1 or 2 ... see scripts/utils/common/plugins) 40 | 41 | USE_SPICE="true" # Recommended for Windows installation and required for Looking Glass and QXL 42 | SPICE_PORT="5904" # 5900 is the normal port, but it may already be used by something else on your system like VNC 43 | USE_SPICE_CLIENT="true" # Recommended for installation 44 | 45 | USE_FAKE_BATTERY="true" # Recommended to avoid Error 43 46 | 47 | VM_START_MODE="qemu" # "qemu" is recommended ("qemu" or "virt-install") 48 | 49 | # USB devices to pass through automatically while the VM is running. Separated by semicolons! 50 | # (See output of lsusb for vendorid/productid or hostbus/hostaddr) 51 | USB_DEVICES="" 52 | # example1: USB_DEVICES="hostbus=3,hostaddr=9" 53 | # example2: USB_DEVICES="vendorid=0x0b95,productid=0x1790" 54 | # example3: USB_DEVICES="vendorid=0x0b12,productid=0x9348;vendorid=0x0b95,productid=0x1790;hostbus=3,hostaddr=9" 55 | -------------------------------------------------------------------------------- /helper-iso-files/Autounattend.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | E:\bin\virtio-drivers\Win10\amd64 8 | 9 | 10 | 11 | 12 | 13 | en-GB 14 | 15 | en-GB 16 | en-GB 17 | en-GB 18 | en-GB 19 | en-GB 20 | 21 | 22 | 23 | 24 | 0 25 | true 26 | 27 | 28 | 1 29 | EFI 30 | 100 31 | 32 | 33 | 2 34 | MSR 35 | 4096 36 | 37 | 38 | 3 39 | Primary 40 | true 41 | 42 | 43 | 44 | 45 | 1 46 | 1 47 | 48 | FAT32 49 | 50 | 51 | 2 52 | 3 53 | 54 | C 55 | NTFS 56 | 57 | 58 | 59 | OnError 60 | 61 | 62 | 63 | OnError 64 | 65 | 66 | /IMAGE/NAME 67 | Windows 10 Pro 68 | 69 | 70 | 71 | 0 72 | 3 73 | 74 | 75 | 76 | 77 | true 78 | 79 | 80 | 81 | 82 | Never 83 | 84 | 85 | 86 | false 87 | Never 88 | 89 | false 90 | C:\Log 91 | 92 | 93 | 94 | 95 | false 96 | 97 | 98 | 99 | 100 | 1 101 | 102 | 103 | 129 | 130 | 131 | 132 | 133 | admin 134 | true</PlainText> 135 | </AdministratorPassword> 136 | </UserAccounts> 137 | <AutoLogon> 138 | <Password> 139 | <Value>admin</Value> 140 | <PlainText>true</PlainText> 141 | </Password> 142 | <Username>Administrator</Username> 143 | <LogonCount>99</LogonCount> 144 | <Enabled>true</Enabled> 145 | </AutoLogon> 146 | <OOBE> 147 | <HideEULAPage>true</HideEULAPage> 148 | <HideLocalAccountScreen>true</HideLocalAccountScreen> 149 | <HideOEMRegistrationScreen>true</HideOEMRegistrationScreen> 150 | <HideOnlineAccountScreens>true</HideOnlineAccountScreens> 151 | <HideWirelessSetupInOOBE>true</HideWirelessSetupInOOBE> 152 | <NetworkLocation>Work</NetworkLocation> 153 | <ProtectYourPC>3</ProtectYourPC> 154 | <SkipMachineOOBE>true</SkipMachineOOBE> 155 | <SkipUserOOBE>true</SkipUserOOBE> 156 | </OOBE> 157 | <TimeZone>UTC</TimeZone> 158 | <FirstLogonCommands> 159 | <SynchronousCommand wcm:action="add"> 160 | <CommandLine>cmd /q /c "FOR %i IN (A B C D E F G H I J K L N M O P Q R S T U V W X Y Z) DO IF EXIST %i:\mbpt-helper.bat cmd /c %i:\mbpt-helper.bat"</CommandLine> 161 | <Description>Install drivers, guest tools, looking glass, enable RDP, etc.</Description> 162 | <Order>1</Order> 163 | <RequiresUserInput>false</RequiresUserInput> 164 | </SynchronousCommand> 165 | </FirstLogonCommands> 166 | </component> 167 | </settings> 168 | <cpi:offlineImage cpi:source="" xmlns:cpi="urn:schemas-microsoft-com:cpi" /> 169 | </unattend> 170 | -------------------------------------------------------------------------------- /helper-iso-files/RedHat.cer: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/T-vK/MobilePassThrough/7102471fa5eb2be16126f02a7445091672c84376/helper-iso-files/RedHat.cer -------------------------------------------------------------------------------- /helper-iso-files/mbpt-helper.bat: -------------------------------------------------------------------------------- 1 | cd /D %~dp0 2 | 3 | echo "Set poweshell execution policy to unrestricted..." 4 | powershell -Command "Set-ExecutionPolicy Unrestricted 5 | 6 | echo "Disable password expiration for Administrator user..." 7 | wmic useraccount where "name='Administrator'" set PasswordExpires=FALSE 8 | 9 | echo "Installing required Visual C++ Redistributable Package..." 10 | .\bin\VC_redist.x64.exe /install /passive /norestart 11 | 12 | echo "Install vfio drivers..." 13 | certutil -addstore "TrustedPublisher" .\RedHat.cer 14 | %WINDIR%\system32\pnputil.exe /add-driver .\bin\virtio-drivers\Win10\amd64\*.inf /subdirs /install 15 | 16 | echo "Disable mouse acceleration..." 17 | powershell -executionpolicy unrestricted -file .\scripts\disable-mouse-acceleration.ps1 18 | 19 | echo "Install Spice guest tools..." 20 | .\bin\spice-guest-tools.exe /S 21 | 22 | echo "Install Spice WebDAV daemon..." 23 | .\bin\spice-webdavd.msi /passive /norestart 24 | 25 | echo "Install Looking Glass to Program Files ..." 26 | .\bin\looking-glass-host-setup.exe /S 27 | 28 | echo "Changing the virtual Ethernet adapter to a private one to allow RDP access..." 29 | for /F "skip=3 tokens=1,2,3* delims= " %%G in ('netsh interface show interface') DO ( 30 | echo "Setting %%J to private..." 31 | powershell -command Set-NetConnectionProfile -InterfaceAlias "Network" -NetworkCategory Private 32 | ) 33 | 34 | echo "Enable remote desktop..." 35 | reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Terminal Server" /v fDenyTSConnections /t REG_DWORD /d 0 /f 36 | netsh advfirewall firewall set rule group="remote desktop" new enable=Yes 37 | 38 | echo "Copy gpu-check script to startup..." 39 | md "%APPDATA%\mbpt" 40 | copy .\scripts\gpu-check.ps1 "%APPDATA%\mbpt" 41 | copy .\scripts\mbpt-startup.bat "%APPDATA%\Microsoft\Windows\Start Menu\Programs\Startup" 42 | 43 | echo "Wait until we're connected to the Internet..." 44 | powershell -executionpolicy unrestricted -file .\scripts\network-check.ps1 45 | 46 | echo "Install Chocolatey if possible..." 47 | powershell -executionpolicy unrestricted -file .\scripts\chocolatey-install.ps1 48 | 49 | echo "Run GPU check..." 50 | powershell -executionpolicy unrestricted -file .\scripts\gpu-check.ps1 unattended 51 | 52 | echo "Done! Shutting down the VM in 30 seconds..." 53 | 54 | shutdown -s 55 | 56 | pause 57 | 58 | ::echo "Set static IP for vfio network device..." 59 | :: TODO: Find the correct network adapter name 60 | ::netsh int ip set address "Ethernet" static 192.168.99.2 255.255.255.0 192.168.99.1 1 61 | ::netsh int ip set dns "Ethernet" static 192.168.99.1 primary 62 | :: netsh int ip set address "Local Area Connection" static 192.168.99.2 255.255.255.0 192.168.99.1 1 63 | :: netsh int ip set dns "Local Area Connection" static 192.168.99.1 primary 64 | 65 | ::echo "Waiting for 5 seconds..." 66 | ::timeout /t 5 /nobreak > nul -------------------------------------------------------------------------------- /helper-iso-files/scripts/disable-mouse-acceleration.ps1: -------------------------------------------------------------------------------- 1 | $code=@' 2 | [DllImport("user32.dll", EntryPoint = "SystemParametersInfo")] 3 | public static extern bool SystemParametersInfo(uint uiAction, uint uiParam, int[] pvParam, uint fWinIni); 4 | '@ 5 | Add-Type $code -name Win32 -NameSpace System 6 | 7 | [System.Win32]::SystemParametersInfo(4,0,0,2) -------------------------------------------------------------------------------- /helper-iso-files/scripts/gpu-check.ps1: -------------------------------------------------------------------------------- 1 | Add-Type -AssemblyName PresentationFramework 2 | 3 | #try { 4 | # choco 5 | #} 6 | #catch { 7 | # Remove-Item C:\ProgramData\chocolatey -Recurse 8 | # [System.Windows.MessageBox]::Show('Chocolatey installation failed! Make sure the VM has Internet access.', "MobilePassThrough - Error") 9 | #} 10 | 11 | #For formatting: 12 | $result = @{Expression = {$_.Name}; Label = "Device Name"}, 13 | @{Expression = {$_.ConfigManagerErrorCode} ; Label = "Status Code" }, 14 | @{Expression = {$_.DeviceID} ; Label = "ID" } 15 | 16 | $driverlessGpus = Get-WmiObject -Class Win32_PnpEntity -ComputerName localhost -Namespace Root\CIMV2 | Where-Object {$_.ConfigManagerErrorCode -gt 0 } | Format-Table $result -AutoSize | findstr -i "Video Controller" | findstr -i " 28 " 17 | 18 | if ($driverlessGpus -like '*VEN_8086*') { 19 | Write-Host 'Intel GPU driver missing' 20 | try { 21 | Write-Host 'Installing the Intel Graphics driver...' 22 | choco install intel-graphics-driver 23 | #Write-Host 'Automatic GPU driver installation not implemented yet. Please install the Intel Graphics driver manually!' 24 | #[System.Windows.MessageBox]::Show('Automatic GPU driver installation not implemented yet. Please install the Intel Graphics driver manually!', "MobilePassThrough - Missing GPU driver") 25 | } 26 | catch { 27 | #If ($Args -ne "unattended") { 28 | # [System.Windows.MessageBox]::Show('Failed to automatically install Intel Graphics driver using chocolatey!', "MobilePassThrough - driver installation failed") 29 | #} 30 | #Write-Host 'Failed to automatically install Intel Graphics driver using chocolatey!' 31 | } 32 | } 33 | if ($driverlessGpus -like '*VEN_10DE*') { 34 | Write-Host 'Nvidia GPU driver missing' 35 | try { 36 | Write-Host 'Installing the Nvidia Display driver...' 37 | choco install nvidia-display-driver 38 | #Write-Host 'Automatic GPU driver installation not implemented yet. Please install the Nvidia Display driver manually!' 39 | #[System.Windows.MessageBox]::Show('Automatic GPU driver installation not implemented yet. Please install the Nvidia Display driver manually!', "MobilePassThrough - Missing GPU driver") 40 | } 41 | catch { 42 | #If ($Args -ne "unattended") { 43 | # [System.Windows.MessageBox]::Show('Failed to automatically install Nvidia Display driver using chocolatey!', "MobilePassThrough - driver installation failed") 44 | #} 45 | } 46 | } 47 | if ($driverlessGpus -like '*VEN_1002*') { 48 | Write-Host 'AMD GPU driver missing' 49 | Write-Host 'Automatically installing AMD GPU drivers is not supported.' 50 | 51 | If ($Args -ne "unattended") { 52 | [System.Windows.MessageBox]::Show("Please install the AMD GPU driver! AMD and Chocolatey unfortunately don't offer a way to do this automatically!", "MobilePassThrough - GPU Driver is missing") 53 | } 54 | } 55 | 56 | $driverlessGpus = Get-WmiObject -Class Win32_PnpEntity -ComputerName localhost -Namespace Root\CIMV2 | Where-Object {$_.ConfigManagerErrorCode -gt 0 } | Format-Table $result -AutoSize | findstr -i "Video Controller" | findstr -i " 28 " 57 | if ($driverlessGpus -like '*VEN_8086*') { 58 | Write-Host 'Failed to automatically install Intel Graphics driver using chocolatey!' 59 | If ($Args -ne "unattended") { 60 | [System.Windows.MessageBox]::Show('Failed to automatically install Intel Graphics driver using chocolatey!', "MobilePassThrough - driver installation failed") 61 | } 62 | } 63 | if ($driverlessGpus -like '*VEN_10DE*') { 64 | Write-Host 'Failed to automatically install Nvidia Display driver using chocolatey!' 65 | If ($Args -ne "unattended") { 66 | [System.Windows.MessageBox]::Show('Failed to automatically install Nvidia Display driver using chocolatey!', "MobilePassThrough - driver installation failed") 67 | } 68 | } 69 | 70 | $error43Devices = Get-WmiObject -Class Win32_PnpEntity -ComputerName localhost -Namespace Root\CIMV2 | Where-Object {$_.ConfigManagerErrorCode -gt 0 } | Format-Table $result -AutoSize | findstr -i "Video Controller" | findstr -i " 43 " 71 | 72 | if ($error43Devices) { 73 | Write-Host 'Error 43 detected:' 74 | Write-Host $error43Devices 75 | If ($Args -ne "unattended") { 76 | [System.Windows.MessageBox]::Show($error43Devices, "MobilePassThrough - Detected Error 43") 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /helper-iso-files/scripts/mbpt-startup.bat: -------------------------------------------------------------------------------- 1 | powershell -executionpolicy unrestricted -file %APPDATA%\mbpt\gpu-check.ps1 -------------------------------------------------------------------------------- /helper-iso-files/scripts/network-check.ps1: -------------------------------------------------------------------------------- 1 | Add-Type -AssemblyName PresentationFramework 2 | 3 | function wait-for-network ($tries) { 4 | while (1) { 5 | # Get a list of DHCP-enabled interfaces that have a 6 | # non-$null DefaultIPGateway property. 7 | $x = gwmi -class Win32_NetworkAdapterConfiguration ` 8 | -filter DHCPEnabled=TRUE | 9 | where { $_.DefaultIPGateway -ne $null } 10 | 11 | # If there is (at least) one available, exit the loop. 12 | if ( ($x | measure).count -gt 0 ) { 13 | #[System.Windows.MessageBox]::Show("Network connection established!", "MobilePassThrough") 14 | Write-Host "Network connection established!" 15 | break 16 | } 17 | 18 | # If $tries > 0 and we have tried $tries times without 19 | # success, throw an exception. 20 | if ( $tries -gt 0 -and $try++ -ge $tries ) { 21 | Write-Host "Network unavaiable after $try tries." 22 | [System.Windows.MessageBox]::Show("Network unavaiable after $try tries.", "MobilePassThrough") 23 | throw "Network unavaiable after $try tries." 24 | } 25 | 26 | # Wait one second. 27 | start-sleep -s 1 28 | } 29 | } 30 | 31 | function wait-for-chocolatey ($tries) { 32 | while (1) { 33 | if ( $tries -gt 0 -and $try++ -ge $tries ) { 34 | Write-Host "chocolatey.org unavaiable after $try tries." 35 | [System.Windows.MessageBox]::Show("chocolatey.org unavaiable after $try tries.", "MobilePassThrough") 36 | throw "chocolatey.org unavaiable after $try tries." 37 | } 38 | if ((Test-Connection -Quiet chocolatey.org)) { 39 | Write-Host "chocolatey.org is reachable!" 40 | break 41 | } 42 | start-sleep -s 1 43 | } 44 | } 45 | 46 | Write-Host "Waiting for a network connection. Waiting up to 60 seconds..." 47 | wait-for-network 60 48 | 49 | Write-Host "Setting the Network to private..." 50 | Set-NetConnectionProfile -Name "Network" -NetworkCategory Private 51 | 52 | Write-Host "Waiting for chocoltey.org to be reachable. Waiting up to 30 seconds..." 53 | wait-for-chocolatey 30 -------------------------------------------------------------------------------- /live-iso-files/get-mbpt.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | echo "> Disabling sleep and force keeping the screen on..." 4 | sudo systemctl mask sleep.target suspend.target hibernate.target hybrid-sleep.target 5 | gsettings set org.gnome.desktop.session idle-delay 0 6 | 7 | printf "%s" "> Waiting for a device supporting big files with at least 60Gb of free storage to be mounted ..." 8 | REQUIRED_DISK_SPACE=60 #Gigabytes 9 | MBPT_BASE_PATH="" 10 | while sleep 1; do 11 | printf "%c" "." 12 | devices="$(sudo df --output=avail,target -B 1G 2> /dev/null | sed 's/^ *//')" 13 | while IFS= read -r deviceLine; do 14 | availableSpace=$(echo "$deviceLine" | cut -d' ' -f1) 15 | mountpoint="$(echo "$deviceLine" | cut -d' ' -f2-)" 16 | if [ -d "${mountpoint}/mbpt/MobilePassThrough" ]; then 17 | MBPT_BASE_PATH="$(echo "${mountpoint}/mbpt" | tr -s '/')" 18 | break 19 | elif [[ $availableSpace -ge $REQUIRED_DISK_SPACE ]]; then 20 | # Test if the device can handle big files (FAT32 for example can't) 21 | #if sudo fallocate -l "${REQUIRED_DISK_SPACE}G" "${mountpoint}/size_test.bin" &> /dev/null; then 22 | if sudo dd if=/dev/zero of="${mountpoint}/size_test.bin" bs="${REQUIRED_DISK_SPACE}G" seek=60 count=0 &> /dev/null; then 23 | sudo rm -f "${mountpoint}/_size_test.bin" 24 | MBPT_BASE_PATH="$(echo "${mountpoint}/mbpt" | tr -s '/')" 25 | break 26 | #else 27 | # echo "> Device mounted at '$mountpoint' doesn't support big files" 28 | fi 29 | fi 30 | done <<< "$devices" 31 | if [ "$MBPT_BASE_PATH" != "" ]; then 32 | break 33 | fi 34 | done 35 | printf "\n%s\n" "> Device found! Files will be stored under: $MBPT_BASE_PATH" 36 | sudo mkdir -p "$MBPT_BASE_PATH" 37 | sudo chown "$(logname):$(id -gn "$(logname)")" "$MBPT_BASE_PATH" 38 | cd "$MBPT_BASE_PATH" 39 | 40 | if [ ! -d "${MBPT_BASE_PATH}/MobilePassThrough" ]; then 41 | printf "%s" "> Waiting for an Internet connection ..." 42 | while ! timeout 5 ping -c 1 -n github.com &> /dev/null; do 43 | printf "%c" "." 44 | sleep 1 45 | done 46 | printf "\n%s\n" "> Connected!" 47 | 48 | requiredDomains="github.com mirrors.fedoraproject.org fedorapeople.org developer.nvidia.com tb.rg-adguard.net software-download.microsoft.com download.microsoft.com chocolatey.org" # www.techpowerup.com 49 | 50 | for domain in $requiredDomains; do 51 | printf "%s" "> Waiting for $domain to be available ..." 52 | while ! timeout 5 ping -c 1 -n $domain &> /dev/null; do 53 | printf "%c" "." 54 | sleep 1 55 | done 56 | printf "\n%s\n" "> $domain is available!" 57 | done 58 | 59 | if ! command -v git &> /dev/null; then 60 | echo "> Installing git..." 61 | sudo dnf install -y git 62 | fi 63 | 64 | echo "> Downloading the MobilePassThrough project..." 65 | git clone https://github.com/T-vK/MobilePassThrough.git 66 | else 67 | echo "[Skipped] MobilePassThrough appears to have been set up already in a previous boot." 68 | fi 69 | 70 | cd MobilePassThrough 71 | echo "> Running MobilePassThrough compatibility check..." 72 | ./mbpt.sh check 73 | if [ $? -eq 0 ]; then 74 | echo "> Waiting for 10 seconds before continuing..." 75 | sleep 10 76 | else 77 | echo "> Waiting for 30 seconds before continuing..." 78 | sleep 30 79 | fi 80 | echo "> Starting MobilePassThrough in auto mode..." 81 | ./mbpt.sh auto 82 | 83 | $SHELL -------------------------------------------------------------------------------- /live-iso-files/mbpt.desktop: -------------------------------------------------------------------------------- 1 | [Desktop Entry] 2 | Name=MobilePassThrough 3 | Exec=/usr/bin/gnome-terminal --maximize -- /home/liveuser/get-mbpt.sh 4 | Terminal=false 5 | Type=Application 6 | StartupNotify=true 7 | NoDisplay=true 8 | X-GNOME-Autostart-enabled=true -------------------------------------------------------------------------------- /mbpt.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | while [[ "$PROJECT_DIR" != */MobilePassThrough ]]; do PROJECT_DIR="$(readlink -f "$(dirname "${PROJECT_DIR:-0}")")"; done 3 | source "$PROJECT_DIR/scripts/utils/common/libs/helpers" 4 | 5 | ##################################################################################################### 6 | # This is the only script that you should really care about as a user of MobilePassThrough. 7 | # Usage: `./mbpt.sh --help` 8 | ##################################################################################################### 9 | 10 | COMMAND="$1" 11 | 12 | function printHelp() { 13 | echo 'mbpt.sh COMMAND [ARG...]' 14 | echo 'mbpt.sh [ -h | --help ]' 15 | echo '' 16 | echo 'mbpt.sh is a wrapper script for a collection of tools that help with GPU passthrough on mobile devices like notebooks and convertibles.' 17 | echo '' 18 | echo 'Options:' 19 | echo ' -h, --help Print usage' 20 | echo '' 21 | echo 'Commands:' 22 | echo ' auto Automatically run check, setup and install' 23 | echo ' configure Interactively guides you through the creation of your config file' 24 | echo ' check Check if and to what degree your notebook is capable of running a GPU passthrough setup' 25 | echo ' setup Install required dependencies and set required kernel parameters' 26 | echo ' install Create and install the VM' 27 | echo ' start Start the VM' 28 | echo ' live Create / Flash a Live ISO image of this project' 29 | # TODO: Split start/install in pre-start, start/install, post-start () 30 | # TODO implement: 31 | #echo ' get-xml Print out the VM configuration as XML' 32 | #echo ' get-qemu Print out the VM configuration as a qemu-system-x86_64 command' 33 | echo ' vbios Dump the vBIOS ROM from the running system or extract it from a BIOS update' 34 | echo '' 35 | echo 'Examples:' 36 | echo ' # Install required dependencies and set required kernel parameters' 37 | echo ' mbpt.sh setup' 38 | echo '' 39 | echo ' # Check if and to what degree your notebook is capable of running a GPU passthrough setup' 40 | echo ' mbpt.sh check' 41 | echo '' 42 | echo ' # Interactively guides you through the creation of your config file' 43 | echo ' mbpt.sh configure' 44 | echo '' 45 | echo ' # Generate a helper iso file that contains required drivers and a helper-script for your Windows VM' 46 | echo ' mbpt.sh iso' 47 | echo '' 48 | echo ' # Create the VM and install Windows in it (Will overwrite an older instance if one exists!)' 49 | echo ' mbpt.sh install' 50 | echo '' 51 | echo ' # Start the VM' 52 | echo ' mbpt.sh start' 53 | echo '' 54 | echo ' # Create a Live ISO' 55 | echo ' mbpt.sh live buid' 56 | echo '' 57 | echo ' # Flash a Live ISO to the USB drive /dev/sdx' 58 | echo ' mbpt.sh live flash /dev/sdx' 59 | echo '' 60 | echo ' # Print the qemu command that would have been used to start the VM' 61 | echo ' mbpt.sh start dry-run' 62 | echo '' 63 | echo ' # Print the qemu command that would have been used to install the VM' 64 | echo ' mbpt.sh install dry-run' 65 | echo '' 66 | echo ' # Print the libvirt XML that would have been used to start the VM' 67 | echo ' mbpt.sh start get-xml' 68 | echo '' 69 | echo ' # Print the libvirt XML that would have been used to install the VM' 70 | echo ' mbpt.sh install get-xml' 71 | echo '' 72 | echo ' # Dump the vBIOS ROM of the GPU with the PCI address 01:00.0 to ./my-vbios.rom (This will most likely fail)' 73 | echo ' mbpt.sh vbios dump 01:00.0 ./my-vbios.rom' 74 | echo '' 75 | echo ' # Extract all the vBIOS ROMs of a given BIOS update to the directory ./my-roms' 76 | echo ' mbpt.sh vbios extract /path/to/my-bios-update.exe ./my-roms' 77 | } 78 | 79 | 80 | if [ "$COMMAND" = "help" ] || [ "$COMMAND" = "--help" ] || [ "$COMMAND" = "-h" ] || [ "$COMMAND" = "" ]; then 81 | printHelp 82 | elif [ "$COMMAND" = "setup" ]; then 83 | sudo "${MAIN_SCRIPTS_DIR}/setup.sh" 84 | elif [ "$COMMAND" = "check" ]; then 85 | sudo "${MAIN_SCRIPTS_DIR}/compatibility-check.sh" 86 | elif [ "$COMMAND" = "configure" ]; then 87 | "${MAIN_SCRIPTS_DIR}/generate-vm-config.sh" 88 | elif [ "$COMMAND" = "helper-iso" ]; then 89 | "${MAIN_SCRIPTS_DIR}/generate-helper-iso.sh" 90 | elif [ "$COMMAND" = "install" ] || [ "$COMMAND" = "create" ]; then 91 | sudo "${MAIN_SCRIPTS_DIR}/vm.sh" install $2 92 | elif [ "$COMMAND" = "remove" ]; then 93 | sudo "${MAIN_SCRIPTS_DIR}/vm.sh" remove 94 | elif [ "$COMMAND" = "start" ]; then 95 | sudo "${MAIN_SCRIPTS_DIR}/vm.sh" start $2 96 | elif [ "$COMMAND" = "live" ]; then 97 | sudo "${MAIN_SCRIPTS_DIR}/generate-live-iso.sh" "$2" "$3" 98 | elif [ "$COMMAND" = "auto" ]; then 99 | #sudo "${MAIN_SCRIPTS_DIR}/compatibility-check.sh" 100 | sudo "${MAIN_SCRIPTS_DIR}/setup.sh" auto 101 | if [ $? -eq 0 ]; then 102 | sudo "${MAIN_SCRIPTS_DIR}/iommu-check.sh" 103 | if [ $? -eq 0 ]; then 104 | sudo "${MAIN_SCRIPTS_DIR}/vm.sh" auto 105 | else 106 | echo "Exiting..." 107 | exit 1 108 | fi 109 | else 110 | echo "Exiting..." 111 | exit 1 112 | fi 113 | elif [ "$COMMAND" = "vbios" ]; then 114 | if [ "$2" == "extract" ]; then 115 | mkdir -p "$4/" 116 | cd "${THIRDPARTY_DIR}/VBiosFinder" 117 | ./vbiosfinder extract "$(readlink -f "$3")" 118 | mv "${THIRDPARTY_DIR}/VBiosFinder/output/*" "$4/" 119 | elif [ "$2" == "dump" ]; then 120 | sudo "${COMMON_UTILS_SETUP_DIR}/extract-vbios" "$3" "$4" 121 | fi 122 | fi 123 | -------------------------------------------------------------------------------- /mock-data/1-lshw.log: -------------------------------------------------------------------------------- 1 | H/W path Device Class Description 2 | =============================================================== 3 | system GF72 8RE (179E.1) 4 | /0 bus MS-179E 5 | /0/1 memory 64KiB BIOS 6 | /0/3b memory 8GiB System Memory 7 | /0/3b/0 memory 8GiB SODIMM DDR4 Synchronous 2667 MHz (0.4 ns) 8 | /0/3b/1 memory [empty] 9 | /0/44 memory 384KiB L1 cache 10 | /0/45 memory 1536KiB L2 cache 11 | /0/46 memory 9MiB L3 cache 12 | /0/47 processor Intel(R) Core(TM) i7-8750H CPU @ 2.20GHz 13 | /0/100 bridge 8th Gen Core Processor Host Bridge/DRAM Registers 14 | /0/100/1 bridge Xeon E3-1200 v5/E3-1500 v5/6th Gen Core Processor PCIe Controller (x16) 15 | /0/100/1/0 display GP106M [GeForce GTX 1060 Mobile] 16 | /0/100/2 display UHD Graphics 630 (Mobile) 17 | /0/100/12 generic Cannon Lake PCH Thermal Controller 18 | /0/100/14 bus Cannon Lake PCH USB 3.1 xHCI Host Controller 19 | /0/100/14/0 usb1 bus xHCI Host Controller 20 | /0/100/14/0/7 input MSI EPF USB 21 | /0/100/14/0/c generic USB2.0-CRW 22 | /0/100/14/0/e communication Bluetooth wireless interface 23 | /0/100/14/1 usb2 bus xHCI Host Controller 24 | /0/100/14/1/3 scsi6 storage Ultra 25 | /0/100/14/1/3/0.0.0 /dev/sdb disk 123GB Ultra 26 | /0/100/14/1/3/0.0.0/0 /dev/sdb disk 123GB 27 | /0/100/14/1/3/0.0.0/0/1 /dev/sdb1 volume 249MiB Windows FAT volume 28 | /0/100/14/1/3/0.0.0/0/2 /dev/sdb2 volume 19GiB EXT4 volume 29 | /0/100/14/1/3/0.0.0/0/3 /dev/sdb3 volume 7059MiB Linux swap volume 30 | /0/100/14/1/3/0.0.0/0/4 /dev/sdb4 volume 87GiB EXT4 volume 31 | /0/100/14/1/4 scsi7 storage Flash Drive FIT 32 | /0/100/14/1/4/0.0.0 /dev/sdc disk 64GB Flash Drive FIT 33 | /0/100/14/1/4/0.0.0/0 /dev/sdc disk 64GB 34 | /0/100/14/1/4/0.0.0/0/1 volume 199MiB Windows FAT volume 35 | /0/100/14/1/4/0.0.0/0/2 /dev/sdc2 volume 1GiB EXT4 volume 36 | /0/100/14/1/4/0.0.0/0/3 /dev/sdc3 volume 58GiB LVM Physical Volume 37 | /0/100/14.2 memory RAM memory 38 | /0/100/14.3 wlo1 network Wireless-AC 9560 [Jefferson Peak] 39 | /0/100/16 communication Cannon Lake PCH HECI Controller 40 | /0/100/17 scsi4 storage Intel Corporation 41 | /0/100/17/0.0.0 /dev/sda disk 1TB WDC WD10SPZX-17Z 42 | /0/100/17/0.0.0/1 /dev/sda1 volume 349MiB Windows FAT volume 43 | /0/100/17/0.0.0/2 /dev/sda2 volume 921GiB Windows NTFS volume 44 | /0/100/17/0.0.0/3 /dev/sda3 volume 10239MiB Windows NTFS volume 45 | /0/100/1d bridge Cannon Lake PCH PCI Express Root Port #16 46 | /0/100/1d/0 enp2s0 network Killer E2400 Gigabit Ethernet Controller 47 | /0/100/1e communication Intel Corporation 48 | /0/100/1f bridge Intel Corporation 49 | /0/100/1f.3 multimedia Cannon Lake PCH cAVS 50 | /0/100/1f.4 bus Cannon Lake PCH SMBus Controller 51 | /0/100/1f.5 bus Cannon Lake PCH SPI Controller 52 | /0/0 system PnP device PNP0c02 53 | /0/2 system PnP device PNP0b00 54 | /0/3 generic PnP device INT3f0d 55 | /0/4 generic PnP device SYN1509 56 | /0/5 generic PnP device MSI0007 57 | /0/6 system PnP device PNP0c02 58 | /0/7 system PnP device PNP0c02 59 | /0/8 system PnP device PNP0c02 60 | /0/9 system PnP device PNP0c02 61 | /0/a system PnP device PNP0c02 62 | /1 power To Be Filled By O.E.M. 63 | /2 tap0 network Ethernet interface 64 | /3 virbr0 network Ethernet interface 65 | /4 virbr0-nic network Ethernet interface 66 | -------------------------------------------------------------------------------- /mock-data/1-lsiommu.log: -------------------------------------------------------------------------------- 1 | IOMMU Group 0 00:00.0 Host bridge [0600]: Intel Corporation 8th Gen Core Processor Host Bridge/DRAM Registers [8086:3ec4] (rev 07) 2 | IOMMU Group 10 02:00.0 Ethernet controller [0200]: Qualcomm Atheros Killer E2400 Gigabit Ethernet Controller [1969:e0a1] (rev 10) 3 | IOMMU Group 1 00:01.0 PCI bridge [0604]: Intel Corporation Xeon E3-1200 v5/E3-1500 v5/6th Gen Core Processor PCIe Controller (x16) [8086:1901] (rev 07) 4 | IOMMU Group 1 01:00.0 VGA compatible controller [0300]: NVIDIA Corporation GP106M [GeForce GTX 1060 Mobile] [10de:1c20] (rev a1) 5 | IOMMU Group 2 00:02.0 VGA compatible controller [0300]: Intel Corporation UHD Graphics 630 (Mobile) [8086:3e9b] 6 | IOMMU Group 3 00:12.0 Signal processing controller [1180]: Intel Corporation Cannon Lake PCH Thermal Controller [8086:a379] (rev 10) 7 | IOMMU Group 4 00:14.0 USB controller [0c03]: Intel Corporation Cannon Lake PCH USB 3.1 xHCI Host Controller [8086:a36d] (rev 10) 8 | IOMMU Group 4 00:14.2 RAM memory [0500]: Intel Corporation Cannon Lake PCH Shared SRAM [8086:a36f] (rev 10) 9 | IOMMU Group 4 00:14.3 Network controller [0280]: Intel Corporation Wireless-AC 9560 [Jefferson Peak] [8086:a370] (rev 10) 10 | IOMMU Group 5 00:16.0 Communication controller [0780]: Intel Corporation Cannon Lake PCH HECI Controller [8086:a360] (rev 10) 11 | IOMMU Group 6 00:17.0 SATA controller [0106]: Intel Corporation Device [8086:a353] (rev 10) 12 | IOMMU Group 7 00:1d.0 PCI bridge [0604]: Intel Corporation Cannon Lake PCH PCI Express Root Port #16 [8086:a337] (rev f0) 13 | IOMMU Group 8 00:1e.0 Communication controller [0780]: Intel Corporation Device [8086:a328] (rev 10) 14 | IOMMU Group 9 00:1f.0 ISA bridge [0601]: Intel Corporation Device [8086:a30d] (rev 10) 15 | IOMMU Group 9 00:1f.3 Audio device [0403]: Intel Corporation Cannon Lake PCH cAVS [8086:a348] (rev 10) 16 | IOMMU Group 9 00:1f.4 SMBus [0c05]: Intel Corporation Cannon Lake PCH SMBus Controller [8086:a323] (rev 10) 17 | IOMMU Group 9 00:1f.5 Serial bus controller [0c80]: Intel Corporation Cannon Lake PCH SPI Controller [8086:a324] (rev 10) 18 | -------------------------------------------------------------------------------- /mock-data/2-lshw: -------------------------------------------------------------------------------- 1 | Bus info Device Class Description 2 | ===================================================== 3 | pci@0000:23:00.0 display Oland PRO [Radeon R7 240/340] 4 | -------------------------------------------------------------------------------- /mock-data/2-lsiommu: -------------------------------------------------------------------------------- 1 | IOMMU Group 0 00:01.0 Host bridge [0600]: Advanced Micro Devices, Inc. [AMD] Family 17h (Models 00h-0fh) PCIe Dummy Host Bridge [1022:1452] 2 | IOMMU Group 10 00:14.0 SMBus [0c05]: Advanced Micro Devices, Inc. [AMD] FCH SMBus Controller [1022:790b] (rev 59) 3 | IOMMU Group 10 00:14.3 ISA bridge [0601]: Advanced Micro Devices, Inc. [AMD] FCH LPC Bridge [1022:790e] (rev 51) 4 | IOMMU Group 11 00:18.0 Host bridge [0600]: Advanced Micro Devices, Inc. [AMD] Family 17h (Models 00h-0fh) Data Fabric: Device 18h; Function 0 [1022:1460] 5 | IOMMU Group 11 00:18.1 Host bridge [0600]: Advanced Micro Devices, Inc. [AMD] Family 17h (Models 00h-0fh) Data Fabric: Device 18h; Function 1 [1022:1461] 6 | IOMMU Group 11 00:18.2 Host bridge [0600]: Advanced Micro Devices, Inc. [AMD] Family 17h (Models 00h-0fh) Data Fabric: Device 18h; Function 2 [1022:1462] 7 | IOMMU Group 11 00:18.3 Host bridge [0600]: Advanced Micro Devices, Inc. [AMD] Family 17h (Models 00h-0fh) Data Fabric: Device 18h; Function 3 [1022:1463] 8 | IOMMU Group 11 00:18.4 Host bridge [0600]: Advanced Micro Devices, Inc. [AMD] Family 17h (Models 00h-0fh) Data Fabric: Device 18h; Function 4 [1022:1464] 9 | IOMMU Group 11 00:18.5 Host bridge [0600]: Advanced Micro Devices, Inc. [AMD] Family 17h (Models 00h-0fh) Data Fabric: Device 18h; Function 5 [1022:1465] 10 | IOMMU Group 11 00:18.6 Host bridge [0600]: Advanced Micro Devices, Inc. [AMD] Family 17h (Models 00h-0fh) Data Fabric: Device 18h; Function 6 [1022:1466] 11 | IOMMU Group 11 00:18.7 Host bridge [0600]: Advanced Micro Devices, Inc. [AMD] Family 17h (Models 00h-0fh) Data Fabric: Device 18h; Function 7 [1022:1467] 12 | IOMMU Group 12 03:00.0 USB controller [0c03]: Advanced Micro Devices, Inc. [AMD] Device [1022:43b9] (rev 02) 13 | IOMMU Group 12 03:00.1 SATA controller [0106]: Advanced Micro Devices, Inc. [AMD] Device [1022:43b5] (rev 02) 14 | IOMMU Group 12 03:00.2 PCI bridge [0604]: Advanced Micro Devices, Inc. [AMD] Device [1022:43b0] (rev 02) 15 | IOMMU Group 12 04:00.0 PCI bridge [0604]: Advanced Micro Devices, Inc. [AMD] 300 Series Chipset PCIe Port [1022:43b4] (rev 02) 16 | IOMMU Group 12 04:01.0 PCI bridge [0604]: Advanced Micro Devices, Inc. [AMD] 300 Series Chipset PCIe Port [1022:43b4] (rev 02) 17 | IOMMU Group 12 04:02.0 PCI bridge [0604]: Advanced Micro Devices, Inc. [AMD] 300 Series Chipset PCIe Port [1022:43b4] (rev 02) 18 | IOMMU Group 12 04:03.0 PCI bridge [0604]: Advanced Micro Devices, Inc. [AMD] 300 Series Chipset PCIe Port [1022:43b4] (rev 02) 19 | IOMMU Group 12 04:04.0 PCI bridge [0604]: Advanced Micro Devices, Inc. [AMD] 300 Series Chipset PCIe Port [1022:43b4] (rev 02) 20 | IOMMU Group 12 04:08.0 PCI bridge [0604]: Advanced Micro Devices, Inc. [AMD] 300 Series Chipset PCIe Port [1022:43b4] (rev 02) 21 | IOMMU Group 12 1e:00.0 Ethernet controller [0200]: Realtek Semiconductor Co., Ltd. RTL8111/8168/8411 PCI Express Gigabit Ethernet Controller [10ec:8168] (rev 15) 22 | IOMMU Group 12 22:00.0 USB controller [0c03]: ASMedia Technology Inc. Device [1b21:2142] 23 | IOMMU Group 13 23:00.0 VGA compatible controller [0300]: Advanced Micro Devices, Inc. [AMD/ATI] Oland PRO [Radeon R7 240/340] [1002:6613] 24 | IOMMU Group 13 23:00.1 Audio device [0403]: Advanced Micro Devices, Inc. [AMD/ATI] Cape Verde/Pitcairn HDMI Audio [Radeon HD 7700/7800 Series] [1002:aab0] 25 | IOMMU Group 14 24:00.0 Non-Essential Instrumentation [1300]: Advanced Micro Devices, Inc. [AMD] Device [1022:145a] 26 | IOMMU Group 15 24:00.2 Encryption controller [1080]: Advanced Micro Devices, Inc. [AMD] Family 17h (Models 00h-0fh) Platform Security Processor [1022:1456] 27 | IOMMU Group 16 24:00.3 USB controller [0c03]: Advanced Micro Devices, Inc. [AMD] Family 17h (Models 00h-0fh) USB 3.0 Host Controller [1022:145c] 28 | IOMMU Group 17 25:00.0 Non-Essential Instrumentation [1300]: Advanced Micro Devices, Inc. [AMD] Device [1022:1455] 29 | IOMMU Group 18 25:00.2 SATA controller [0106]: Advanced Micro Devices, Inc. [AMD] FCH SATA Controller [AHCI mode] [1022:7901] (rev 51) 30 | IOMMU Group 19 25:00.3 Audio device [0403]: Advanced Micro Devices, Inc. [AMD] Family 17h (Models 00h-0fh) HD Audio Controller [1022:1457] 31 | IOMMU Group 1 00:01.3 PCI bridge [0604]: Advanced Micro Devices, Inc. [AMD] Family 17h (Models 00h-0fh) PCIe GPP Bridge [1022:1453] 32 | IOMMU Group 2 00:02.0 Host bridge [0600]: Advanced Micro Devices, Inc. [AMD] Family 17h (Models 00h-0fh) PCIe Dummy Host Bridge [1022:1452] 33 | IOMMU Group 3 00:03.0 Host bridge [0600]: Advanced Micro Devices, Inc. [AMD] Family 17h (Models 00h-0fh) PCIe Dummy Host Bridge [1022:1452] 34 | IOMMU Group 4 00:03.1 PCI bridge [0604]: Advanced Micro Devices, Inc. [AMD] Family 17h (Models 00h-0fh) PCIe GPP Bridge [1022:1453] 35 | IOMMU Group 5 00:04.0 Host bridge [0600]: Advanced Micro Devices, Inc. [AMD] Family 17h (Models 00h-0fh) PCIe Dummy Host Bridge [1022:1452] 36 | IOMMU Group 6 00:07.0 Host bridge [0600]: Advanced Micro Devices, Inc. [AMD] Family 17h (Models 00h-0fh) PCIe Dummy Host Bridge [1022:1452] 37 | IOMMU Group 7 00:07.1 PCI bridge [0604]: Advanced Micro Devices, Inc. [AMD] Family 17h (Models 00h-0fh) Internal PCIe GPP Bridge 0 to Bus B [1022:1454] 38 | IOMMU Group 8 00:08.0 Host bridge [0600]: Advanced Micro Devices, Inc. [AMD] Family 17h (Models 00h-0fh) PCIe Dummy Host Bridge [1022:1452] 39 | IOMMU Group 9 00:08.1 PCI bridge [0604]: Advanced Micro Devices, Inc. [AMD] Family 17h (Models 00h-0fh) Internal PCIe GPP Bridge 0 to Bus B [1022:1454] 40 | -------------------------------------------------------------------------------- /mock-data/3-lshw: -------------------------------------------------------------------------------- 1 | Bus info Device Class Description 2 | ===================================================== 3 | pci@0000:01:00.0 display Tahiti XT [Radeon HD 7970/8970 OEM / R9 280X] 4 | pci@0000:02:00.0 display Tahiti XT [Radeon HD 7970/8970 OEM / R9 280X] 5 | -------------------------------------------------------------------------------- /mock-data/3-lsiommu: -------------------------------------------------------------------------------- 1 | IOMMU Group 0 00:00.0 Host bridge [0600]: Intel Corporation 4th Gen Core Processor DRAM Controller [8086:0c00] (rev 06) 2 | IOMMU Group 10 00:1c.6 PCI bridge [0604]: Intel Corporation 9 Series Chipset Family PCI Express Root Port 7 [8086:8c9c] (rev d0) 3 | IOMMU Group 11 00:1c.7 PCI bridge [0604]: Intel Corporation 9 Series Chipset Family PCI Express Root Port 8 [8086:8c9e] (rev d0) 4 | IOMMU Group 12 00:1d.0 USB controller [0c03]: Intel Corporation 9 Series Chipset Family USB EHCI Controller #1 [8086:8ca6] 5 | IOMMU Group 13 00:1f.0 ISA bridge [0601]: Intel Corporation 9 Series Chipset Family Z97 LPC Controller [8086:8cc4] 6 | IOMMU Group 13 00:1f.2 SATA controller [0106]: Intel Corporation 9 Series Chipset Family SATA Controller [AHCI Mode] [8086:8c82] 7 | IOMMU Group 13 00:1f.3 SMBus [0c05]: Intel Corporation 9 Series Chipset Family SMBus Controller [8086:8ca2] 8 | IOMMU Group 14 04:00.0 Network controller [0280]: Qualcomm Atheros QCA6174 802.11ac Wireless Network Adapter [168c:003e] (rev 20) 9 | IOMMU Group 15 05:00.0 Ethernet controller [0200]: Qualcomm Atheros Killer E220x Gigabit Ethernet Controller [1969:e091] (rev 13) 10 | IOMMU Group 16 06:00.0 USB controller [0c03]: ASMedia Technology Inc. ASM1042A USB 3.0 Host Controller [1b21:1142] 11 | IOMMU Group 17 07:00.0 PCI bridge [0604]: ASMedia Technology Inc. Device [1b21:1184] 12 | IOMMU Group 18 08:01.0 PCI bridge [0604]: ASMedia Technology Inc. Device [1b21:1184] 13 | IOMMU Group 19 08:03.0 PCI bridge [0604]: ASMedia Technology Inc. Device [1b21:1184] 14 | IOMMU Group 1 00:01.0 PCI bridge [0604]: Intel Corporation Xeon E3-1200 v3/4th Gen Core Processor PCI Express x16 Controller [8086:0c01] (rev 06) 15 | IOMMU Group 1 00:01.2 PCI bridge [0604]: Intel Corporation Xeon E3-1200 v3/4th Gen Core Processor PCI Express x4 Controller [8086:0c09] (rev 06) 16 | IOMMU Group 1 01:00.0 VGA compatible controller [0300]: Advanced Micro Devices, Inc. [AMD/ATI] Tahiti XT [Radeon HD 7970/8970 OEM / R9 280X] [1002:6798] 17 | IOMMU Group 1 01:00.1 Audio device [0403]: Advanced Micro Devices, Inc. [AMD/ATI] Tahiti XT HDMI Audio [Radeon HD 7970 Series] [1002:aaa0] 18 | IOMMU Group 1 02:00.0 VGA compatible controller [0300]: Advanced Micro Devices, Inc. [AMD/ATI] Tahiti XT [Radeon HD 7970/8970 OEM / R9 280X] [1002:6798] 19 | IOMMU Group 1 02:00.1 Audio device [0403]: Advanced Micro Devices, Inc. [AMD/ATI] Tahiti XT HDMI Audio [Radeon HD 7970 Series] [1002:aaa0] 20 | IOMMU Group 20 08:05.0 PCI bridge [0604]: ASMedia Technology Inc. Device [1b21:1184] 21 | IOMMU Group 21 08:07.0 PCI bridge [0604]: ASMedia Technology Inc. Device [1b21:1184] 22 | IOMMU Group 21 0c:00.0 Ethernet controller [0200]: Intel Corporation 82574L Gigabit Network Connection [8086:10d3] 23 | IOMMU Group 22 0d:00.0 SATA controller [0106]: ASMedia Technology Inc. ASM1062 Serial ATA Controller [1b21:0612] (rev 01) 24 | IOMMU Group 2 00:14.0 USB controller [0c03]: Intel Corporation 9 Series Chipset Family USB xHCI Controller [8086:8cb1] 25 | IOMMU Group 3 00:16.0 Communication controller [0780]: Intel Corporation 9 Series Chipset Family ME Interface #1 [8086:8cba] 26 | IOMMU Group 4 00:1a.0 USB controller [0c03]: Intel Corporation 9 Series Chipset Family USB EHCI Controller #2 [8086:8cad] 27 | IOMMU Group 5 00:1b.0 Audio device [0403]: Intel Corporation 9 Series Chipset Family HD Audio Controller [8086:8ca0] 28 | IOMMU Group 6 00:1c.0 PCI bridge [0604]: Intel Corporation 9 Series Chipset Family PCI Express Root Port 1 [8086:8c90] (rev d0) 29 | IOMMU Group 7 00:1c.2 PCI bridge [0604]: Intel Corporation 9 Series Chipset Family PCI Express Root Port 3 [8086:8c94] (rev d0) 30 | IOMMU Group 8 00:1c.3 PCI bridge [0604]: Intel Corporation 9 Series Chipset Family PCI Express Root Port 4 [8086:8c96] (rev d0) 31 | IOMMU Group 9 00:1c.4 PCI bridge [0604]: Intel Corporation 9 Series Chipset Family PCI Express Root Port 5 [8086:8c98] (rev d0) 32 | -------------------------------------------------------------------------------- /mock-data/4-lshw: -------------------------------------------------------------------------------- 1 | Bus info Device Class Description 2 | ======================================================== 3 | pci@0000:01:00.0 display GM204 [GeForce GTX 970] 4 | pci@0000:00:02.0 display Xeon E3-1200 v3/4th Gen Core Processor Integrated Graphics Controller 5 | -------------------------------------------------------------------------------- /mock-data/4-lsiommu: -------------------------------------------------------------------------------- 1 | IOMMU Group 0 00:00.0 Host bridge [0600]: Intel Corporation 4th Gen Core Processor DRAM Controller [8086:0c00] (rev 06) 2 | IOMMU Group 10 00:1c.3 PCI bridge [0604]: Intel Corporation 82801 PCI Bridge [8086:244e] (rev d5) 3 | IOMMU Group 10 04:00.0 PCI bridge [0604]: Intel Corporation 82801 PCI Bridge [8086:244e] (rev 41) 4 | IOMMU Group 11 00:1d.0 USB controller [0c03]: Intel Corporation 8 Series/C220 Series Chipset Family USB EHCI #1 [8086:8c26] (rev 05) 5 | IOMMU Group 12 00:1f.0 ISA bridge [0601]: Intel Corporation B85 Express LPC Controller [8086:8c50] (rev 05) 6 | IOMMU Group 12 00:1f.2 SATA controller [0106]: Intel Corporation 8 Series/C220 Series Chipset Family 6-port SATA Controller 1 [AHCI mode] [8086:8c02] (rev 05) 7 | IOMMU Group 12 00:1f.3 SMBus [0c05]: Intel Corporation 8 Series/C220 Series Chipset Family SMBus Controller [8086:8c22] (rev 05) 8 | IOMMU Group 13 03:00.0 Ethernet controller [0200]: Realtek Semiconductor Co., Ltd. RTL8111/8168/8411 PCI Express Gigabit Ethernet Controller [10ec:8168] (rev 06) 9 | IOMMU Group 1 00:01.0 PCI bridge [0604]: Intel Corporation Xeon E3-1200 v3/4th Gen Core Processor PCI Express x16 Controller [8086:0c01] (rev 06) 10 | IOMMU Group 1 01:00.0 VGA compatible controller [0300]: NVIDIA Corporation GM204 [GeForce GTX 970] [10de:13c2] (rev a1) 11 | IOMMU Group 1 01:00.1 Audio device [0403]: NVIDIA Corporation GM204 High Definition Audio Controller [10de:0fbb] (rev a1) 12 | IOMMU Group 2 00:02.0 VGA compatible controller [0300]: Intel Corporation Xeon E3-1200 v3/4th Gen Core Processor Integrated Graphics Controller [8086:0412] (rev 06) 13 | IOMMU Group 3 00:03.0 Audio device [0403]: Intel Corporation Xeon E3-1200 v3/4th Gen Core Processor HD Audio Controller [8086:0c0c] (rev 06) 14 | IOMMU Group 4 00:14.0 USB controller [0c03]: Intel Corporation 8 Series/C220 Series Chipset Family USB xHCI [8086:8c31] (rev 05) 15 | IOMMU Group 5 00:16.0 Communication controller [0780]: Intel Corporation 8 Series/C220 Series Chipset Family MEI Controller #1 [8086:8c3a] (rev 04) 16 | IOMMU Group 6 00:1a.0 USB controller [0c03]: Intel Corporation 8 Series/C220 Series Chipset Family USB EHCI #2 [8086:8c2d] (rev 05) 17 | IOMMU Group 7 00:1b.0 Audio device [0403]: Intel Corporation 8 Series/C220 Series Chipset High Definition Audio Controller [8086:8c20] (rev 05) 18 | IOMMU Group 8 00:1c.0 PCI bridge [0604]: Intel Corporation 8 Series/C220 Series Chipset Family PCI Express Root Port #1 [8086:8c10] (rev d5) 19 | IOMMU Group 9 00:1c.2 PCI bridge [0604]: Intel Corporation 8 Series/C220 Series Chipset Family PCI Express Root Port #3 [8086:8c14] (rev d5) 20 | -------------------------------------------------------------------------------- /mock-data/5-lshw: -------------------------------------------------------------------------------- 1 | Bus info Device Class Description 2 | ======================================================== 3 | pci@0000:01:00.0 display GK107GLM [Quadro K2000M] 4 | pci@0000:00:02.0 display 3rd Gen Core processor Graphics Controller 5 | -------------------------------------------------------------------------------- /mock-data/5-lsiommu: -------------------------------------------------------------------------------- 1 | IOMMU Group 0 00:00.0 Host bridge [0600]: Intel Corporation 3rd Gen Core processor DRAM Controller [8086:0154] (rev 09) 2 | IOMMU Group 10 00:1c.2 PCI bridge [0604]: Intel Corporation 7 Series/C210 Series Chipset Family PCI Express Root Port 3 [8086:1e14] (rev c4) 3 | IOMMU Group 11 00:1d.0 USB controller [0c03]: Intel Corporation 7 Series/C216 Chipset Family USB Enhanced Host Controller #1 [8086:1e26] (rev 04) 4 | IOMMU Group 12 00:1f.0 ISA bridge [0601]: Intel Corporation QM77 Express Chipset LPC Controller [8086:1e55] (rev 04) 5 | IOMMU Group 12 00:1f.2 SATA controller [0106]: Intel Corporation 7 Series Chipset Family 6-port SATA Controller [AHCI mode] [8086:1e03] (rev 04) 6 | IOMMU Group 12 00:1f.3 SMBus [0c05]: Intel Corporation 7 Series/C216 Chipset Family SMBus Controller [8086:1e22] (rev 04) 7 | IOMMU Group 13 02:00.0 System peripheral [0880]: Ricoh Co Ltd MMC/SD Host Controller [1180:e822] (rev 08) 8 | IOMMU Group 13 02:00.3 FireWire (IEEE 1394) [0c00]: Ricoh Co Ltd R5C832 PCIe IEEE 1394 Controller [1180:e832] (rev 04) 9 | IOMMU Group 14 03:00.0 Network controller [0280]: Intel Corporation Centrino Advanced-N 6205 [Taylor Peak] [8086:0085] (rev 34) 10 | IOMMU Group 1 00:01.0 PCI bridge [0604]: Intel Corporation Xeon E3-1200 v2/3rd Gen Core processor PCI Express Root Port [8086:0151] (rev 09) 11 | IOMMU Group 1 01:00.0 VGA compatible controller [0300]: NVIDIA Corporation GK107GLM [Quadro K2000M] [10de:0ffb] (rev a1) 12 | IOMMU Group 2 00:02.0 VGA compatible controller [0300]: Intel Corporation 3rd Gen Core processor Graphics Controller [8086:0166] (rev 09) 13 | IOMMU Group 3 00:14.0 USB controller [0c03]: Intel Corporation 7 Series/C210 Series Chipset Family USB xHCI Host Controller [8086:1e31] (rev 04) 14 | IOMMU Group 4 00:16.0 Communication controller [0780]: Intel Corporation 7 Series/C216 Chipset Family MEI Controller #1 [8086:1e3a] (rev 04) 15 | IOMMU Group 5 00:19.0 Ethernet controller [0200]: Intel Corporation 82579LM Gigabit Network Connection [8086:1502] (rev 04) 16 | IOMMU Group 6 00:1a.0 USB controller [0c03]: Intel Corporation 7 Series/C216 Chipset Family USB Enhanced Host Controller #2 [8086:1e2d] (rev 04) 17 | IOMMU Group 7 00:1b.0 Audio device [0403]: Intel Corporation 7 Series/C216 Chipset Family High Definition Audio Controller [8086:1e20] (rev 04) 18 | IOMMU Group 8 00:1c.0 PCI bridge [0604]: Intel Corporation 7 Series/C216 Chipset Family PCI Express Root Port 1 [8086:1e10] (rev c4) 19 | IOMMU Group 9 00:1c.1 PCI bridge [0604]: Intel Corporation 7 Series/C210 Series Chipset Family PCI Express Root Port 2 [8086:1e12] (rev c4) 20 | -------------------------------------------------------------------------------- /mock-data/6-lshw: -------------------------------------------------------------------------------- 1 | Bus info Device Class Description 2 | ======================================================== 3 | pci@0000:00:02.0 display Intel Corporation Device 4 | pci@0000:01:00.0 display GK107GLM [Quadro K2000M] 5 | -------------------------------------------------------------------------------- /mock-data/6-lsiommu: -------------------------------------------------------------------------------- 1 | IOMMU Group 0 00:00.0 Host bridge [0600]: Intel Corporation Device [8086:5914] (rev 08) 2 | IOMMU Group 1 00:02.0 VGA compatible controller [0300]: Intel Corporation Device [8086:5917] (rev 07) 3 | IOMMU Group 2 00:04.0 Signal processing controller [1180]: Intel Corporation Xeon E3-1200 v5/E3-1500 v5/6th Gen Core Processor Thermal Subsystem [8086:1903] (rev 08) 4 | IOMMU Group 3 00:13.0 Non-VGA unclassified device [0000]: Intel Corporation Device [8086:9d35] (rev 21) 5 | IOMMU Group 4 00:14.0 USB controller [0c03]: Intel Corporation Sunrise Point-LP USB 3.0 xHCI Controller [8086:9d2f] (rev 21) 6 | IOMMU Group 4 00:14.2 Signal processing controller [1180]: Intel Corporation Sunrise Point-LP Thermal subsystem [8086:9d31] (rev 21) 7 | IOMMU Group 5 00:15.0 Signal processing controller [1180]: Intel Corporation Sunrise Point-LP Serial IO I2C Controller #0 [8086:9d60] (rev 21) 8 | IOMMU Group 6 00:16.0 Communication controller [0780]: Intel Corporation Sunrise Point-LP CSME HECI #1 [8086:9d3a] (rev 21) 9 | IOMMU Group 7 00:1c.0 PCI bridge [0604]: Intel Corporation Sunrise Point-LP PCI Express Root Port #1 [8086:9d10] (rev f1) 10 | IOMMU Group 7 00:1c.4 PCI bridge [0604]: Intel Corporation Sunrise Point-LP PCI Express Root Port #5 [8086:9d14] (rev f1) 11 | IOMMU Group 7 00:1c.6 PCI bridge [0604]: Intel Corporation Sunrise Point-LP PCI Express Root Port #7 [8086:9d16] (rev f1) 12 | IOMMU Group 7 00:1c.7 PCI bridge [0604]: Intel Corporation Sunrise Point-LP PCI Express Root Port #8 [8086:9d17] (rev f1) 13 | IOMMU Group 7 01:00.0 3D controller [0302]: NVIDIA Corporation GP108 [GeForce MX150] [10de:1d10] (rev a1) 14 | IOMMU Group 7 3b:00.0 Network controller [0280]: Intel Corporation Wireless 8265 / 8275 [8086:24fd] (rev 78) 15 | IOMMU Group 7 3c:00.0 Unassigned class [ff00]: Realtek Semiconductor Co., Ltd. RTS525A PCI Express Card Reader [10ec:525a] (rev 01) 16 | IOMMU Group 8 00:1d.0 PCI bridge [0604]: Intel Corporation Sunrise Point-LP PCI Express Root Port #9 [8086:9d18] (rev f1) 17 | IOMMU Group 8 3d:00.0 Non-Volatile memory controller [0108]: Samsung Electronics Co Ltd NVMe SSD Controller SM961/PM961 [144d:a804] 18 | IOMMU Group 9 00:1f.0 ISA bridge [0601]: Intel Corporation Device [8086:9d4e] (rev 21) 19 | IOMMU Group 9 00:1f.2 Memory controller [0580]: Intel Corporation Sunrise Point-LP PMC [8086:9d21] (rev 21) 20 | IOMMU Group 9 00:1f.3 Audio device [0403]: Intel Corporation Device [8086:9d71] (rev 21) 21 | IOMMU Group 9 00:1f.4 SMBus [0c05]: Intel Corporation Sunrise Point-LP SMBus [8086:9d23] (rev 21) 22 | -------------------------------------------------------------------------------- /mock-data/7-lshw: -------------------------------------------------------------------------------- 1 | Bus info Device Class Description 2 | ===================================================== 3 | pci@0000:23:00.0 display [GeForce GTX 1060 6GB] 4 | pci@0000:24:00.0 display GF110 [GeForce GTX 580] 5 | -------------------------------------------------------------------------------- /mock-data/7-lsiommu: -------------------------------------------------------------------------------- 1 | IOMMU Group 0 00:01.0 Host bridge [0600]: Advanced Micro Devices, Inc. [AMD] Device [1022:1452] 2 | IOMMU Group 0 00:01.1 PCI bridge [0604]: Advanced Micro Devices, Inc. [AMD] Device [1022:1453] 3 | IOMMU Group 0 00:01.3 PCI bridge [0604]: Advanced Micro Devices, Inc. [AMD] Device [1022:1453] 4 | IOMMU Group 0 01:00.0 Non-Volatile memory controller [0108]: Samsung Electronics Co Ltd NVMe SSD Controller SM961/PM961 [144d:a804] 5 | IOMMU Group 0 03:00.0 USB controller [0c03]: Advanced Micro Devices, Inc. [AMD] Device [1022:43b9] (rev 02) 6 | IOMMU Group 0 03:00.1 SATA controller [0106]: Advanced Micro Devices, Inc. [AMD] Device [1022:43b5] (rev 02) 7 | IOMMU Group 0 03:00.2 PCI bridge [0604]: Advanced Micro Devices, Inc. [AMD] Device [1022:43b0] (rev 02) 8 | IOMMU Group 0 04:00.0 PCI bridge [0604]: Advanced Micro Devices, Inc. [AMD] Device [1022:43b4] (rev 02) 9 | IOMMU Group 0 04:01.0 PCI bridge [0604]: Advanced Micro Devices, Inc. [AMD] Device [1022:43b4] (rev 02) 10 | IOMMU Group 0 04:02.0 PCI bridge [0604]: Advanced Micro Devices, Inc. [AMD] Device [1022:43b4] (rev 02) 11 | IOMMU Group 0 04:03.0 PCI bridge [0604]: Advanced Micro Devices, Inc. [AMD] Device [1022:43b4] (rev 02) 12 | IOMMU Group 0 04:04.0 PCI bridge [0604]: Advanced Micro Devices, Inc. [AMD] Device [1022:43b4] (rev 02) 13 | IOMMU Group 0 04:08.0 PCI bridge [0604]: Advanced Micro Devices, Inc. [AMD] Device [1022:43b4] (rev 02) 14 | IOMMU Group 0 1e:00.0 Ethernet controller [0200]: Realtek Semiconductor Co., Ltd. RTL8111/8168/8411 PCI Express Gigabit Ethernet Controller [10ec:8168] (rev 15) 15 | IOMMU Group 0 22:00.0 USB controller [0c03]: ASMedia Technology Inc. Device [1b21:2142] 16 | IOMMU Group 1 00:02.0 Host bridge [0600]: Advanced Micro Devices, Inc. [AMD] Device [1022:1452] 17 | IOMMU Group 2 00:03.0 Host bridge [0600]: Advanced Micro Devices, Inc. [AMD] Device [1022:1452] 18 | IOMMU Group 2 00:03.1 PCI bridge [0604]: Advanced Micro Devices, Inc. [AMD] Device [1022:1453] 19 | IOMMU Group 2 00:03.2 PCI bridge [0604]: Advanced Micro Devices, Inc. [AMD] Device [1022:1453] 20 | IOMMU Group 2 23:00.0 VGA compatible controller [0300]: NVIDIA Corporation GP106 [GeForce GTX 1060 6GB] [10de:1c03] (rev a1) 21 | IOMMU Group 2 23:00.1 Audio device [0403]: NVIDIA Corporation GP106 High Definition Audio Controller [10de:10f1] (rev a1) 22 | IOMMU Group 2 24:00.0 VGA compatible controller [0300]: NVIDIA Corporation GF110 [GeForce GTX 580] [10de:1080] (rev a1) 23 | IOMMU Group 2 24:00.1 Audio device [0403]: NVIDIA Corporation GF110 High Definition Audio Controller [10de:0e09] (rev a1) 24 | IOMMU Group 3 00:04.0 Host bridge [0600]: Advanced Micro Devices, Inc. [AMD] Device [1022:1452] 25 | IOMMU Group 4 00:07.0 Host bridge [0600]: Advanced Micro Devices, Inc. [AMD] Device [1022:1452] 26 | IOMMU Group 4 00:07.1 PCI bridge [0604]: Advanced Micro Devices, Inc. [AMD] Device [1022:1454] 27 | IOMMU Group 4 25:00.0 Non-Essential Instrumentation [1300]: Advanced Micro Devices, Inc. [AMD] Device [1022:145a] 28 | IOMMU Group 4 25:00.2 Encryption controller [1080]: Advanced Micro Devices, Inc. [AMD] Device [1022:1456] 29 | IOMMU Group 4 25:00.3 USB controller [0c03]: Advanced Micro Devices, Inc. [AMD] USB3 Host Controller [1022:145c] 30 | IOMMU Group 5 00:08.0 Host bridge [0600]: Advanced Micro Devices, Inc. [AMD] Device [1022:1452] 31 | IOMMU Group 5 00:08.1 PCI bridge [0604]: Advanced Micro Devices, Inc. [AMD] Device [1022:1454] 32 | IOMMU Group 5 26:00.0 Non-Essential Instrumentation [1300]: Advanced Micro Devices, Inc. [AMD] Device [1022:1455] 33 | IOMMU Group 5 26:00.2 SATA controller [0106]: Advanced Micro Devices, Inc. [AMD] FCH SATA Controller [AHCI mode] [1022:7901] (rev 51) 34 | IOMMU Group 5 26:00.3 Audio device [0403]: Advanced Micro Devices, Inc. [AMD] Device [1022:1457] 35 | IOMMU Group 6 00:14.0 SMBus [0c05]: Advanced Micro Devices, Inc. [AMD] FCH SMBus Controller [1022:790b] (rev 59) 36 | IOMMU Group 6 00:14.3 ISA bridge [0601]: Advanced Micro Devices, Inc. [AMD] FCH LPC Bridge [1022:790e] (rev 51) 37 | IOMMU Group 7 00:18.0 Host bridge [0600]: Advanced Micro Devices, Inc. [AMD] Device [1022:1460] 38 | IOMMU Group 7 00:18.1 Host bridge [0600]: Advanced Micro Devices, Inc. [AMD] Device [1022:1461] 39 | IOMMU Group 7 00:18.2 Host bridge [0600]: Advanced Micro Devices, Inc. [AMD] Device [1022:1462] 40 | IOMMU Group 7 00:18.3 Host bridge [0600]: Advanced Micro Devices, Inc. [AMD] Device [1022:1463] 41 | IOMMU Group 7 00:18.4 Host bridge [0600]: Advanced Micro Devices, Inc. [AMD] Device [1022:1464] 42 | IOMMU Group 7 00:18.5 Host bridge [0600]: Advanced Micro Devices, Inc. [AMD] Device [1022:1465] 43 | IOMMU Group 7 00:18.6 Host bridge [0600]: Advanced Micro Devices, Inc. [AMD] Device [1022:1466] 44 | IOMMU Group 7 00:18.7 Host bridge [0600]: Advanced Micro Devices, Inc. [AMD] Device [1022:1467] 45 | -------------------------------------------------------------------------------- /mock-data/8-lshw: -------------------------------------------------------------------------------- 1 | Bus info Device Class Description 2 | ===================================================== 3 | pci@0000:26:00.0 display Ellesmere [Radeon RX 470/480/570/570X/580/580X] 4 | pci@0000:27:00.0 display Ellesmere [Radeon RX 470/480/570/570X/580/580X] 5 | -------------------------------------------------------------------------------- /mock-data/8-lsiommu: -------------------------------------------------------------------------------- 1 | IOMMU Group 0 00:01.0 Host bridge [0600]: Advanced Micro Devices, Inc. [AMD] Family 17h (Models 00h-0fh) PCIe Dummy Host Bridge [1022:1452] 2 | IOMMU Group 10 00:08.0 Host bridge [0600]: Advanced Micro Devices, Inc. [AMD] Family 17h (Models 00h-0fh) PCIe Dummy Host Bridge [1022:1452] 3 | IOMMU Group 11 00:08.1 PCI bridge [0604]: Advanced Micro Devices, Inc. [AMD] Family 17h (Models 00h-0fh) Internal PCIe GPP Bridge 0 to Bus B [1022:1454] 4 | IOMMU Group 12 00:14.0 SMBus [0c05]: Advanced Micro Devices, Inc. [AMD] FCH SMBus Controller [1022:790b] (rev 59) 5 | IOMMU Group 12 00:14.3 ISA bridge [0601]: Advanced Micro Devices, Inc. [AMD] FCH LPC Bridge [1022:790e] (rev 51) 6 | IOMMU Group 13 00:18.0 Host bridge [0600]: Advanced Micro Devices, Inc. [AMD] Family 17h (Models 00h-0fh) Data Fabric: Device 18h; Function 0 [1022:1460] 7 | IOMMU Group 13 00:18.1 Host bridge [0600]: Advanced Micro Devices, Inc. [AMD] Family 17h (Models 00h-0fh) Data Fabric: Device 18h; Function 1 [1022:1461] 8 | IOMMU Group 13 00:18.2 Host bridge [0600]: Advanced Micro Devices, Inc. [AMD] Family 17h (Models 00h-0fh) Data Fabric: Device 18h; Function 2 [1022:1462] 9 | IOMMU Group 13 00:18.3 Host bridge [0600]: Advanced Micro Devices, Inc. [AMD] Family 17h (Models 00h-0fh) Data Fabric: Device 18h; Function 3 [1022:1463] 10 | IOMMU Group 13 00:18.4 Host bridge [0600]: Advanced Micro Devices, Inc. [AMD] Family 17h (Models 00h-0fh) Data Fabric: Device 18h; Function 4 [1022:1464] 11 | IOMMU Group 13 00:18.5 Host bridge [0600]: Advanced Micro Devices, Inc. [AMD] Family 17h (Models 00h-0fh) Data Fabric: Device 18h; Function 5 [1022:1465] 12 | IOMMU Group 13 00:18.6 Host bridge [0600]: Advanced Micro Devices, Inc. [AMD] Family 17h (Models 00h-0fh) Data Fabric: Device 18h; Function 6 [1022:1466] 13 | IOMMU Group 13 00:18.7 Host bridge [0600]: Advanced Micro Devices, Inc. [AMD] Family 17h (Models 00h-0fh) Data Fabric: Device 18h; Function 7 [1022:1467] 14 | IOMMU Group 14 01:00.0 Non-Volatile memory controller [0108]: Samsung Electronics Co Ltd NVMe SSD Controller SM961/PM961 [144d:a804] 15 | IOMMU Group 15 03:00.0 USB controller [0c03]: Advanced Micro Devices, Inc. [AMD] Device [1022:43b9] (rev 02) 16 | IOMMU Group 15 03:00.1 SATA controller [0106]: Advanced Micro Devices, Inc. [AMD] Device [1022:43b5] (rev 02) 17 | IOMMU Group 15 03:00.2 PCI bridge [0604]: Advanced Micro Devices, Inc. [AMD] Device [1022:43b0] (rev 02) 18 | IOMMU Group 15 1d:00.0 PCI bridge [0604]: Advanced Micro Devices, Inc. [AMD] 300 Series Chipset PCIe Port [1022:43b4] (rev 02) 19 | IOMMU Group 15 1d:01.0 PCI bridge [0604]: Advanced Micro Devices, Inc. [AMD] 300 Series Chipset PCIe Port [1022:43b4] (rev 02) 20 | IOMMU Group 15 1d:02.0 PCI bridge [0604]: Advanced Micro Devices, Inc. [AMD] 300 Series Chipset PCIe Port [1022:43b4] (rev 02) 21 | IOMMU Group 15 1d:03.0 PCI bridge [0604]: Advanced Micro Devices, Inc. [AMD] 300 Series Chipset PCIe Port [1022:43b4] (rev 02) 22 | IOMMU Group 15 1d:04.0 PCI bridge [0604]: Advanced Micro Devices, Inc. [AMD] 300 Series Chipset PCIe Port [1022:43b4] (rev 02) 23 | IOMMU Group 15 1d:06.0 PCI bridge [0604]: Advanced Micro Devices, Inc. [AMD] 300 Series Chipset PCIe Port [1022:43b4] (rev 02) 24 | IOMMU Group 15 1d:07.0 PCI bridge [0604]: Advanced Micro Devices, Inc. [AMD] 300 Series Chipset PCIe Port [1022:43b4] (rev 02) 25 | IOMMU Group 15 1f:00.0 Ethernet controller [0200]: Intel Corporation I211 Gigabit Network Connection [8086:1539] (rev 03) 26 | IOMMU Group 16 26:00.0 VGA compatible controller [0300]: Advanced Micro Devices, Inc. [AMD/ATI] Ellesmere [Radeon RX 470/480/570/570X/580/580X] [1002:67df] (rev e7) 27 | IOMMU Group 16 26:00.1 Audio device [0403]: Advanced Micro Devices, Inc. [AMD/ATI] Ellesmere [Radeon RX 580] [1002:aaf0] 28 | IOMMU Group 17 27:00.0 VGA compatible controller [0300]: Advanced Micro Devices, Inc. [AMD/ATI] Ellesmere [Radeon RX 470/480/570/570X/580/580X] [1002:67df] (rev e7) 29 | IOMMU Group 17 27:00.1 Audio device [0403]: Advanced Micro Devices, Inc. [AMD/ATI] Ellesmere [Radeon RX 580] [1002:aaf0] 30 | IOMMU Group 18 28:00.0 Non-Essential Instrumentation [1300]: Advanced Micro Devices, Inc. [AMD] Device [1022:145a] 31 | IOMMU Group 19 28:00.2 Encryption controller [1080]: Advanced Micro Devices, Inc. [AMD] Family 17h (Models 00h-0fh) Platform Security Processor [1022:1456] 32 | IOMMU Group 1 00:01.1 PCI bridge [0604]: Advanced Micro Devices, Inc. [AMD] Family 17h (Models 00h-0fh) PCIe GPP Bridge [1022:1453] 33 | IOMMU Group 20 28:00.3 USB controller [0c03]: Advanced Micro Devices, Inc. [AMD] Family 17h (Models 00h-0fh) USB 3.0 Host Controller [1022:145c] 34 | IOMMU Group 21 29:00.0 Non-Essential Instrumentation [1300]: Advanced Micro Devices, Inc. [AMD] Device [1022:1455] 35 | IOMMU Group 22 29:00.2 SATA controller [0106]: Advanced Micro Devices, Inc. [AMD] FCH SATA Controller [AHCI mode] [1022:7901] (rev 51) 36 | IOMMU Group 23 29:00.3 Audio device [0403]: Advanced Micro Devices, Inc. [AMD] Family 17h (Models 00h-0fh) HD Audio Controller [1022:1457] 37 | IOMMU Group 2 00:01.3 PCI bridge [0604]: Advanced Micro Devices, Inc. [AMD] Family 17h (Models 00h-0fh) PCIe GPP Bridge [1022:1453] 38 | IOMMU Group 3 00:02.0 Host bridge [0600]: Advanced Micro Devices, Inc. [AMD] Family 17h (Models 00h-0fh) PCIe Dummy Host Bridge [1022:1452] 39 | IOMMU Group 4 00:03.0 Host bridge [0600]: Advanced Micro Devices, Inc. [AMD] Family 17h (Models 00h-0fh) PCIe Dummy Host Bridge [1022:1452] 40 | IOMMU Group 5 00:03.1 PCI bridge [0604]: Advanced Micro Devices, Inc. [AMD] Family 17h (Models 00h-0fh) PCIe GPP Bridge [1022:1453] 41 | IOMMU Group 6 00:03.2 PCI bridge [0604]: Advanced Micro Devices, Inc. [AMD] Family 17h (Models 00h-0fh) PCIe GPP Bridge [1022:1453] 42 | IOMMU Group 7 00:04.0 Host bridge [0600]: Advanced Micro Devices, Inc. [AMD] Family 17h (Models 00h-0fh) PCIe Dummy Host Bridge [1022:1452] 43 | IOMMU Group 8 00:07.0 Host bridge [0600]: Advanced Micro Devices, Inc. [AMD] Family 17h (Models 00h-0fh) PCIe Dummy Host Bridge [1022:1452] 44 | IOMMU Group 9 00:07.1 PCI bridge [0604]: Advanced Micro Devices, Inc. [AMD] Family 17h (Models 00h-0fh) Internal PCIe GPP Bridge 0 to Bus B [1022:1454] 45 | -------------------------------------------------------------------------------- /requirements.sh: -------------------------------------------------------------------------------- 1 | ##################################################################################################### 2 | # This file is supposed to be `source`d by the `scripts/main/setup.sh` bash script. 3 | # It specifies which executables and files and kernel parameters which part of this project depends on 4 | # WARNING: File dependencies can't contain spaces at the moment 5 | # Usage: `source ./requirements.sh` 6 | ##################################################################################################### 7 | 8 | # TODO: #sudo dnf install -y msr-tools tunctl # TODO: check if these are still needed and if so what for 9 | 10 | # TODO: check if there even is a case where is would be necessary 11 | #INITRAMFS_DRIVERS=("vfio_virqfd" "vfio_pci" "vfio_iommu_type1" "addInitramfsDriver" "vfio") #vfio stub drivers 12 | 13 | # Docs: https://www.kernel.org/doc/Documentation/admin-guide/kernel-parameters.txt 14 | # More docs: https://lwn.net/Articles/252826/ 15 | # https://www.kernel.org/doc/Documentation/x86/x86_64/boot-options.txt 16 | KERNEL_PARAMS_GENERAL=("iommu=1") # '1' is not a documented option. stop confusing me wendell! Maybe the "force" option should be used instead? 17 | KERNEL_PARAMS_GENERAL+=("kvm.ignore_msrs=1") # prevent bluescreens when a VM does MSR reads / writes directly 18 | KERNEL_PARAMS_GENERAL+=("rd.driver.pre=vfio-pci") # tell dracut to load vfio-pci first 19 | #KERNEL_PARAMS_GENERAL+=("pcie_acs_override=downstream") # fix /dev/vfio/1 not found error # shouldn't be necessary 20 | #KERNEL_PARAMS_GENERAL+=("acpi_osi=!") # may fix problems with AMI style UEFIs 21 | #KERNEL_PARAMS_GENERAL+=("acpi_osi='Windows 2009'") # may fix problems with AMI style UEFIs 22 | KERNEL_PARAMS_INTEL_CPU=("intel_iommu=on") # enable Intel VT-D ;# using "intel_iommu=on,igfx_off" iGPU gets no iommu group... 23 | #KERNEL_PARAMS_INTEL_CPU+=("915.preliminary_hw_support=1") # add skylake support; probably only necessary with older kernels 24 | KERNEL_PARAMS_AMD_CPU=("amd_iommu=on") # 'on' is not a docuemnted option for this parameter either! This is insanely confusing! 25 | KERNEL_PARAMS_INTEL_GPU=("i915.enable_gvt=1") # enable mediated iGPU passthrough support (GVT-g) on Intel iGPUs 26 | #KERNEL_PARAMS_AMD_GPU=() 27 | #KERNEL_PARAMS_NVIDIA_GPU=() 28 | #KERNEL_PARAMS_BUMBLEBEE_NVIDIA=("nouveau.modeset=0") 29 | 30 | 31 | # TODO: check if we should use relative paths to be more distribution-gnostic 32 | #EXEC_DEPS_GENERAL=("sudo" "bash" "mv" "cp" "sed" "awk" "git" "echo" "ls" "echo" "printf" "cd" "mkdir" "chmod" "chown" "grep" "cut" "which") 33 | EXEC_DEPS_FAKE_BATTERY=("iasl") # acpica-tools 34 | EXEC_DEPS_OVMF_VBIOS_PATCH=("git" "docker") # git moby-engine 35 | EXEC_DEPS_GENERATE_CONFIG=("crudini") # crudini 36 | EXEC_DEPS_VBIOS_FINDER=("git" "wget" "curl" "unzip" "ruby" "gem" "bundle" "7za" "make" "innoextract" "upx") # git wget curl-minimal unzip ruby rubygems rubygem-bundler p7zip make innoextract upx 37 | FILE_DEPS_VBIOS_FINDER=("/usr/include/rub*/ruby.h") # ruby-devel 38 | EXEC_DEPS_VIRTUALIZATION=("qemu-system-x86_64" "virsh" "virt-viewer" "virt-install" "spicy" "socat" "fdisk" "dd" "nmap" "driverctl" ) # qemu-system-x86-core libvirt-client virt-viewer virt-install spice-gtk-tools socat coreutils util-linux nmap driverctl 39 | FILE_DEPS_VIRTUALIZATION=("/usr/share/OVMF/OVMF_CODE.fd" "/usr/share/OVMF/OVMF_VARS.fd" "/usr/share/libvirt/networks/default.xml") # edk2-ovmf libvirt-daemon-config-network 40 | EXEC_DEPS_RDP=("remmina") # remmina 41 | EXEC_DEPS_SAMBA=("samba") # samba 42 | EXEC_DEPS_IGPU_PASSTHROUGH=("uuid" "intel-virtual-output") # uuid xorg-x11-drv-intel 43 | EXEC_DEPS_HELPER_ISO=("genisoimage") # genisoimage 44 | EXEC_DEPS_UEFI_CHECK=("systool") # sysfsutils 45 | EXEC_DEPS_COMPATIBILITY_CHECK=("systool" "lshw" "lspci") # sysfsutils lshw pciutils dmidecode 46 | EXEC_DEPS_CPU_CHECK=("lscpu") # util-linux 47 | EXEC_DEPS_GPU_CHECK=("lshw") # lshw 48 | EXEC_DEPS_LOOKING_GLASS=("cmake" "gcc" "wayland-scanner" "makensis" "x86_64-w64-mingw32-g++") # cmake gcc-g++ wayland-devel mingw32-nsis mingw64-gcc-c++ 49 | FILE_DEPS_LOOKING_GLASS+=("/usr/include/bfd.h" "/usr/lib64/libbfd.a" "/usr/lib64/libiberty.a") # binutils-devel 50 | FILE_DEPS_LOOKING_GLASS+=("/usr/include/fontconfig/fontconfig.h") # fontconfig-devel 51 | FILE_DEPS_LOOKING_GLASS+=("/usr/include/spice-1/spice/protocol.h" "/usr/include/spice-1/spice/vd_agent.h" "") # spice-protocol 52 | FILE_DEPS_LOOKING_GLASS+=("/usr/include/X11/Xlib.h" "/usr/include/X11/Xutil.h") # libX11-devel 53 | FILE_DEPS_LOOKING_GLASS+=("/usr/include/nettle/asn1.h" "/usr/include/nettle/sha1.h" "/usr/include/nettle/rsa.h" "/usr/include/nettle/bignum.h") # nettle-devel 54 | FILE_DEPS_LOOKING_GLASS+=("/usr/share/wayland-protocols/stable/xdg-shell/xdg-shell.xml" "/usr/share/wayland-protocols/unstable/idle-inhibit/idle-inhibit-unstable-v1.xml" "/usr/share/wayland-protocols/unstable/keyboard-shortcuts-inhibit/keyboard-shortcuts-inhibit-unstable-v1.xml" "/usr/share/wayland-protocols/unstable/xdg-decoration/xdg-decoration-unstable-v1.xml") # wayland-protocols-devel 55 | FILE_DEPS_LOOKING_GLASS+=("/usr/lib/gcc/x86_64-redhat-linux/*/include/stdatomic.h" "/usr/lib/gcc/x86_64-redhat-linux/*/include/emmintrin.h" "/usr/lib/gcc/x86_64-redhat-linux/*/include/smmintrin.h" "/usr/lib/gcc/x86_64-redhat-linux/*/include/stdarg.h" "/usr/lib/gcc/x86_64-redhat-linux/*/include/stdbool.h" "/usr/lib/gcc/x86_64-redhat-linux/*/include/stddef.h" "/usr/lib/gcc/x86_64-redhat-linux/*/include/stdint.h") # gcc 56 | FILE_DEPS_LOOKING_GLASS+=("/usr/include/X11/extensions/scrnsaver.h") # libXScrnSaver-devel 57 | FILE_DEPS_LOOKING_GLASS+=("/usr/include/X11/extensions/Xfixes.h") # libXfixes-devel 58 | FILE_DEPS_LOOKING_GLASS+=("/usr/include/X11/extensions/XInput2.h") # libXi-devel 59 | FILE_DEPS_LOOKING_GLASS+=("/usr/include/wayland-client.h" "/usr/include/wayland-cursor.h" "/usr/include/wayland-egl.h") # wayland-devel 60 | FILE_DEPS_LOOKING_GLASS+=("/usr/include/X11/extensions/Xinerama.h") # libXinerama-devel 61 | FILE_DEPS_LOOKING_GLASS+=("/usr/include/SDL2/SDL.h" "/usr/include/SDL2/SDL_syswm.h") # SDL2-devel (will be removed in B5 probably) 62 | FILE_DEPS_LOOKING_GLASS+=("/usr/include/SDL2/SDL_ttf.h") # SDL2_ttf-devel (will be removed in B5 probably) 63 | #FILE_DEPS_LOOKING_GLASS+=("/usr/share/texlive/texmf-dist/fonts/opentype/public/gnu-freefont/FreeMono.otf") # this file is not actually a dependency # texlive-gnu-freefont # TODO: check if texlive-gnu-freefont is actually a dependency 64 | EXEC_DEPS_LIVE_ISO+=("wget" "xorriso" "mksquashfs" "unsquashfs") # wget xorriso squashfs-tools 65 | ############################################################################################################################# 66 | 67 | ALL_EXEC_DEPS="" # Will contain all content of all variables starting with EXEC_DEPS 68 | ALL_EXEC_DEPS_VARS="$(set -o posix ; set | grep -P '^EXEC_DEPS' | cut -d'=' -f1 | tr '\n' ' ')" 69 | for deps in $ALL_EXEC_DEPS_VARS; do 70 | ALL_EXEC_DEPS+="$(eval "echo \" \${$deps[*]}\"")" 71 | done 72 | 73 | ALL_FILE_DEPS="" # Will contain all content of all variables starting with FILE_DEPS 74 | ALL_FILE_DEPS_VARS="$(set -o posix ; set | grep -P '^FILE_DEPS' | cut -d'=' -f1 | tr '\n' ' ')" 75 | for deps in $ALL_FILE_DEPS_VARS; do 76 | ALL_FILE_DEPS+="$(eval "echo \" \${$deps[*]}\"")" 77 | done 78 | 79 | ALL_KERNEL_PARAMS="" # Will contain all content of all variables starting with KERNEL_PARAMS 80 | ALL_KERNEL_PARAMS_VARS="$(set -o posix ; set | grep -P '^KERNEL_PARAMS' | cut -d'=' -f1 | tr '\n' ' ')" 81 | for params in $ALL_KERNEL_PARAMS_VARS; do 82 | ALL_KERNEL_PARAMS+="$(eval "echo \" \${$params[*]}\"")" 83 | done 84 | -------------------------------------------------------------------------------- /screenshots/example-output.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/T-vK/MobilePassThrough/7102471fa5eb2be16126f02a7445091672c84376/screenshots/example-output.png -------------------------------------------------------------------------------- /scripts/README.md: -------------------------------------------------------------------------------- 1 | ``` 2 | scripts # All bash scripts called directly or indirectly by `mbpt.sh`. (Some scripts may also be installed in the `thirdparty` directory or may straight up be system dependencies installed using your package manager.) 3 | ├── main # Scripts that can be called directly or by running `mbpt.sh`. They work on any Linux distribution, given that a corresponding `utils/distro-specific/{DISTRIBUTION}/{VERSION}` directory with its scripts exists. 4 | └── utils # Scripts that are used by other scripts in this project. 5 | ├── common # Scripts that work on any Linux distribution, given that a corresponding `utils/distro-specific/{DISTRIBUTION}/{VERSION}` directory with its scripts exists. 6 | │ ├── libs # Scripts that are not executable and have to be `source`d. 7 | │ ├── setup # Scripts that have dependencies on other scripts (or programs in the `thirdparty` directory) in this project. 8 | │ └── tools # Scripts that don't have dependencies on other files in this project and could be moved into their own project at some point. 9 | ├── manager-specific # Scripts that are specific to a certain manager like systemd, dracut or grub. This is used to abstract functionality like creating services, adding kernel parameters and adding drivers to initfsram. 10 | └── distro-specific # Scripts that are distribution-specific. For every distribution/version the exact same set of scripts 11 | ├── Fedora # All `Fedora`-specific scripts. 12 | │ ├── 34 # All `Fedora 34`-specific scripts. 13 | │ └── 35 # All `Fedora 35`-specific scripts. 14 | └── Ubuntu # All `Ubuntu`-specific scripts. 15 | └── 21.04 # All `Ubuntu 21.04`-specific scripts. 16 | ``` -------------------------------------------------------------------------------- /scripts/main/compatibility-check.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | while [[ "$PROJECT_DIR" != */MobilePassThrough ]]; do PROJECT_DIR="$(readlink -f "$(dirname "${PROJECT_DIR:-0}")")"; done 3 | source "$PROJECT_DIR/scripts/utils/common/libs/helpers" 4 | 5 | ##################################################################################################### 6 | # This script checks the device it's executed on for GPU passthrough compatibility and prints a detailed report to the terminal. 7 | ##################################################################################################### 8 | 9 | # Enable these to mock the lshw output and iommu groups of other computers for testing purposes 10 | #MOCK_SET=1 11 | #LSHW_MOCK="${PROJECT_DIR}/mock-data/$MOCK_SET-lshw" 12 | #LSIOMMU_MOCK="${PROJECT_DIR}/mock-data/$MOCK_SET-lsiommu" 13 | 14 | source "${PROJECT_DIR}/requirements.sh" 15 | 16 | if sudo which optirun &> /dev/null && sudo optirun echo>/dev/null ; then 17 | USE_BUMBLEBEE=true 18 | OPTIRUN_PREFIX="optirun " 19 | else 20 | USE_BUMBLEBEE=false 21 | OPTIRUN_PREFIX="" 22 | fi 23 | 24 | alias updatePkgInfo="'${PACKAGE_MANAGER}' update" 25 | alias getExecPkg="'${PACKAGE_MANAGER}' install --executables" 26 | alias getMissingExecutables="${COMMON_UTILS_TOOLS_DIR}/get-missing-executables" 27 | alias lsiommu="sudo '${OPTIRUN_PREFIX}${COMMON_UTILS_TOOLS_DIR}/lsiommu'" 28 | 29 | MISSING_DEPS=$(getMissingExecutables "${EXEC_DEPS_COMPATIBILITY_CHECK[*]}") 30 | if [ "$MISSING_DEPS" != "" ]; then 31 | echo_white "[Info] Update package info..." 32 | updatePkgInfo 33 | echo_white "[Info] Trying to install packages providing: $MISSING_DEPS ..." 34 | getExecPkg "${EXEC_DEPS_COMPATIBILITY_CHECK[*]}" # Find and install packages needed to run this check 35 | fi 36 | MISSING_DEPS=$(getMissingExecutables "${EXEC_DEPS_COMPATIBILITY_CHECK[*]}") 37 | if [ "$MISSING_DEPS" != "" ]; then 38 | echo_red "[Error] Failed to install packages providing: $MISSING_DEPS" 39 | echo_red "[Info] Please install them manually and try again!" 40 | exit 1 41 | fi 42 | 43 | if [ -z ${LSIOMMU_MOCK+x} ]; then 44 | IOMMU_GROUPS=$(lsiommu) 45 | MOCK_MODE=false 46 | else 47 | IOMMU_GROUPS=$(cat "${LSIOMMU_MOCK}") 48 | MOCK_MODE=true 49 | fi 50 | 51 | if [ -z ${LSHW_MOCK+x} ]; then 52 | GPU_INFO=$(sudo lshw -class display -businfo) 53 | else 54 | GPU_INFO=$(cat "${LSHW_MOCK}") 55 | fi 56 | 57 | if [ "$MOCK_MODE" = true ]; then 58 | echo_red "[Warning] Using mock data! The following output has nothing to do with this system!" 59 | fi 60 | 61 | # Check if kernel is configured correctly 62 | if cat /proc/cmdline | grep --quiet iommu ; then 63 | KERNEL_IOMMU_ENABLED=true 64 | echo_green "[OK] The IOMMU kernel parameters are set." 65 | else 66 | KERNEL_IOMMU_ENABLED=false 67 | echo_red "[Error] The iommu kernel parameters are missing! You have to add them in order to use GPU passthrough!" 68 | fi 69 | 70 | # Check if UEFI is configured correctly 71 | if systool -m kvm_intel -v &> /dev/null || systool -m kvm_amd -v &> /dev/null ; then 72 | UEFI_VIRTUALIZATION_ENABLED=true 73 | echo_green "[OK] VT-X / AMD-V virtualization is enabled in the UEFI." 74 | else 75 | UEFI_VIRTUALIZATION_ENABLED=false 76 | echo_orange "[Warning] VT-X / AMD-V virtualization is not enabled in the UEFI! This feature is required to run virtual machines!" 77 | fi 78 | 79 | if [ "$IOMMU_GROUPS" != "" ] ; then 80 | UEFI_IOMMU_ENABLED=true 81 | echo_green "[OK] VT-D / IOMMU is enabled in the UEFI." 82 | else 83 | if [ "${KERNEL_IOMMU_ENABLED}" = true ] ; then 84 | UEFI_IOMMU_ENABLED=false 85 | echo_red "[Error] VT-D / IOMMU is not enabled in the UEFI! This feature is required to check which devices are in which IOMMU group and to use GPU passthrough!" 86 | else 87 | echo_orange "[Warning] VT-D / IOMMU might possibly not enabled in the UEFI. This feature is required to check which devices are in which IOMMU group and to use GPU passthrough!" 88 | fi 89 | fi 90 | 91 | GPU_IDS=($(echo "${GPU_INFO}" | grep "pci@" | cut -d " " -f 1 | cut -d ":" -f 2-)) 92 | 93 | GOOD_GPUS=() 94 | BAD_GPUS=() 95 | for GPU_ID in "${GPU_IDS[@]}"; do 96 | GPU_IOMMU_GROUP=$(echo "${IOMMU_GROUPS}" | grep "${GPU_ID}" | cut -d " " -f 3) 97 | 98 | if [ "$GPU_IOMMU_GROUP" == "" ] ; then # Compensate for Intel iGPUs sometimes not having an IOMMU group at all 99 | GPU_NAME="$(lspci -s "${GPU_ID}" | cut -d' ' -f2-)" 100 | if echo "${GPU_NAME}" | grep --quiet "Intel"; then 101 | GPU_IOMMU_GROUP="N/A" 102 | IOMMU_GROUPS+=$'\n'"IOMMU GROUP N/A ${GPU_ID} ${GPU_NAME}" 103 | fi 104 | fi 105 | 106 | if [ "$GPU_IOMMU_GROUP" == "" ] ; then 107 | echo_red "[Error] Failed to find the IOMMU group of the GPU with the ID ${GPU_ID}! Have you enabled iommu in the UEFI and kernel?" 108 | else 109 | OTHER_DEVICES_IN_GPU_GROUP=$(echo "${IOMMU_GROUPS}" | grep "IOMMU Group ${GPU_IOMMU_GROUP} " | grep -v ${GPU_ID} | grep -v " Audio device " | grep -v " PCI bridge ") 110 | OTHER_DEVICES_IN_GPU_GROUP_NO_GPUS=$(echo "${OTHER_DEVICES_IN_GPU_GROUP}" | grep -v " VGA compatible controller " | grep -v " 3D controller ") 111 | 112 | if [ "$OTHER_DEVICES_IN_GPU_GROUP" == "" ] ; then 113 | echo_green "[Success] GPU with ID '${GPU_ID}' could be passed through to a virtual machine!" 114 | GOOD_GPUS+=("$GPU_ID") 115 | elif [ "$OTHER_DEVICES_IN_GPU_GROUP_NO_GPUS" = "" ] ; then 116 | echo_orange "[Warning] GPU with ID '${GPU_ID}' could be passed through to a virtual machine, but only together with the following devices: " 117 | echo_orange "${OTHER_DEVICES_IN_GPU_GROUP}" 118 | GOOD_GPUS+=("${GPU_ID}") 119 | else 120 | echo_orange "[Problem] Other devices have been found in the IOMMU group of the GPU with the ID '${GPU_ID}'. Depending on the devices, this could make it impossible to pass this GPU through to a virtual machine!" 121 | echo_orange "The devices found in this GPU's IOMMU Group are:" 122 | echo_red "${OTHER_DEVICES_IN_GPU_GROUP}" 123 | echo_white "[Info] It might be possible to get it to work by putting the devices in different slots on the motherboard and/or by using the ACS override patch. Otherwise you'll probably have to get a different motherboard. If you're on a laptop, there is nothing you can do as far as I'm aware. Although it would theoretically be possible for ACS support for laptops to exist. TODO: Find a way to check if the current machine has support for that." 124 | BAD_GPUS+=("${GPU_ID}") 125 | fi 126 | fi 127 | done 128 | 129 | GPU_LIST="Is Compatible?|Name|IOMMU_GROUP|PCI Address" 130 | 131 | for GPU_ID in "${BAD_GPUS[@]}"; do 132 | PCI_ADDRESS="pci@0000:${GPU_ID}" 133 | NAME=$(echo "${GPU_INFO}" | grep "${GPU_ID}" | tr -s " " | cut -d " " -f 3-) 134 | IOMMU_GROUP=$(echo "${IOMMU_GROUPS}" | grep ${GPU_ID} | cut -d " " -f 3) 135 | GPU_LIST="${GPU_LIST}\nNo|${NAME}|${IOMMU_GROUP}|${PCI_ADDRESS}" 136 | done 137 | 138 | for GPU_ID in "${GOOD_GPUS[@]}"; do 139 | PCI_ADDRESS="pci@0000:${GPU_ID}" 140 | NAME=$(echo "${GPU_INFO}" | grep "${GPU_ID}" | tr -s " " | cut -d " " -f 3-) 141 | IOMMU_GROUP=$(echo "${IOMMU_GROUPS}" | grep "${GPU_ID}" | cut -d " " -f 3) 142 | GPU_LIST="${GPU_LIST}\nYes|${NAME}|${IOMMU_GROUP}|${PCI_ADDRESS}" 143 | done 144 | 145 | IOMMU_COMPATIBILITY_LVL=0 # 0: no GPUs to pass through; 1: at least 1 GPU for pt, but no GPU for host left; 2: at least one GPU for pt and at least one GPU for host left 146 | 147 | if [ "${#GOOD_GPUS[@]}" == "0" ] ; then 148 | if [ "${#GPU_IDS[@]}" == "0" ] ; then 149 | echo_red "[Warning] Failed to find any GPUs! Assuning this is correct, GPU passthrough is obviously impossible on this system in the current configuration!" 150 | else 151 | echo_red "[Warning] This script was not able to identify a GPU in this that could be passed through to a VM!" 152 | fi 153 | else 154 | echo_green "[Success] There are ${#GOOD_GPUS[@]} GPU(s) in this system that could be passed through to a VM!" 155 | 156 | echo_white "" 157 | GPU_LIST=$(echo -e "${GPU_LIST}" | column -t -s'|') 158 | while read -r line; do 159 | if echo "${line}" | grep --quiet Yes ; then 160 | echo_green "${line}" 161 | elif echo "${line}" | grep --quiet No ; then 162 | echo_red "${line}" 163 | else 164 | echo_orange "${line}" 165 | fi 166 | done <<< "${GPU_LIST}" 167 | echo_white "" 168 | 169 | if [ ${#GOOD_GPUS[@]} != 1 ] && grep -qE '^([0-9]+)( \1)*$' <<< $(echo $(echo "${IOMMU_GROUPS}" | grep -E $(echo "${GOOD_GPUS[@]}" | tr ' ' '|') | cut -d " " -f 3)) ; then 170 | if [ ${#BAD_GPUS[@]} == 0 ] ; then 171 | IOMMU_COMPATIBILITY_LVL=1 172 | echo_orange "[Warning] All GPUs in this system are in the same IOMMU group. This would make GPU passthrough difficult (not impossible) because your host machine would be left without a GPU!" 173 | else 174 | IOMMU_COMPATIBILITY_LVL=2 175 | echo_green "[Warning] Some of your GPUs are in the same IOMMU group. This means they could only be passed through together. You could still use a GPU that's in another group for your host system. (E.g. the one with the PCI address 'pci@0000:'${BAD_GPUS[0]} " 176 | fi 177 | else 178 | if [ "${#GPU_IDS[@]}" == "1" ] ; then 179 | IOMMU_COMPATIBILITY_LVL=1 180 | echo_orange "[Warning] Only 1 GPU found! (Counting all GPUs, not just dedicated ones.) This would make GPU passthrough difficult (not impossible) because your host machine would be left without a GPU!" 181 | else 182 | IOMMU_COMPATIBILITY_LVL=2 183 | echo_green "[OK] You have GPUs that are not in the same IOMMU group. At least one of these could be passed through to a VM and at least one of the remaining ones could be used for the host system." 184 | fi 185 | fi 186 | fi 187 | 188 | # If the device is a laptop 189 | #if [ "$(sudo ${OPTIRUN_PREFIX}dmidecode --string chassis-type)" != "Desktop" ] ; then 190 | if [ $(echo $IOMMU_GROUPS | grep " VGA compatible controller " | wc -l) = "2" ] && ! echo $IOMMU_GROUPS | grep --quiet " Display controller " ; then 191 | echo_white "[Info] This system is probably MUXed. (The connection between the GPU(s) and the [internal display]/[display outputs] is multiplexed.)" 192 | else 193 | echo_white "[Info] This system is probably MUX-less. (The connection between the GPU(s) and the [internal display]/[display outputs] is not multiplexed.)" 194 | fi 195 | #fi 196 | 197 | if [ "$MOCK_MODE" = true ]; then 198 | echo_red "[Warning] Remember, the above output has been generated using the given mock data and has nothing to do with this system!" 199 | fi 200 | 201 | if [ "${UEFI_VIRTUALIZATION_ENABLED}" = true ] && [ "${UEFI_IOMMU_ENABLED}" = true ] && [ "${KERNEL_IOMMU_ENABLED}" = true ] && [ "${IOMMU_COMPATIBILITY_LVL}" -gt "0" ] ; then 202 | echo_green "If you found a notebook that appears to be GPU passthrough compatible, please open an issue on Github and let me know." 203 | if [ "${IOMMU_COMPATIBILITY_LVL}" -gt "1" ] ; then 204 | echo_green "You may now proceed and run './mbpt.sh configure' if you haven't already." 205 | else 206 | exit 1 207 | fi 208 | else 209 | exit 1 210 | fi 211 | -------------------------------------------------------------------------------- /scripts/main/generate-helper-iso.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | while [[ "$PROJECT_DIR" != */MobilePassThrough ]]; do PROJECT_DIR="$(readlink -f "$(dirname "${PROJECT_DIR:-0}")")"; done 3 | source "$PROJECT_DIR/scripts/utils/common/libs/helpers" 4 | loadConfig 5 | ##################################################################################################### 6 | # This script creates a helper ISO file containing scripts and drivers to fully automate the Windows installation within the VM. 7 | ##################################################################################################### 8 | 9 | mkdir -p "${HELPER_ISO_FILES_DIR}/bin" 10 | mkdir -p "${HELPER_ISO_FILES_DIR}/scripts" 11 | #if [ ! -f "${HELPER_ISO_FILES_DIR}/bin/AutoHotkeyU64.exe" ]; then 12 | # echo "> Downloading AutoHotkey..." 13 | # rm -rf "${HELPER_ISO_FILES_DIR}/tmp" 14 | # mkdir -p "${HELPER_ISO_FILES_DIR}/tmp" 15 | # wget "https://autohotkey.com/download/ahk.zip" -O "${HELPER_ISO_FILES_DIR}/tmp/ahk.zip" 16 | # unzip "${HELPER_ISO_FILES_DIR}/tmp/ahk.zip" -d "${HELPER_ISO_FILES_DIR}/tmp/" 17 | # echo "> Adding AutoHotkey to iso folder..." 18 | # cp "${HELPER_ISO_FILES_DIR}/tmp/AutoHotkeyU64.exe" "${HELPER_ISO_FILES_DIR}/bin/" 19 | # rm -rf "${HELPER_ISO_FILES_DIR}/tmp" 20 | #else 21 | # echo "> AutoHotkey already exist in iso folder..." 22 | #fi 23 | 24 | if [ ! -f "${HELPER_ISO_FILES_DIR}/bin/VC_redist.x64.exe" ]; then 25 | echo "> Downloading Visual C++ Redistributable Package 2017 x64 for the Looking Glass Host application..." 26 | wget "https://download.microsoft.com/download/8/9/D/89D195E1-1901-4036-9A75-FBE46443FC5A/VC_redist.x64.exe" -O "${HELPER_ISO_FILES_DIR}/bin/VC_redist.x64.exe" 27 | else 28 | echo "> Visual C++ Redistributable Package 2017 x64 already exist in iso folder..." 29 | fi 30 | 31 | if [ ! -f "${HELPER_ISO_FILES_DIR}/bin/spice-guest-tools.exe" ]; then 32 | echo "> Downloading Spice Guest Tools..." 33 | wget "https://www.spice-space.org/download/windows/spice-guest-tools/spice-guest-tools-0.141/spice-guest-tools-0.141.exe" -O "${HELPER_ISO_FILES_DIR}/bin/spice-guest-tools.exe" 34 | else 35 | echo "> Spice Guest Tools already exists in iso folder..." 36 | fi 37 | 38 | if [ ! -f "${HELPER_ISO_FILES_DIR}/bin/spice-webdavd.msi" ]; then 39 | echo "> Downloading Spice WebDAV daemon..." 40 | wget "https://www.spice-space.org/download/windows/spice-webdavd/spice-webdavd-x64-2.4.msi" -O "${HELPER_ISO_FILES_DIR}/bin/spice-webdavd.msi" 41 | else 42 | echo "> Spice WebDAV daemon already exists in iso folder..." 43 | fi 44 | 45 | if [ ! -f "${HELPER_ISO_FILES_DIR}/bin/looking-glass-host-setup.exe" ]; then 46 | #echo "> Downloading Looking Glass Host application..." 47 | #wget "https://github.com/gnif/LookingGlass/releases/download/${LOOKING_GLASS_VERSION}/looking-glass-host.exe" -O "${HELPER_ISO_FILES_DIR}/bin/looking-glass-host.exe" 48 | echo "> Copy Looking Glass Host application setup to where we need it..." 49 | cp "${PROJECT_DIR}/thirdparty/LookingGlass/platform/Windows/looking-glass-host-setup.exe" "${HELPER_ISO_FILES_DIR}/bin/looking-glass-host-setup.exe" 50 | else 51 | echo "> Looking Glass Host application already exist in iso folder..." 52 | fi 53 | 54 | #if [ ! -f "${HELPER_ISO_FILES_DIR}/bin/ivshmem-driver/ivshmem.cat" ] || [ ! -f "${HELPER_ISO_FILES_DIR}/bin/ivshmem-driver/ivshmem.inf" ] || [ ! -f "${HELPER_ISO_FILES_DIR}/bin/ivshmem-driver/ivshmem.pdb" ] || [ ! -f "${HELPER_ISO_FILES_DIR}/bin/ivshmem-driver/ivshmem.sys" ]; then 55 | # echo "> Downloading IVSHMEM driver..." 56 | # rm -rf "${HELPER_ISO_FILES_DIR}/tmp" 57 | # mkdir -p "${HELPER_ISO_FILES_DIR}/tmp" 58 | # wget "https://fedorapeople.org/groups/virt/virtio-win/direct-downloads/upstream-virtio/virtio-win10-prewhql-0.1-161.zip" -O "${HELPER_ISO_FILES_DIR}/tmp/virtio-win10-prewhql.zip" 59 | # unzip "${HELPER_ISO_FILES_DIR}/tmp/virtio-win10-prewhql.zip" -d "${HELPER_ISO_FILES_DIR}/tmp" 60 | # rm -f "${HELPER_ISO_FILES_DIR}/tmp/virtio-win10-prewhql.zip" 61 | # rm -rf "${HELPER_ISO_FILES_DIR}/bin/ivshmem-driver" 62 | # mkdir -p "${HELPER_ISO_FILES_DIR}/bin/ivshmem-driver" 63 | # cp "${HELPER_ISO_FILES_DIR}/tmp/Win10/amd64/ivshmem*" "${HELPER_ISO_FILES_DIR}/bin/ivshmem-driver/" 64 | # #cp -r "${HELPER_ISO_FILES_DIR}/tmp" "${HELPER_ISO_FILES_DIR}/bin/ivshmem-driver" 65 | # rm -rf "${HELPER_ISO_FILES_DIR}/tmp" 66 | #else 67 | # echo "> IVSHMEM driver already exist in iso folder..." 68 | #fi 69 | 70 | if [ ! -d "${HELPER_ISO_FILES_DIR}/bin/virtio-drivers/Win10" ]; then 71 | echo "> Downloading virtio drivers..." 72 | rm -rf "${HELPER_ISO_FILES_DIR}/tmp" 73 | mkdir -p "${HELPER_ISO_FILES_DIR}/tmp" 74 | wget "https://fedorapeople.org/groups/virt/virtio-win/direct-downloads/upstream-virtio/virtio-win10-prewhql-0.1-161.zip" -O "${HELPER_ISO_FILES_DIR}/tmp/virtio-win10-prewhql.zip" 75 | mkdir -p "${HELPER_ISO_FILES_DIR}/bin/virtio-drivers" 76 | unzip "${HELPER_ISO_FILES_DIR}/tmp/virtio-win10-prewhql.zip" -d "${HELPER_ISO_FILES_DIR}/bin/virtio-drivers" 77 | rm -rf "${HELPER_ISO_FILES_DIR}/tmp" 78 | else 79 | echo "> virtio drivers already exist in iso folder..." 80 | fi 81 | 82 | #if [ ! -f "${HELPER_ISO_FILES_DIR}/bin/devcon.exe" ]; then 83 | # echo "> Downloading Microsoft's devcon driver tool..." 84 | # rm -rf "${HELPER_ISO_FILES_DIR}/tmp" 85 | # mkdir -p "${HELPER_ISO_FILES_DIR}/tmp" 86 | # wget "https://download.microsoft.com/download/B/5/8/B58D625D-17D6-47A8-B3D3-668670B6D1EB/wdk/Installers/787bee96dbd26371076b37b13c405890.cab" -O "${HELPER_ISO_FILES_DIR}/tmp/devcon.cab" 87 | # cabextract -d "${HELPER_ISO_FILES_DIR}/tmp" "${HELPER_ISO_FILES_DIR}/tmp/devcon.cab" 88 | # cp "${HELPER_ISO_FILES_DIR}/tmp/devcon.cab" "${HELPER_ISO_FILES_DIR}/bin/devcon.exe" 89 | # #TODO: check if installing the cabextract is necessary or if it actually is devcon directly 90 | # rm -rf "${HELPER_ISO_FILES_DIR}/tmp" 91 | #else 92 | # echo "> devcon driver tool already exist in iso folder..." 93 | #fi 94 | 95 | if [ ! -f "${HELPER_ISO_FILES_DIR}/scripts/chocolatey-install.ps1" ]; then 96 | echo "> Downloading Chocolatey install script..." 97 | wget "https://chocolatey.org/install.ps1" -O "${HELPER_ISO_FILES_DIR}/scripts/chocolatey-install.ps1" 98 | else 99 | echo "> Chocolatey install script already exist in iso folder..." 100 | fi 101 | 102 | rm -rf "${HELPER_ISO_FILES_DIR}/tmp" 103 | 104 | rm -f "${HELPER_ISO}" 105 | 106 | #echo "genisoimage -quiet -input-charset utf-8 -J -joliet-long -r -allow-lowercase -allow-multidot -o \"${HELPER_ISO}\" \"${HELPER_ISO_FILES_DIR}\"" 107 | genisoimage -quiet -input-charset utf-8 -J -joliet-long -r -allow-lowercase -allow-multidot -o "${HELPER_ISO}" "${HELPER_ISO_FILES_DIR}" |& grep -v "Warning: " 108 | -------------------------------------------------------------------------------- /scripts/main/generate-live-iso.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | while [[ "$PROJECT_DIR" != */MobilePassThrough ]]; do PROJECT_DIR="$(readlink -f "$(dirname "${PROJECT_DIR:-0}")")"; done 3 | source "$PROJECT_DIR/scripts/utils/common/libs/helpers" 4 | loadConfig 5 | 6 | source "${PROJECT_DIR}/requirements.sh" 7 | 8 | alias getMissingExecutables="${COMMON_UTILS_TOOLS_DIR}/get-missing-executables" 9 | alias updatePkgInfo="'${PACKAGE_MANAGER}' update" 10 | alias getExecPkg="'${PACKAGE_MANAGER}' install --executables" 11 | 12 | MODE="$1" 13 | DRIVE="$2" 14 | 15 | ISO_DOWNLOAD_URL="https://download.fedoraproject.org/pub/fedora/linux/releases/34/Workstation/x86_64/iso/Fedora-Workstation-Live-x86_64-34-1.2.iso" 16 | ISO_FILE="${LIVE_ISO_FILES_DIR}/Fedora-Workstation-Live-x86_64-34-1.2.iso" 17 | ISO_FILE_MODIFIED="${LIVE_ISO_FILES_DIR}/Fedora-Workstation-Live-x86_64-34-1.2.modified.iso" 18 | #ISO_DOWNLOAD_URL="https://download.fedoraproject.org/pub/fedora/linux/releases/35/Workstation/x86_64/iso/Fedora-Workstation-Live-x86_64-35-1.2.iso" 19 | #ISO_FILE="${LIVE_ISO_FILES_DIR}/Fedora-Workstation-Live-x86_64-35-1.2.iso" 20 | #ISO_FILE_MODIFIED="${LIVE_ISO_FILES_DIR}/Fedora-Workstation-Live-x86_64-35-1.2.modified.iso" 21 | 22 | SOURCE_SQUASHFS_IMG="/LiveOS/squashfs.img" 23 | SQUASHFS_IMG="/tmp/squashfs.img" 24 | SQUASHFS_EXTRACTED="/tmp/squashfs-extracted" 25 | SQUASHFS_IMG_MODIFIED="/tmp/squashfs.modified.img" 26 | 27 | ROOTFS_IMG="${SQUASHFS_EXTRACTED}/LiveOS/rootfs.img" 28 | ROOTFS_MOUNTPOINT="/tmp/rootfs-mountpoint" 29 | 30 | MISSING_EXECUTABLES="$(getMissingExecutables "$EXEC_DEPS_LIVE_ISO")" 31 | 32 | if [ "$MISSING_EXECUTABLES" != "" ]; then 33 | echo "> Update package info..." 34 | updatePkgInfo 35 | echo "> Find and install packages containing executables that we need..." 36 | getExecPkg "$ALL_EXEC_DEPS" # Find and install packages containing executables that we need 37 | MISSING_EXECUTABLES="$(getMissingExecutables "$ALL_EXEC_DEPS")" 38 | if [ "$MISSING_EXECUTABLES" != "" ]; then 39 | echo "> ERROR: Failed to install packages providing the following executables automatically: $MISSING_EXECUTABLES" 40 | fi 41 | else 42 | echo "> [Skipped] Executable dependencies are already installed." 43 | fi 44 | 45 | if [ ! -d "${THIRDPARTY_DIR}/livecd-tools" ]; then 46 | echo "> Downloading and installing livecd-tools..." 47 | mkdir -p "${THIRDPARTY_DIR}" 48 | cd "${THIRDPARTY_DIR}" 49 | git clone https://github.com/livecd-tools/livecd-tools.git #--branch=livecd-tools-28.3 --single-branch livecd-tools 50 | cd livecd-tools 51 | git checkout 9c7f40e7edae3475be9a0b8afd7b390a7ad3bfbc 52 | sudo make install 53 | sudo pip3 install urlgrabber 54 | else 55 | echo "> [Skipped] livecd-tools already installed." 56 | fi 57 | 58 | cd "${PROJECT_DIR}" 59 | 60 | function build_method_1() { 61 | if [ ! -f "${ISO_FILE}" ]; then 62 | echo "> Downloading Fedora ISO..." 63 | wget "${ISO_DOWNLOAD_URL}" -c -O "${ISO_FILE}.part" 64 | mv "${ISO_FILE}.part" "${ISO_FILE}" 65 | else 66 | echo "> [Skipped] Fedora ISO already downloaded." 67 | fi 68 | 69 | sudo rm -rf "${ISO_FILE_MODIFIED}" 70 | 71 | echo "> Rebuilding the ISO adding kernel parameters and some files..." 72 | TMP_SCRIPT="/tmp/tmp-rootfs-setup.sh" 73 | sudo rm -f "${TMP_SCRIPT}" 74 | echo "#!/usr/bin/env bash" > "${TMP_SCRIPT}" 75 | echo "mkdir -p /etc/skel/.config/autostart/" >> "${TMP_SCRIPT}" 76 | echo "IFS='' read -r -d '' GET_MBPT_SCRIPT <<\"EOF\"" >> "${TMP_SCRIPT}" 77 | echo "$(cat ${LIVE_ISO_FILES_DIR}/get-mbpt.sh)" >> "${TMP_SCRIPT}" 78 | echo "EOF" >> "${TMP_SCRIPT}" 79 | echo 'echo "$GET_MBPT_SCRIPT" > /etc/skel/get-mbpt.sh' >> "${TMP_SCRIPT}" 80 | echo "chmod +x /etc/skel/get-mbpt.sh" >> "${TMP_SCRIPT}" 81 | echo "IFS='' read -r -d '' GET_MBPT_DESKTOP_FILE <<\"EOF\"" >> "${TMP_SCRIPT}" 82 | echo "$(cat ${LIVE_ISO_FILES_DIR}/mbpt.desktop)" >> "${TMP_SCRIPT}" 83 | echo "EOF" >> "${TMP_SCRIPT}" 84 | echo 'echo "$GET_MBPT_DESKTOP_FILE" > /etc/skel/.config/autostart/mbpt.desktop' >> "${TMP_SCRIPT}" 85 | echo 'echo "$GET_MBPT_DESKTOP_FILE" > /usr/share/applications/mbpt.desktop' >> "${TMP_SCRIPT}" 86 | #echo "touch /etc/skel/.config/autostart/fedora-welcome.desktop" >> "${TMP_SCRIPT}" 87 | echo "sed -i 's/^\(Exec=\).*/\1\/usr\/bin\/true/' /usr/share/anaconda/gnome/fedora-welcome.desktop" >> "${TMP_SCRIPT}" 88 | #echo "dnf install -y --allowerasing fedora-remix-logos generic-release" >> "${TMP_SCRIPT}" 89 | echo "dnf install -y --allowerasing generic-logos generic-release" >> "${TMP_SCRIPT}" 90 | echo "dnf install -y fedora-remix-logos" >> "${TMP_SCRIPT}" 91 | #echo "dnf remove -y fedora-logos" >> "${TMP_SCRIPT}" # impossbile because of gnome-shell dependency 92 | sudo chmod +x "${TMP_SCRIPT}" 93 | 94 | USERNAME="T-vK" sudo editliveos \ 95 | --builder "T-vK" \ 96 | --noshell \ 97 | --script "${TMP_SCRIPT}" \ 98 | --extra-kernel-args "$ALL_KERNEL_PARAMS" \ 99 | --output "${LIVE_ISO_FILES_DIR}" \ 100 | --name "mbpt" \ 101 | "${ISO_FILE}" 102 | 103 | mv "${LIVE_ISO_FILES_DIR}/mbpt-"*.iso "${ISO_FILE_MODIFIED}" 104 | 105 | sudo rm -f "${TMP_SCRIPT}" 106 | } 107 | 108 | function build_method_2() { 109 | if [ ! -f "${ISO_FILE}" ]; then 110 | echo "> Downloading Fedora ISO..." 111 | wget "${ISO_DOWNLOAD_URL}" -c -O "${ISO_FILE}.part" 112 | mv "${ISO_FILE}.part" "${ISO_FILE}" 113 | else 114 | echo "> [Skipped] Fedora ISO already downloaded." 115 | fi 116 | 117 | sudo rm -rf "${ISO_FILE_MODIFIED}" 118 | 119 | echo "> Extracting the squashfs image and unsquash it..." 120 | sudo rm -f "/tmp/grub.conf" 121 | sudo rm -f "/tmp/isolinux.cfg" 122 | sudo rm -f "/tmp/BOOT.conf" 123 | sudo rm -f "/tmp/grub.cfg" 124 | sudo rm -f "${SQUASHFS_IMG}" 125 | xorriso -dev "${ISO_FILE}" -osirrox "on" \ 126 | -extract "${SOURCE_SQUASHFS_IMG}" "${SQUASHFS_IMG}" \ 127 | -extract "/isolinux/grub.conf" "/tmp/grub.conf" \ 128 | -extract "/isolinux/isolinux.cfg" "/tmp/isolinux.cfg" \ 129 | -extract "/EFI/BOOT/BOOT.conf" "/tmp/BOOT.conf" \ 130 | -extract "/EFI/BOOT/grub.cfg" "/tmp/grub.cfg" 131 | sudo rm -rf "${SQUASHFS_EXTRACTED}" 132 | sudo unsquashfs -d "${SQUASHFS_EXTRACTED}" "${SQUASHFS_IMG}" # Unsquash the squashfs and mount the rootfs in read-write mode 133 | sudo rm -f "${SQUASHFS_IMG}" 134 | 135 | echo "> Mounting the rootfs image of the unsquashed squashfs image..." 136 | sudo umount --force "${ROOTFS_MOUNTPOINT}" 137 | sudo rm -rf "${ROOTFS_MOUNTPOINT}" 138 | sudo mkdir -p "${ROOTFS_MOUNTPOINT}" 139 | sudo mount -o loop,rw "${ROOTFS_IMG}" "${ROOTFS_MOUNTPOINT}" 140 | 141 | echo "> Adding files to the rootfs..." 142 | sudo mkdir -p "${ROOTFS_MOUNTPOINT}/etc/skel/.config/autostart/" 143 | sudo cp "${LIVE_ISO_FILES_DIR}/get-mbpt.sh" "${ROOTFS_MOUNTPOINT}/etc/skel/" 144 | sudo cp "${LIVE_ISO_FILES_DIR}/mbpt.desktop" "${ROOTFS_MOUNTPOINT}/etc/skel/.config/autostart/" 145 | sudo cp "${LIVE_ISO_FILES_DIR}/mbpt.desktop" "${ROOTFS_MOUNTPOINT}/usr/share/applications/" 146 | 147 | echo "> Unmounting the rootfs image again..." 148 | sudo umount "${ROOTFS_MOUNTPOINT}" 149 | sudo rm -rf "${ROOTFS_MOUNTPOINT}" 150 | 151 | echo "> Making a new squashfs image from the unsquashed modified squashfs image..." 152 | sudo mksquashfs "${SQUASHFS_EXTRACTED}" "${SQUASHFS_IMG_MODIFIED}" -b 1024k -comp xz -Xbcj x86 -e boot 153 | sudo rm -rf "${SQUASHFS_EXTRACTED}" 154 | 155 | sudo sed -i "s/rd.live.image/$1 &/" "/tmp/grub.conf" 156 | sudo sed -i "s/rd.live.image/$1 &/" "/tmp/isolinux.cfg" 157 | sudo sed -i "s/rd.live.image/$1 &/" "/tmp/BOOT.conf" 158 | sudo sed -i "s/rd.live.image/$1 &/" "/tmp/grub.cfg" 159 | 160 | echo "> Overwriting the squashfs image inside the ISO with the modified one..." 161 | xorriso -indev "${ISO_FILE}" -outdev "${ISO_FILE_MODIFIED}" -md5 "all" -compliance no_emul_toc \ 162 | -update "${SQUASHFS_IMG_MODIFIED}" "/LiveOS/squashfs.img" \ 163 | -update "/tmp/grub.conf" "/isolinux/grub.conf" \ 164 | -update "/tmp/isolinux.cfg" "/isolinux/isolinux.cfg" \ 165 | -update "/tmp/BOOT.conf" "/EFI/BOOT/BOOT.conf" \ 166 | -update "/tmp/grub.cfg" "/EFI/BOOT/grub.cfg" \ 167 | -boot_image any replay 168 | 169 | echo "> Removing modified squashfs image..." 170 | sudo rm -f "${SQUASHFS_IMG_MODIFIED}" 171 | } 172 | 173 | function flash() { 174 | echo "> Flashing ISO to USB drive" 175 | mps="$(mount | grep "$DRIVE" | cut -d' ' -f3)" # get mountpoint for device 176 | if [ "$mps" != "" ]; then 177 | echo "> $DRIVE is still mounted." 178 | while IFS= read -r mp; do 179 | echo "> Unmounting partition mounted at ${mp}..." 180 | sudo umount --force "$mp" 181 | done <<< "$mps" 182 | fi 183 | yes "" | sudo livecd-iso-to-disk --format ext4 --overlay-size-mb 4095 --efi --force --extra-kernel-args "$ALL_KERNEL_PARAMS" "${ISO_FILE_MODIFIED}" "$DRIVE" 184 | } 185 | 186 | if [ "$MODE" = "flash" ]; then 187 | if [ "$DRIVE" = "" ]; then 188 | echo "> [Error] Missing parameter. You have to specify the device onto which to flash the Live ISO! E.g. /dev/sda" 189 | exit 1 190 | fi 191 | if [ ! -f "${ISO_FILE_MODIFIED}" ]; then 192 | build_method_1 193 | fi 194 | flash 195 | elif [ "$MODE" = "build" ]; then 196 | build_method_1 197 | fi -------------------------------------------------------------------------------- /scripts/main/generate-vm-config.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | while [[ "$PROJECT_DIR" != */MobilePassThrough ]]; do PROJECT_DIR="$(readlink -f "$(dirname "${PROJECT_DIR:-0}")")"; done 3 | source "$PROJECT_DIR/scripts/utils/common/libs/helpers" 4 | 5 | ##################################################################################################### 6 | # This interactive script creates a custom config file (user.conf) to your liking. 7 | ##################################################################################################### 8 | 9 | #source "$COMMON_UTILS_LIBS_DIR/gpu-check" 10 | 11 | interactiveCfg() { 12 | DEFAULT_VALUE=$(grep -Po "(?<=^$2=).*" "${PROJECT_DIR}/default.conf" | cut -d "#" -f1 | sed 's/^\s*"\(.*\)"\s*$/\1/' | xargs) 13 | COMMENT=$(grep -Po "(?<=^$2=).*" "${PROJECT_DIR}/default.conf" | cut -d "#" -f2-) 14 | #echo "DEFAULT_VALUE: $DEFAULT_VALUE" 15 | declare -A "$2=$DEFAULT_VALUE" 16 | TMP_VAR_NAME="TMP_$2"; 17 | #echo "TMP_VAR_NAME: ${TMP_VAR_NAME}" 18 | read -p "$1 [$DEFAULT_VALUE]: " "$TMP_VAR_NAME"; 19 | declare -A "USER_INPUT=${!TMP_VAR_NAME}" 20 | #echo "VM_FILES_DIR: ${VM_FILES_DIR}" 21 | #echo "USER_INPUT: ${!TMP_VAR_NAME}" 22 | if [ "${USER_INPUT}" != "" ]; then 23 | FINAL_VALUE="${USER_INPUT}" 24 | else 25 | FINAL_VALUE="${DEFAULT_VALUE}" 26 | fi 27 | declare -g "$2=${FINAL_VALUE}" 28 | #echo "FINAL_VALUE: $FINAL_VALUE" 29 | if [ "${USER_CONFIG_FILE}" != "" ]; then 30 | crudini --set "${USER_CONFIG_FILE}" "" "$2" "\"${FINAL_VALUE}\" #${COMMENT}" 31 | echo "> Set $2 to '${FINAL_VALUE}'" 32 | fi 33 | # TODO: change modified value on config file USER_CONFIG_FILE 34 | } 35 | 36 | echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" 37 | echo "!!IF IN DOUBT WITH ANY OF THE FOLLOWING, JUST PRESS ENTER TO USE THE RECOMMENDED/DEFAULT VALUE!!" 38 | echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" 39 | interactiveCfg "Where should the VM files be saved?" VM_FILES_DIR 40 | echo "> Directory set to '${VM_FILES_DIR}'" 41 | 42 | #read -p "Where should the config to be generated be saved? (Will overwrite if necessary) [${VM_FILES_DIR}/user.conf]: " USER_CONFIG_FILE 43 | #if [ "$USER_CONFIG_FILE" == "" ]; then 44 | # USER_CONFIG_FILE="${VM_FILES_DIR}/user.conf" 45 | #fi 46 | USER_CONFIG_FILE="${PROJECT_DIR}/user.conf" 47 | 48 | eval "USER_CONFIG_FILE=${USER_CONFIG_FILE}" 49 | #echo "USER_CONFIG_FILE=$USER_CONFIG_FILE" 50 | mkdir -p "$(dirname "${USER_CONFIG_FILE}")" 51 | cp "${PROJECT_DIR}/default.conf" "${USER_CONFIG_FILE}" 52 | echo "> Config will be created at ${USER_CONFIG_FILE}'" 53 | 54 | # Variables that require a reinstall when changed (./mbpt.sh install) 55 | interactiveCfg "What should the name of the VM be?" VM_NAME 56 | interactiveCfg "Where to save the VM drive image?" DRIVE_IMG 57 | interactiveCfg "How big should the VM drive image be? (At least 40G is highly recommended; Can't be changed wihtout a reinstall)" VM_DISK_SIZE 58 | interactiveCfg "Path to your Windows installation iso. (If it doesn't exist it will be downloaded to that location automatically.)" INSTALL_IMG 59 | 60 | # Variables that can be changed between VM starts (./mbpt.sh start) 61 | interactiveCfg "How many CPU cores should the VM get? (e.g. 8 or auto; auto equals [AVAILABLE CORES]-1 but uses 16 cores max)" CPU_CORE_COUNT 62 | interactiveCfg "How much RAM should the VM get? (e.g. 16G or auto; auto equals [FREE RAM]-1G but uses 16G max)" RAM_SIZE 63 | 64 | interactiveCfg "The PCI address of your dGPU as obtained by 'lspci' or 'optimus lspci'. (E.g. 01:00.0 or auto to detect it automatically)" DGPU_PCI_ADDRESS 65 | interactiveCfg "The PCI address of your iGPU as obtained by 'lspci'. (E.g. 00:02.0 or auto to detect it automatically)" IGPU_PCI_ADDRESS 66 | interactiveCfg "Pass the dGPU through to the VM. (true, false or auto to enable if more than one GPU is in this system)" DGPU_PASSTHROUGH 67 | interactiveCfg "Share the iGPU (only supports Intel atm) with the VM to allow using Optimus within the VM to save battery life (true, false or auto to share it only if available)" SHARE_IGPU 68 | 69 | interactiveCfg "Path to a dGPU ROM. (Optional; Can help avoid error 43)" DGPU_ROM 70 | interactiveCfg "Path to a iGPU ROM. (Optional; Can help avoid error 43)" IGPU_ROM 71 | interactiveCfg "Patch OVMF with your dGPU ROM if you supply one. (Highly recommended to avoid Error 43)" PATCH_OVMF_WITH_VROM 72 | 73 | interactiveCfg "MAC address to use (e.g. 11:22:33:44:55:66 or auto to generate it automatically)" MAC_ADDRESS 74 | interactiveCfg "Network mode to use? Only supports bridge at the moment." NETWORK_MODE 75 | interactiveCfg "Path to a folder to share with the VM via SMB. (Optional)" SMB_SHARE_FOLDER 76 | 77 | interactiveCfg "Virtual input device mode for keyboard and mouse. (if usb-tablet doesn't work properly, you may want to switch to virtio)" VIRTUAL_INPUT_TYPE 78 | 79 | interactiveCfg "Location of the unmodified OVMF_VARS.fd." OVMF_VARS 80 | interactiveCfg "Location of the unmodified OVMF_CODE.fd." OVMF_CODE 81 | interactiveCfg "Where to create Creating a copy of OVMF_VARS.fd (containing the executable firmware code and but the non-volatile variable store) for the VM?" OVMF_VARS_VM 82 | 83 | interactiveCfg "Location of helper iso or where to create it." HELPER_ISO 84 | 85 | interactiveCfg "Max screen width with Looking Glass." LOOKING_GLASS_MAX_SCREEN_WIDTH 86 | interactiveCfg "Max screen height with Looking Glass." LOOKING_GLASS_MAX_SCREEN_HEIGHT 87 | interactiveCfg "Version of Looking Glass to use (B4 is highly recommended)" LOOKING_GLASS_VERSION 88 | 89 | interactiveCfg "Display mode to use (e.g. 1 or 2 ... see scripts/utils/common/plugins)" DISPLAY_MODE 90 | 91 | interactiveCfg "Enable spice. (Leave this on unless you know what you're doing!)" USE_SPICE 92 | interactiveCfg "Port to use for spice." SPICE_PORT 93 | interactiveCfg "Automatically start a Spice client when the VM starts." USE_SPICE_CLIENT 94 | 95 | interactiveCfg "Provide the VM with a fake battery (Highly recommended to avoid Error 43)" USE_FAKE_BATTERY 96 | 97 | interactiveCfg "Tool to use to start/install the VM. (qemu or virt-install)" VM_START_MODE 98 | 99 | interactiveCfg "List of USB devices to pass through. (Semicolon separated, e.g. vendorid=0x0b12,productid=0x9348;vendorid=0x0b95,productid=0x1790)" USB_DEVICES 100 | # TODO: Make selecting USB devices easier -------------------------------------------------------------------------------- /scripts/main/iommu-check.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | while [[ "$PROJECT_DIR" != */MobilePassThrough ]]; do PROJECT_DIR="$(readlink -f "$(dirname "${PROJECT_DIR:-0}")")"; done 3 | source "$PROJECT_DIR/scripts/utils/common/libs/helpers" 4 | 5 | ##################################################################################################### 6 | # This script checks if virtualization and IOMMU are enabled in the UEFI and kernel. 7 | # Exits with 0 in case of success; Exits with 1 if it's not fully enabled. 8 | # Will print helpful output telling you what is working and what is not. 9 | ##################################################################################################### 10 | 11 | if sudo which optirun &> /dev/null && sudo optirun echo>/dev/null ; then 12 | OPTIRUN_PREFIX="optirun " 13 | else 14 | OPTIRUN_PREFIX="" 15 | fi 16 | 17 | IOMMU_GROUPS=$(sudo ${OPTIRUN_PREFIX}${COMMON_UTILS_TOOLS_DIR}/lsiommu) 18 | 19 | # Check if UEFI is configured correctly 20 | if systool -m kvm_intel -v &> /dev/null || systool -m kvm_amd -v &> /dev/null ; then 21 | UEFI_VIRTUALIZATION_ENABLED=true 22 | echo "[OK] VT-X / AMD-V virtualization is enabled in the UEFI." 23 | else 24 | UEFI_VIRTUALIZATION_ENABLED=false 25 | echo "[Error] VT-X / AMD-V virtualization is not enabled in the UEFI! This is required to run virtual machines!" 26 | fi 27 | 28 | if [ "$IOMMU_GROUPS" != "" ] ; then 29 | UEFI_IOMMU_ENABLED=true 30 | echo "[OK] VT-D / IOMMU is enabled in the UEFI." 31 | else 32 | UEFI_IOMMU_ENABLED=false 33 | echo "[Error] VT-D / IOMMU is not enabled in the UEFI! This is required to check which devices are in which IOMMU group and to use GPU passthrough!" 34 | fi 35 | 36 | if [ "$UEFI_VIRTUALIZATION_ENABLED" = true ] && [ "$UEFI_IOMMU_ENABLED" = true ] ; then 37 | exit 0 # success 38 | else 39 | exit 1 # error 40 | fi -------------------------------------------------------------------------------- /scripts/main/setup.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | while [[ "$PROJECT_DIR" != */MobilePassThrough ]]; do PROJECT_DIR="$(readlink -f "$(dirname "${PROJECT_DIR:-0}")")"; done 3 | source "$PROJECT_DIR/scripts/utils/common/libs/helpers" 4 | loadConfig 5 | 6 | ##################################################################################################### 7 | # This script installs all missing and required dependencies and also adds required kernel parameters. It's called like this: `./setup.sh` 8 | # If you want to automatically reboot the system if necessary (e.g. to load new kernel params) run with: `./setup.sh auto`. 9 | # This won't just reboot the system, but also create a temporary service that will execute `mbpt.sh auto` on the next boot. 10 | # TODO: the service creation shouldn'T be part of setup.sh. It should be in the auto section of mbpt.sh. 11 | ##################################################################################################### 12 | 13 | source "${PROJECT_DIR}/requirements.sh" 14 | 15 | alias getMissingExecutables="${COMMON_UTILS_TOOLS_DIR}/get-missing-executables" 16 | alias getMissingFiles="${COMMON_UTILS_TOOLS_DIR}/get-missing-files" 17 | alias updatePkgInfo="'${PACKAGE_MANAGER}' update" 18 | alias getExecPkg="'${PACKAGE_MANAGER}' install --executables" 19 | alias getFilePkg="'${PACKAGE_MANAGER}' install --files" 20 | alias addKernelParams="sudo '${KERNEL_PARAM_MANAGER}' add" 21 | alias applyKernelParamChanges="sudo '${KERNEL_PARAM_MANAGER}' apply" 22 | alias runtimeKernelHasParams="${COMMON_UTILS_TOOLS_DIR}/runtime-kernel-has-params" 23 | alias ovmfVbiosPatchSetup="sudo '$COMMON_UTILS_SETUP_DIR/ovmf-vbios-patch-setup'" 24 | alias buildFakeBatterySsdt="sudo '$COMMON_UTILS_SETUP_DIR/build-fake-battery-ssdt'" 25 | alias vbiosFinderSetup="sudo '$COMMON_UTILS_SETUP_DIR/vbios-finder-setup'" 26 | alias lookingGlassSetup="sudo '$COMMON_UTILS_SETUP_DIR/looking-glass-setup'" 27 | alias generateHelperIso="sudo '${MAIN_SCRIPTS_DIR}/generate-helper-iso.sh'" 28 | alias downloadWindowsIso="$COMMON_UTILS_TOOLS_DIR/download-windows-iso" 29 | alias createAutoStartService="'${SERVICE_MANAGER}' create-autostart-service" 30 | alias removeAutoStartService="'${SERVICE_MANAGER}' remove-autostart-service" 31 | 32 | mkdir -p "${THIRDPARTY_DIR}" 33 | mkdir -p "${VM_FILES_DIR}" 34 | 35 | if [ -f "${DISTRO_UTILS_DIR}/pre-package-info-update" ]; then 36 | "${DISTRO_UTILS_DIR}/pre-package-info-update" 37 | fi 38 | 39 | MISSING_EXECUTABLES="$(getMissingExecutables "$ALL_EXEC_DEPS")" 40 | MISSING_FILES="$(getMissingFiles "$ALL_FILE_DEPS")" 41 | 42 | if [ "$MISSING_EXECUTABLES" != "" ] || [ "$MISSING_FILES" != "" ]; then 43 | echo "> Update package info..." 44 | updatePkgInfo 45 | fi 46 | 47 | if [ -f "${DISTRO_UTILS_DIR}/pre-package-install" ]; then 48 | "${DISTRO_UTILS_DIR}/pre-package-install" 49 | fi 50 | 51 | if [ "$MISSING_EXECUTABLES" != "" ]; then 52 | echo "> Finding and installing packages containing executables that we need..." 53 | getExecPkg "$ALL_EXEC_DEPS" # Find and install packages containing executables that we need 54 | MISSING_EXECUTABLES="$(getMissingExecutables "$ALL_EXEC_DEPS")" 55 | if [ "$MISSING_EXECUTABLES" != "" ]; then 56 | echo "> [Error] Failed to install packages providing the following executables automatically: $MISSING_EXECUTABLES" 57 | fi 58 | else 59 | echo "> [Skipped] Executable dependencies are already installed." 60 | fi 61 | 62 | if [ "$MISSING_FILES" != "" ]; then 63 | echo "> Finding and installing packages containing files that we need..." 64 | getFilePkg "$ALL_FILE_DEPS" # Find and install packages containing specific files that we need 65 | MISSING_FILES="$(getMissingFiles "$ALL_FILE_DEPS")" 66 | if [ "$MISSING_FILES" != "" ]; then 67 | MISSING_FILES="$(echo "$MISSING_EXECUTABLES" | sed 's/\s\+/\n/g')" # replace spaces with new lines 68 | echo "> [Error] Failed to install packages providing the following executables automatically:" 69 | echo "$MISSING_FILES" 70 | fi 71 | else 72 | echo "> [Skipped] File dependencies are already installed." 73 | fi 74 | 75 | if [ "$MISSING_EXECUTABLES" != "" ] || [ "$MISSING_FILES" != "" ]; then 76 | exit 1 77 | fi 78 | 79 | REBOOT_REQUIRED=false 80 | if ! runtimeKernelHasParams "${KERNEL_PARAMS_GENERAL[*]}"; then 81 | echo "> Adding general kernel params..." 82 | addKernelParams "${KERNEL_PARAMS_GENERAL[*]}" 83 | REBOOT_REQUIRED=true 84 | else 85 | echo "> [Skipped] General kernel params already set on running kernel." 86 | fi 87 | 88 | source "$COMMON_UTILS_LIBS_DIR/cpu-check" 89 | source "$COMMON_UTILS_LIBS_DIR/gpu-check" 90 | 91 | #if [ "$HAS_INTEL_CPU" = true ]; then 92 | if ! runtimeKernelHasParams "${KERNEL_PARAMS_INTEL_CPU[*]}"; then 93 | echo "> Adding Intel CPU-specific kernel params..." 94 | addKernelParams "${KERNEL_PARAMS_INTEL_CPU[*]}" 95 | REBOOT_REQUIRED=true 96 | else 97 | echo "> [Skipped] Intel CPU-specific kernel params already set on running kernel." 98 | fi 99 | #fi 100 | 101 | #if [ "$HAS_AMD_CPU" = true ]; then 102 | if ! runtimeKernelHasParams "${KERNEL_PARAMS_AMD_CPU[*]}"; then 103 | echo "> Adding AMD CPU-specific kernel params..." 104 | addKernelParams "${KERNEL_PARAMS_AMD_CPU[*]}" 105 | REBOOT_REQUIRED=true 106 | else 107 | echo "> [Skipped] AMD CPU-specific kernel params already set on running kernel." 108 | fi 109 | #fi 110 | 111 | #if [ "$HAS_INTEL_GPU" = true ]; then 112 | if ! runtimeKernelHasParams "${KERNEL_PARAMS_INTEL_GPU[*]}"; then 113 | echo "> Adding Intel GPU-specific kernel params..." 114 | addKernelParams "${KERNEL_PARAMS_INTEL_GPU[*]}" 115 | REBOOT_REQUIRED=true 116 | else 117 | echo "> [Skipped] Intel GPU-specific kernel params already set on running kernel." 118 | fi 119 | #fi 120 | 121 | #if [ "$HAS_NVIDIA_GPU" = true ]; then # TODO: Don't force Bumblebee and the proprietary Nvidia driver upon the user 122 | # if ! runtimeKernelHasParams "${KERNEL_PARAMS_BUMBLEBEE_NVIDIA[*]}"; then 123 | # echo "> Adding Nvidia GPU-specific kernel params..." 124 | # addKernelParams "${KERNEL_PARAMS_BUMBLEBEE_NVIDIA[*]}" 125 | # REBOOT_REQUIRED=true 126 | # else 127 | # echo "> [Skipped] Nvidia GPU-specific kernel params already set on running kernel." 128 | # fi 129 | #fi 130 | 131 | #if [ "$HAS_NVIDIA_GPU" = true ]; then 132 | # nvidiaSetup 133 | #fi 134 | #if [ "$SUPPORTS_OPTIMUS" = true ]; then 135 | # bumblebeeSetup 136 | #fi 137 | 138 | if [ REBOOT_REQUIRED = true ]; then 139 | echo "> Appling kernel param changes..." 140 | applyKernelParamChanges 141 | fi 142 | 143 | if [ ! -f "${ACPI_TABLES_DIR}/fake-battery.aml" ]; then 144 | echo "> Building fake ACPI SSDT battery..." 145 | buildFakeBatterySsdt 146 | else 147 | echo "> [Skipped] Fake ACPI SSDT battery has already been built." 148 | fi 149 | 150 | if [ ! -f ${THIRDPARTY_DIR}/VBiosFinder/vendor/bundle/ruby/*/bin/coderay ]; then 151 | echo "> Installing VBiosFinder..." 152 | vbiosFinderSetup 153 | else 154 | echo "> [Skipped] VBiosFinder is already set up." 155 | fi 156 | 157 | if [ ! -f "${THIRDPARTY_DIR}/LookingGlass/looking-glass-host.exe" ] || [ ! -f "${THIRDPARTY_DIR}/LookingGlass/client/build/looking-glass-client" ]; then 158 | echo "> Installing Looking Glass..." 159 | lookingGlassSetup 160 | else 161 | echo "> [Skipped] Looking Glass is already set up." 162 | fi 163 | 164 | CHECKSUM_FILE_PATH="$HELPER_ISO_FILES_DIR/.checksum" 165 | PREVIOUS_HELPER_ISO_DIR_CHECKSUM="$(cat "$CHECKSUM_FILE_PATH" 2> /dev/null)" 166 | NEW_HELPER_ISO_DIR_CHECKSUM="$(find "$HELPER_ISO_FILES_DIR" -type f ! -iname ".checksum" -exec md5sum {} + | LC_ALL=C sort | md5sum | cut -d' ' -f1)" 167 | if [ "$PREVIOUS_HELPER_ISO_DIR_CHECKSUM" != "$NEW_HELPER_ISO_DIR_CHECKSUM" ]; then 168 | echo "> Generating helper ISO for auto unattended Windows install, config and driver installation..." 169 | rm -f "$CHECKSUM_FILE_PATH" 170 | generateHelperIso 171 | echo "$NEW_HELPER_ISO_DIR_CHECKSUM" > "$CHECKSUM_FILE_PATH" 172 | else 173 | echo "> [Skipped] Helper ISO for auto unattended Windows install, config and driver installation already generated for the current files." 174 | fi 175 | 176 | if [ ! -f "$INSTALL_IMG" ] || [ $(wc -c <"$INSTALL_IMG") -le 1000000000 ]; then 177 | echo "Downloading Windows ISO from Microsoft now." 178 | rm -f "$INSTALL_IMG" 179 | downloadWindowsIso "$INSTALL_IMG" 180 | else 181 | echo "> [Skipped] Windows ISO has already been downloaded." 182 | fi 183 | 184 | if [[ "$(sudo docker images -q 'tavk/ovmf-vbios-patch:1.0.1-edk2-stable201905' 2> /dev/null)" == "" ]]; then 185 | echo "> Installing 'ovmf-vbios-patch' Docker Image..." 186 | ovmfVbiosPatchSetup 187 | else 188 | echo "> [Skipped] Image 'ovmf-vbios-patch' has already been built." 189 | fi 190 | 191 | if [ "$1" = "auto" ]; then 192 | if [ "$REBOOT_REQUIRED" = true ]; then 193 | echo "> Creating a temporary service that will run on next reboot and continue the installation..." 194 | createAutoStartService "${PROJECT_DIR}/mbpt.sh auto" "MobilePassthroughInitSetup" 195 | echo "> Rebooting in 30 seconds... Press Ctrl+C to cancel." 196 | sleep 30 && sudo shutdown -r 0 197 | else 198 | removeAutoStartService "MobilePassthroughInitSetup" &> /dev/null 199 | echo "> No reboot required." 200 | fi 201 | else 202 | if [ REBOOT_REQUIRED = true ]; then 203 | echo "> Please reboot to load the new kernel parameters!" 204 | else 205 | echo "> No reboot required." 206 | fi 207 | fi 208 | -------------------------------------------------------------------------------- /scripts/utils/common/libs/cpu-check: -------------------------------------------------------------------------------- 1 | ##################################################################################################### 2 | # This script is not meant to be executed. It should be `source`d. 3 | # It creates a bunch of variables telling you what kinds of CPUs the system has. 4 | # Use it like this: `source "./cpu-check.sh"` 5 | ##################################################################################################### 6 | 7 | LSCPU_OUTPUT="$(sudo lscpu)" 8 | if echo -e "$LSCPU_OUTPUT" | grep "Model name: " | grep -qi "intel"; then 9 | export HAS_INTEL_CPU=true 10 | fi 11 | 12 | if echo -e "$LSCPU_OUTPUT" | grep "Model name: " | grep -qi "AMD"; then 13 | export HAS_AMD_CPU=true 14 | fi -------------------------------------------------------------------------------- /scripts/utils/common/libs/gpu-check: -------------------------------------------------------------------------------- 1 | ##################################################################################################### 2 | # This script is not meant to be executed. It should be `source`d. 3 | # It creates a bunch of variables telling you what kinds of GPUs the system has. 4 | # Use it like this: `source "./gpu-check.sh"` 5 | ##################################################################################################### 6 | 7 | LSHW_DISPLAY_OUTPUT="$(sudo lshw -C display)" 8 | if echo -e "$LSHW_DISPLAY_OUTPUT" | grep " vendor: " | grep -qi "intel"; then 9 | export HAS_INTEL_GPU=true 10 | fi 11 | 12 | if echo -e "$LSHW_DISPLAY_OUTPUT" | grep " vendor: " | grep -qi "nvidia"; then 13 | export HAS_NVIDIA_GPU=true 14 | fi 15 | 16 | if echo -e "$LSHW_DISPLAY_OUTPUT" | grep " vendor: " | grep -qi "amd"; then 17 | export HAS_AMD_GPU=true 18 | fi 19 | 20 | if [ "$HAS_INTEL_GPU" = true ] && [ "$HAS_NVIDIA_GPU" = true ]; then 21 | export SUPPORTS_OPTIMUS=true 22 | fi 23 | 24 | if [ "$HAS_INTEL_GPU" = true ] && [ "$HAS_AMD_GPU" = true ]; then 25 | export SUPPORTS_DRI_PRIME=true 26 | fi 27 | -------------------------------------------------------------------------------- /scripts/utils/common/libs/helpers: -------------------------------------------------------------------------------- 1 | ##################################################################################################### 2 | # This script has to be sourced and is not meant to be executed directly! 3 | # How to use: Insert the following two lines without the `#` symbols below the shebang of all scripts in this project that need it: 4 | # while [[ "$PROJECT_DIR" != */MobilePassThrough ]]; do PROJECT_DIR="$(readlink -f "$(dirname "${PROJECT_DIR:-0}")")"; done 5 | # source "$PROJECT_DIR/scripts/utils/common/libs/helpers" 6 | ##################################################################################################### 7 | 8 | 9 | SCRIPTS_DIR="${PROJECT_DIR}/scripts" 10 | MAIN_SCRIPTS_DIR="${SCRIPTS_DIR}/main" 11 | UTILS_DIR="${SCRIPTS_DIR}/utils" 12 | COMMON_UTILS_DIR="${UTILS_DIR}/common" 13 | COMMON_UTILS_LIBS_DIR="${COMMON_UTILS_DIR}/libs" 14 | COMMON_UTILS_PLUGINS_DIR="${COMMON_UTILS_DIR}/plugins" 15 | COMMON_UTILS_SETUP_DIR="${COMMON_UTILS_DIR}/setup" 16 | COMMON_UTILS_TOOLS_DIR="${COMMON_UTILS_DIR}/tools" 17 | DISTRO_UTILS_DIR="${UTILS_DIR}/distro-specific/$("${COMMON_UTILS_TOOLS_DIR}/distro-info" --exclude-version)" 18 | DISTRO_VERSION_UTILS_DIR="${UTILS_DIR}/distro-specific/$("${COMMON_UTILS_TOOLS_DIR}/distro-info")" 19 | MANAGER_UTILS_DIR="${UTILS_DIR}/manager-specific" 20 | INITRAMFS_MANAGER="${MANAGER_UTILS_DIR}/initramfs/$(sudo "${COMMON_UTILS_TOOLS_DIR}/get-manager" initramfs)" 21 | SERVICE_MANAGER="${MANAGER_UTILS_DIR}/service/$("${COMMON_UTILS_TOOLS_DIR}/get-manager" service)" 22 | KERNEL_PARAM_MANAGER="${MANAGER_UTILS_DIR}/kernelparams/$(sudo "${COMMON_UTILS_TOOLS_DIR}/get-manager" kernelparams)" 23 | PACKAGE_MANAGER="${MANAGER_UTILS_DIR}/package/$("${COMMON_UTILS_TOOLS_DIR}/get-manager" package)" 24 | GUI_TERMINAL="${MANAGER_UTILS_DIR}/gui-terminal/$("${COMMON_UTILS_TOOLS_DIR}/get-manager" gui-terminal)" 25 | THIRDPARTY_DIR="${PROJECT_DIR}/thirdparty" 26 | ACPI_TABLES_DIR="${PROJECT_DIR}/acpi-tables" 27 | HELPER_ISO_FILES_DIR="${PROJECT_DIR}/helper-iso-files" 28 | LIVE_ISO_FILES_DIR="${PROJECT_DIR}/live-iso-files" 29 | LOG_BASE_DIR="${PROJECT_DIR}/logs" 30 | 31 | C_NC='\033[0m' # No Color 32 | C_RED='\033[0;31m' 33 | C_GREEN='\033[0;32m' 34 | C_ORANGE='\033[1;33m' 35 | 36 | function echo_red() { 37 | echo -e "${C_RED}$@${C_NC}" 38 | } 39 | function echo_green() { 40 | echo -e "${C_GREEN}$@${C_NC}" 41 | } 42 | function echo_orange() { 43 | echo -e "${C_ORANGE}$@${C_NC}" 44 | } 45 | function echo_white() { 46 | echo -e "$@" 47 | } 48 | 49 | function loadConfig() { 50 | # If user.conf doesn't exist use the default.conf 51 | if [ -f "${PROJECT_DIR}/user.conf" ]; then 52 | #echo "> Loading config from ${PROJECT_DIR}/user.conf" 53 | source "${PROJECT_DIR}/user.conf" 54 | elif [ -f "${PROJECT_DIR}/default.conf" ]; then 55 | #echo "> Warning: No user.conf found, falling back to default.conf" 56 | #echo "> Loading config from ${PROJECT_DIR}/default.conf" 57 | source "${PROJECT_DIR}/default.conf" 58 | else 59 | #echo "> Error: No user.conf or user.conf found!" 60 | exit 61 | fi 62 | } 63 | 64 | shopt -s expand_aliases 65 | -------------------------------------------------------------------------------- /scripts/utils/common/plugins/display-mode-1: -------------------------------------------------------------------------------- 1 | ##################################################################################################### 2 | # This script has to be sourced and is not meant to be executed directly! 3 | # It sets the display output configuration. 4 | # How to use: 5 | # source "$PLUGIN_DIR/display-mode-x" 6 | ##################################################################################################### 7 | 8 | if [ "$DMA_BUF_AVAILABLE" = true ]; then 9 | USE_QXL=false 10 | USE_DMA_BUF=true 11 | USE_RDP=false 12 | if [ "$VM_ACTION" = "start" ]; then 13 | USE_LOOKING_GLASS=true 14 | elif [ "$VM_ACTION" = "install" ]; then 15 | USE_LOOKING_GLASS=false 16 | fi 17 | else 18 | USE_DMA_BUF=false 19 | USE_RDP=true 20 | if [ "$VM_ACTION" = "install" ]; then 21 | USE_QXL=true 22 | USE_LOOKING_GLASS=false 23 | elif [ "$VM_ACTION" = "start" ]; then 24 | USE_QXL=false 25 | USE_LOOKING_GLASS=true 26 | fi 27 | fi -------------------------------------------------------------------------------- /scripts/utils/common/plugins/display-mode-2: -------------------------------------------------------------------------------- 1 | ##################################################################################################### 2 | # This script has to be sourced and is not meant to be executed directly! 3 | # It sets the display output configuration. 4 | # How to use: 5 | # source "$PLUGIN_DIR/display-mode-x" 6 | ##################################################################################################### 7 | 8 | RDP=true 9 | if [ "$DMA_BUF_AVAILABLE" = true ]; then 10 | USE_LOOKING_GLASS=true 11 | USE_DMA_BUF=true 12 | USE_QXL=false 13 | else 14 | USE_DMA_BUF=false 15 | if [ "$VM_ACTION" = "install" ]; then 16 | USE_QXL=true 17 | USE_LOOKING_GLASS=false 18 | elif [ "$VM_ACTION" = "start" ]; then 19 | USE_QXL=false 20 | USE_LOOKING_GLASS=true 21 | fi 22 | fi -------------------------------------------------------------------------------- /scripts/utils/common/plugins/display-mode-3: -------------------------------------------------------------------------------- 1 | ##################################################################################################### 2 | # This script has to be sourced and is not meant to be executed directly! 3 | # It sets the display output configuration. 4 | # How to use: 5 | # source "$PLUGIN_DIR/display-mode-x" 6 | ##################################################################################################### 7 | 8 | if [ "$VM_ACTION" = "install" ]; then 9 | USE_LOOKING_GLASS=false 10 | USE_RDP=false 11 | if [ "$DMA_BUF_AVAILABLE" = true ]; then 12 | USE_DMA_BUF=true 13 | USE_QXL=false 14 | elif [ "$VM_ACTION" = "start" ]; then 15 | USE_DMA_BUF=false 16 | USE_QXL=true 17 | fi 18 | else 19 | USE_SPICE_CLIENT=true 20 | USE_LOOKING_GLASS=true 21 | USE_RDP=true 22 | USE_QXL=true 23 | USE_DMA_BUF=false 24 | fi -------------------------------------------------------------------------------- /scripts/utils/common/plugins/display-mode-4: -------------------------------------------------------------------------------- 1 | ##################################################################################################### 2 | # This script has to be sourced and is not meant to be executed directly! 3 | # It sets the display output configuration. 4 | # How to use: 5 | # source "$PLUGIN_DIR/display-mode-x" 6 | ##################################################################################################### 7 | 8 | USE_LOOKING_GLASS=false 9 | 10 | if [ "$VM_ACTION" = "start" ]; then 11 | USE_RDP=true 12 | elif [ "$VM_ACTION" = "install" ]; then 13 | USE_RDP=false 14 | fi 15 | 16 | if [ "$DMA_BUF_AVAILABLE" = true ]; then 17 | USE_QXL=false 18 | USE_DMA_BUF=true 19 | else 20 | USE_DMA_BUF=false 21 | USE_RDP=true 22 | fi -------------------------------------------------------------------------------- /scripts/utils/common/plugins/display-mode-5: -------------------------------------------------------------------------------- 1 | ##################################################################################################### 2 | # This script has to be sourced and is not meant to be executed directly! 3 | # It sets the display output configuration. 4 | # How to use: 5 | # source "$PLUGIN_DIR/display-mode-x" 6 | ##################################################################################################### 7 | 8 | if [ "$VM_ACTION" = "install" ]; then 9 | USE_LOOKING_GLASS=false 10 | USE_RDP=false 11 | if [ "$DMA_BUF_AVAILABLE" = true ]; then 12 | USE_DMA_BUF=true 13 | USE_QXL=false 14 | elif [ "$VM_ACTION" = "start" ]; then 15 | USE_DMA_BUF=false 16 | USE_QXL=true 17 | fi 18 | else 19 | USE_SPICE_CLIENT=true 20 | USE_LOOKING_GLASS=true 21 | USE_RDP=true 22 | USE_QXL=false 23 | USE_DMA_BUF=false 24 | fi -------------------------------------------------------------------------------- /scripts/utils/common/setup/build-fake-battery-ssdt: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | while [[ "$PROJECT_DIR" != */MobilePassThrough ]]; do PROJECT_DIR="$(readlink -f "$(dirname "${PROJECT_DIR:-0}")")"; done 3 | source "$PROJECT_DIR/scripts/utils/common/libs/helpers" 4 | 5 | ##################################################################################################### 6 | # This script compiles the asm source code for the SSDT table that contains a fake battery for the VM. 7 | # Usage: `./build-fake-battery-ssdt` 8 | ##################################################################################################### 9 | 10 | iasl "${ACPI_TABLES_DIR}/fake-battery.asl" # creates fake-battery.aml -------------------------------------------------------------------------------- /scripts/utils/common/setup/extract-vbios: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | while [[ "$PROJECT_DIR" != */MobilePassThrough ]]; do PROJECT_DIR="$(readlink -f "$(dirname "${PROJECT_DIR:-0}")")"; done 3 | source "$PROJECT_DIR/scripts/utils/common/libs/helpers" 4 | 5 | 6 | ##################################################################################################### 7 | # WARNING: THIS SCRIPT WORKS ON ALMOST NO SYSTEM 8 | # This script tries to extract the vBIOS ROM form your dGPU. 9 | # usage: `./extract-vbios` 10 | ##################################################################################################### 11 | 12 | function extractNvidiaVbios() { 13 | if which optirun ; then 14 | USE_BUMBLEBEE=true 15 | OPTIRUN_PREFIX="optirun " 16 | else 17 | USE_BUMBLEBEE=false 18 | OPTIRUN_PREFIX="" 19 | fi 20 | if [ ! -f "${UTILS_DIR}/nvflash_linux" ]; then 21 | NVFLASH_DOWNLOAD_ID=$(curl https://www.techpowerup.com/download/nvidia-nvflash/ | grep '_linux.zip' -A 5 | grep 'name="id" value="' | cut -d '"' -f6) 22 | wget --post-data "id=${NVFLASH_DOWNLOAD_ID}&server_id=2" https://www.techpowerup.com/download/nvidia-nvflash/ -O ${THIRDPARTY_DIR}/nvidia-nvflash.zip 23 | unzip ${THIRDPARTY_DIR}/nvidia-nvflash.zip -d ${THIRDPARTY_DIR}/ 24 | rm -f ${THIRDPARTY_DIR}/nvidia-nvflash.zip 25 | chmod +x ${THIRDPARTY_DIR}/nvflash_linux 26 | fi 27 | mkdir -p "${VM_FILES_DIR}/vbios-roms" 28 | sudo ${OPTIRUN_PREFIX}${THIRDPARTY_DIR}/nvflash_linux --save ${VM_FILES_DIR}/vbios-roms/nvidia_vbios.rom 29 | } 30 | 31 | function extractVbios() { 32 | PCI_ADDRESS="$1" 33 | OUTPUT_AS="$1" 34 | sudo bash -c "echo 1 > /sys/bus/pci/devices/0000:${PCI_ADDRESS}/rom" 35 | sudo cat /sys/bus/pci/devices/0000:${PCI_ADDRESS}/rom > ${OUTPUT_AS} 36 | sudo bash -c "echo 0 > /sys/bus/pci/devices/0000:${PCI_ADDRESS}/rom" 37 | } 38 | 39 | #echo "Attempting to extract the VBIOS ROM of the Nvidia GPU" 40 | #echo "This will probably fail. If you know how to fix it please open an issue and tell me." 41 | #extractNvidiaVbios 42 | extractVbios $1 $2 -------------------------------------------------------------------------------- /scripts/utils/common/setup/looking-glass-setup: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | while [[ "$PROJECT_DIR" != */MobilePassThrough ]]; do PROJECT_DIR="$(readlink -f "$(dirname "${PROJECT_DIR:-0}")")"; done 3 | source "$PROJECT_DIR/scripts/utils/common/libs/helpers" 4 | loadConfig 5 | 6 | LOOKING_GLASS_VERSION="B4" 7 | cd "${THIRDPARTY_DIR}" 8 | 9 | if [ ! -f "./LookingGlass" ]; then 10 | # Get the source code 11 | git clone --single-branch --branch "${LOOKING_GLASS_VERSION}" --depth 1 --recursive https://github.com/gnif/LookingGlass.git 12 | fi 13 | CURRENT_LG_VERSION="$(cd LookingGlass && git branch --show-current)" 14 | if [ "$CURRENT_LG_VERSION" != "$LOOKING_GLASS_VERSION" ]; then 15 | # If an old version of Looking Glass is detected, delete the old source code and get a clean copy of the required one 16 | rm -rf LookingGlass 17 | git clone --single-branch --branch "${LOOKING_GLASS_VERSION}" --depth 1 --recursive https://github.com/gnif/LookingGlass.git 18 | fi 19 | 20 | # Clean up (remove old builds etc.) 21 | git clean -fdx 22 | 23 | # Build the (Linux) client application 24 | mkdir LookingGlass/client/build 25 | cd LookingGlass/client/build 26 | cmake ../ 27 | make 28 | 29 | # Utilize systemd-tmpfiles to automatically set required permissions on /dev/shm/looking-glass 30 | sudo bash -c "echo '#Type Path Mode UID GID Age Argument' > /etc/tmpfiles.d/10-looking-glass.conf" 31 | sudo bash -c "echo 'f /dev/shm/looking-glass 0660 $(logname) kvm - ' >> /etc/tmpfiles.d/10-looking-glass.conf" 32 | sudo systemd-tmpfiles --create /etc/tmpfiles.d/10-looking-glass.conf 33 | 34 | # Adjust permissions for systems with AppArmor 35 | if [ -d "/etc/apparmor.d" ]; then 36 | if ! sudo cat /etc/apparmor.d/local/abstractions/libvirt-qemu | grep --quiet '/dev/shm/looking-glass rw,'; then 37 | sudo bash -c "echo '/dev/shm/looking-glass rw,' >> /etc/apparmor.d/local/abstractions/libvirt-qemu" 38 | sudo systemctl restart apparmor 39 | fi 40 | fi 41 | 42 | # Adjust permissions for systems with SELinux 43 | if [ -d "/etc/selinux" ]; then 44 | TE_FILE="./lookingglass-fix-qemu.te" 45 | MOD_FILE="./lookingglass-fix-qemu.mod" 46 | PP_FILE="./lookingglass-fix-qemu.pp" 47 | echo "module lookingglass-fix-qemu 1.0;" > "${TE_FILE}" 48 | echo "" >> "${TE_FILE}" 49 | echo "require {" >> "${TE_FILE}" 50 | echo " type tmpfs_t;" >> "${TE_FILE}" 51 | echo " type svirt_t;" >> "${TE_FILE}" 52 | echo " class file { getattr map open };" >> "${TE_FILE}" 53 | echo "}" >> "${TE_FILE}" 54 | echo "" >> "${TE_FILE}" 55 | echo "#============= svirt_t ==============" >> "${TE_FILE}" 56 | echo "allow svirt_t tmpfs_t:file { getattr open };" >> "${TE_FILE}" 57 | echo "" >> "${TE_FILE}" 58 | echo "#!!!! This avc can be allowed using the boolean 'domain_can_mmap_files'" >> "${TE_FILE}" 59 | echo "allow svirt_t tmpfs_t:file map;" >> "${TE_FILE}" 60 | 61 | checkmodule -M -m -o "${MOD_FILE}" "${TE_FILE}" 62 | semodule_package -o "${PP_FILE}" -m "${MOD_FILE}" 63 | sudo semodule -i "${PP_FILE}" 64 | fi 65 | 66 | # Download the Nvidia Capture SDK if it hasn'T been downlaoded already 67 | cd "${THIRDPARTY_DIR}" 68 | if [ ! -f "./Capture_Linux_v8.0.4" ]; then 69 | wget https://developer.nvidia.com/capture_sdk/downloads/v8.0.4/linux -O ./nvidia_capture_api.tgz 70 | #rm -rf ./Capture_Linux_v8.0.4 71 | tar -xvzf ./nvidia_capture_api.tgz 72 | rm ./nvidia_capture_api.tgz 73 | fi 74 | 75 | # Build the (Windows) host application 76 | cp ./Capture_Linux_v8.0.4 ./LookingGlass/ 77 | cd LookingGlass 78 | cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_TOOLCHAIN_FILE=./host/toolchain-mingw64.cmake -DNVFBC_SDK='./Capture_Linux_v8.0.4' -DUSE_NVFBC=1 ./host 79 | make 80 | 81 | #wget "https://ci.appveyor.com/api/projects/rainers/visuald/artifacts/cv2pdb.exe?job=Environment%3A%20os%3DVisual%20Studio%202015%2C%20VS%3D14%2C%20APPVEYOR_BUILD_WORKER_IMAGE%3DVisual%20Studio%202015" -O "cv2pdb.exe" 82 | #wine './cv2pdb.exe' './looking-glass-host.exe' 83 | makensis './platform/Windows/installer.nsi' -------------------------------------------------------------------------------- /scripts/utils/common/setup/ovmf-vbios-patch-setup: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | while [[ "$PROJECT_DIR" != */MobilePassThrough ]]; do PROJECT_DIR="$(readlink -f "$(dirname "${PROJECT_DIR:-0}")")"; done 3 | source "$PROJECT_DIR/scripts/utils/common/libs/helpers" 4 | 5 | ##################################################################################################### 6 | # This script builds a Docker image that allows us to patch OVMF_CODE.fd and OVMF_VARS.fd with your vBIOS ROM. 7 | # This helps circumvent Nvidia's Error 43 in some cases. 8 | # Usage: `./ovmf-vbios-patch-setup` 9 | ##################################################################################################### 10 | 11 | cd "${THIRDPARTY_DIR}" 12 | 13 | sudo service docker start 14 | #rm -rf ovmf-with-vbios-patch 15 | #git clone https://github.com/T-vK/ovmf-with-vbios-patch.git 16 | #cd ovmf-with-vbios-patch 17 | #sudo docker build -t ovmf-vbios-patch . 18 | sudo docker pull 'tavk/ovmf-vbios-patch:1.0.1-edk2-stable201905' # Pull instead of build because the root partition of the Live version is too small. 19 | # TODO: Get rid of Docker and build this thing natively -------------------------------------------------------------------------------- /scripts/utils/common/setup/vbios-finder-setup: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | while [[ "$PROJECT_DIR" != */MobilePassThrough ]]; do PROJECT_DIR="$(readlink -f "$(dirname "${PROJECT_DIR:-0}")")"; done 3 | source "$PROJECT_DIR/scripts/utils/common/libs/helpers" 4 | loadConfig 5 | 6 | cd "${THIRDPARTY_DIR}" 7 | 8 | rm -rf VBiosFinder 9 | git clone https://github.com/coderobe/VBiosFinder.git 10 | git checkout c2d764975115de466fdb4963d7773b5bc8468a06 11 | cd VBiosFinder 12 | 13 | wget https://github.com/LongSoft/UEFITool/releases/download/A58/UEFIExtract_NE_A58_linux_x86_64.zip -O ./UEFIExtract.zip 14 | unzip ./UEFIExtract.zip -d ./3rdparty/ 15 | rm -f ./UEFIExtract.zip 16 | 17 | git clone https://github.com/awilliam/rom-parser.git 18 | cd rom-parser 19 | git checkout 94a615302f89b94e70446270197e0f5138d678f3 20 | 21 | bundle install --path=vendor/bundle 22 | gem install bundler:1.17.3 23 | 24 | make 25 | mv ./rom-fixer ../3rdparty/ 26 | mv ./rom-parser ../3rdparty/ 27 | cd .. 28 | 29 | bundle install --path=vendor/bundle 30 | -------------------------------------------------------------------------------- /scripts/utils/common/tools/commands-available: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | ##################################################################################################### 4 | # Checks if all given commands are installed and if not print out the list of missing ones 5 | # Usage: `./commands-available` 6 | ##################################################################################################### 7 | 8 | function commandsAvailable() { 9 | commandsMissing=() 10 | for currentCommand in $1; do 11 | if ! command -v $currentCommand &> /dev/null; then 12 | commandsMissing+=("$currentCommand") 13 | fi 14 | done 15 | if ((${#commandsMissing[@]})); then 16 | echo "Missing commands: ${commandsMissing[@]}" 17 | return 1 # Some commands are missing 18 | else 19 | return 0 20 | fi 21 | } 22 | 23 | commandsAvailable "$1" -------------------------------------------------------------------------------- /scripts/utils/common/tools/distro-info: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | ##################################################################################################### 4 | # Determines which Linux distribution and version this is and echoes it out 5 | # Usage: `./distro-info` 6 | ##################################################################################################### 7 | 8 | if [ -f /etc/os-release ]; then 9 | # freedesktop.org and systemd 10 | . /etc/os-release 11 | OS=$NAME 12 | VER=$VERSION_ID 13 | elif type lsb_release >/dev/null 2>&1; then 14 | # linuxbase.org 15 | OS=$(lsb_release -si) 16 | VER=$(lsb_release -sr) 17 | elif [ -f /etc/lsb-release ]; then 18 | # For some versions of Debian/Ubuntu without lsb_release command 19 | . /etc/lsb-release 20 | OS=$DISTRIB_ID 21 | VER=$DISTRIB_RELEASE 22 | elif [ -f /etc/debian_version ]; then 23 | # Older Debian/Ubuntu/etc. 24 | OS=Debian 25 | VER=$(cat /etc/debian_version) 26 | elif [ -f /etc/SuSe-release ]; then 27 | # Older SuSE/etc. 28 | #... 29 | : 30 | elif [ -f /etc/redhat-release ]; then 31 | # Older Red Hat, CentOS, etc. 32 | #... 33 | : 34 | else 35 | # Fall back to uname, e.g. "Linux <version>", also works for BSD, etc. 36 | OS=$(uname -s) 37 | VER=$(uname -r) 38 | fi 39 | 40 | if [ "$1" = "--exclude-version" ]; then 41 | echo "${OS}" 42 | else 43 | echo "${OS}/${VER}" 44 | fi 45 | -------------------------------------------------------------------------------- /scripts/utils/common/tools/download-windows-iso: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | ##################################################################################################### 4 | # Downloads a Windows 10 ISO from Microsoft 5 | # Usage: `./download-windows-iso "/path/to/where/you/want/to/save/the/windows.iso" "x64"` 6 | ##################################################################################################### 7 | 8 | WIN10_IMG_DESTINATION="$1" 9 | WIN10_IMG_ARCH="$2" 10 | echo "$WIN10_IMG_DESTINATION" 11 | 12 | if [[ "$WIN10_IMG_ARCH" == "x86" ]] || [[ "$WIN10_IMG_ARCH" == "i386" ]] ; then 13 | echo "Retrieving the x86 Windows 10 iso URL..." 14 | WINDOWS_10_ISO_URL=$(curl -LsI -o /dev/null -w %{url_effective} "https://tb.rg-adguard.net/dl.php?go=7e583fea") 15 | else 16 | echo "Retrieving the x64 Windows 10 iso URL..." 17 | WINDOWS_10_ISO_URL=$(curl -LsI -o /dev/null -w %{url_effective} "https://tb.rg-adguard.net/dl.php?go=3dd1ce66") 18 | fi 19 | 20 | echo "$WINDOWS_10_ISO_URL" 21 | echo "Making sure the URL comes from a trusted Microsoft domain..." 22 | if [[ $WINDOWS_10_ISO_URL == https://*.microsoft.com/* ]] ; then 23 | echo "Downloading the Windows 10 installation iso..." 24 | if [ ! -f "${WIN10_IMG_DESTINATION}" ]; then 25 | if wget "${WINDOWS_10_ISO_URL}" --no-check-certificate -c -O "${WIN10_IMG_DESTINATION}.part"; then 26 | mv "${WIN10_IMG_DESTINATION}.part" "${WIN10_IMG_DESTINATION}" 27 | else 28 | echo "Download failed. Please try again or download the Windows 10 iso manually." 29 | exit 1 30 | fi 31 | else 32 | echo "Skipping download because the Windows ISO already exists: ${WIN10_IMG_DESTINATION}" 33 | fi 34 | else 35 | echo "URL validation failed. Please download the Windows 10 iso manually." 36 | exit 1 37 | fi 38 | -------------------------------------------------------------------------------- /scripts/utils/common/tools/driver-util: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | ##################################################################################################### 4 | # A simple tool to make driverbinding easy. 5 | # Usage: `./driver-util --help` 6 | ##################################################################################################### 7 | 8 | COMMAND="$1" 9 | 10 | # Get driver currently used by the given PCI device 11 | # Parameter 1: PCI address of the device (format: XX:XX.X) 12 | # stdout: The name of the driver 13 | # returns: 0 on success; 1 on error 14 | function get() { 15 | local PCI_ADDRESS="$1" 16 | sudo lspci -k | grep -A 4 "${PCI_ADDRESS}" | grep -oP "Kernel driver in use: \K.+" | head -1 17 | } 18 | 19 | # Bind the given driver to the given PCI device 20 | # Parameter 1: PCI address of the device (format: XX:XX.X) 21 | # Parameter 2: Name of the driver (As shown in lspci -vvv) 22 | # returns: 0 on success; 1 on error 23 | function bind() { 24 | local PCI_ADDRESS="$1" 25 | local DRIVER="$2" 26 | local CURRENT_DRIVER="$(get "${PCI_ADDRESS}")" 27 | 28 | if [ "$CURRENT_DRIVER" != "" ]; then 29 | if [ "$CURRENT_DRIVER" = "$DRIVER" ]; then 30 | return 0 31 | else 32 | unbind "${PCI_ADDRESS}" "${CURRENT_DRIVER}" 33 | fi 34 | fi 35 | 36 | if ! sudo bash -c "echo '0000:${PCI_ADDRESS}' > '/sys/bus/pci/drivers/${DRIVER}/bind'" &> /dev/null ; then 37 | local IDS=$(sudo lspci -n -s "${PCI_ADDRESS}" | grep -oP "\w+:\w+" | tail -1) 38 | local VENDOR_ID=$(echo "${IDS}" | cut -d ":" -f1) 39 | local DEVICE_ID=$(echo "${IDS}" | cut -d ":" -f2) 40 | sudo bash -c "echo '${VENDOR_ID} ${DEVICE_ID}' > '/sys/bus/pci/drivers/${DRIVER}/new_id'" 41 | fi 42 | #sudo bash -c "echo 'options vfio-pci ids=${VENDOR_ID}:${DEVICE_ID}' > '/etc/modprobe.d/vfio.conf'" 43 | #sudo bash -c "echo '8086:1901' > '/sys/bus/pci/drivers/${DRIVER}/new_id'" 44 | } 45 | 46 | # Unbind the driver of the given PCI device 47 | # Parameter 1: PCI address of the device (format: XX:XX.X) 48 | # Parameter 2 (optional): Name of the driver (As shown in lspci -vvv) 49 | # returns: 0 on success; 1 on error 50 | function unbind() { 51 | local PCI_ADDRESS="$1" 52 | local DRIVER="$2" 53 | if [ "$DRIVER" = "" ]; then 54 | DRIVER="$(get "${PCI_ADDRESS}")" 55 | fi 56 | if [ "$DRIVER" != "" ]; then 57 | sudo bash -c "echo '0000:${PCI_ADDRESS}' > '/sys/bus/pci/drivers/${DRIVER}/unbind'" 58 | #sudo bash -c "echo '0000:${PCI_ADDRESS}' > '/sys/bus/pci/devices/0000:${PCI_ADDRESS}/driver/unbind'" 59 | #sudo bash -c "echo '0000:${DGPU_PCI_ADDRESS}' > '/sys/bus/pci/drivers/vfio-pci/0000:${DGPU_PCI_ADDRESS}/driver/unbind'" 60 | fi 61 | } 62 | 63 | if [ "$COMMAND" = "help" ] || [ "$COMMAND" = "--help" ] || [ "$COMMAND" = "-h" ]; then 64 | COMMAND="$2" 65 | if [ "$COMMAND" = "" ]; then 66 | echo "driver-util [OPTIONS] COMMAND [ARG...]" 67 | echo "driver-util [ -h | --help | -v | --version ]" 68 | echo "" 69 | echo "A simple tool to make driver binding easy." 70 | echo "" 71 | echo "Options:" 72 | echo " -h, --help Print usage" 73 | echo " -v, --version Print version information" 74 | echo "" 75 | echo "Commands:" 76 | echo " get Get driver currently used by the given PCI device" 77 | echo " bind Bind the given driver to the given PCI device" 78 | echo " unbind Unbind the driver of the given PCI device" 79 | echo "" 80 | echo "Examples:" 81 | echo " #Get the active driver of the device with address 02:00.0" 82 | echo " driver-util get 02:00.0" 83 | echo "" 84 | echo " #Unbind the active driver of the device with address 01:00.0" 85 | echo " driver-util unbind 01:00.0" 86 | echo "" 87 | echo " #Bind the vfio-pci driver to the device with address 01:00.0" 88 | echo " driver-util bind 01:00.0 vfio-pci" 89 | else 90 | if [ "$COMMAND" = "bind" ]; then 91 | echo 'driver-util bind <PCI_ADDRESS> <DRIVER_NAME>' 92 | echo "" 93 | echo "Bind the given driver to the given PCI device" 94 | echo "" 95 | echo "Parameters:" 96 | echo ' PCI_ADDRESS PCI address of the device (format: XX:XX.X)' 97 | echo ' DRIVER_NAME Name of the driver (As shown in lspci -vvv)' 98 | echo "" 99 | echo "Examples:" 100 | echo " #Bind the vfio-pci driver to the device with address 01:00.0" 101 | echo " driver-util bind 01:00.0 vfio-pci" 102 | echo "" 103 | echo " #Bind the nvidia driver to the device with address 05:00.0" 104 | echo " driver-util bind 05:00.0 nvidia" 105 | echo "" 106 | echo " #Bind the amdgpu driver to the device with address 02:00.0" 107 | echo " driver-util bind 02:00.0 amdgpu" 108 | elif [ "$COMMAND" = "unbind" ]; then 109 | echo 'driver-util unbind <PCI_ADDRESS> [DRIVER_NAME]' 110 | echo "" 111 | echo "Unbind the driver of the given PCI device" 112 | echo "" 113 | echo "Parameters:" 114 | echo ' PCI_ADDRESS PCI address of the device (format: XX:XX.X)' 115 | echo ' DRIVER_NAME Name of the driver (As shown in lspci -vvv)' 116 | echo "" 117 | echo "Examples:" 118 | echo " #Unbind the vfio-pci driver from the device with address 01:00.0" 119 | echo " driver-util unbind 01:00.0 vfio-pci" 120 | echo "" 121 | echo " #Unbind the active driver of the device with address 03:00.0" 122 | echo " driver-util unbind 03:00.0" 123 | echo "" 124 | echo " #Unbind the amdgpu driver from the device with address 02:00.0" 125 | echo " driver-util unbind 02:00.0 amdgpu" 126 | elif [ "$COMMAND" = "get" ]; then 127 | echo 'driver-util get <PCI_ADDRESS>' 128 | echo "" 129 | echo "Get driver currently used by the given PCI device" 130 | echo "" 131 | echo "Parameters:" 132 | echo ' PCI_ADDRESS PCI address of the device (format: XX:XX.X)' 133 | echo "" 134 | echo "Examples:" 135 | echo " #Get the active driver of the device with address 02:00.0" 136 | echo " driver-util get 02:00.0" 137 | echo "" 138 | echo " #Get the active driver of the device with address 01:00.0" 139 | echo " driver-util get 01:00.0" 140 | fi 141 | fi 142 | elif [ "$COMMAND" = "bind" ]; then 143 | bind "${@:2}" 144 | elif [ "$COMMAND" = "unbind" ]; then 145 | unbind "${@:2}" 146 | elif [ "$COMMAND" = "get" ]; then 147 | get "${@:2}" 148 | fi -------------------------------------------------------------------------------- /scripts/utils/common/tools/get-manager: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | ##################################################################################################### 4 | # Determines how the system manages initramfs, packages, kernel parameters and services 5 | # Usage: `./get-manager service` # supports service, initramfs, kernelparams, package 6 | ##################################################################################################### 7 | 8 | COMMAND="$1" 9 | 10 | if [ "$COMMAND" = "service" ]; then 11 | if command -v "systemctl" &> /dev/null; then 12 | echo "systemd" 13 | elif command -v "service" &> /dev/null; then 14 | echo "service" 15 | elif command -v "initctl" &> /dev/null; then 16 | echo "initctl" 17 | #elif [ -d "/etc/init.d/" ] && command -v "service" &> /dev/null; then 18 | # echo "sysvinit" 19 | else 20 | exit 1 21 | fi 22 | elif [ "$COMMAND" = "initramfs" ]; then 23 | if [ -d "/etc/dracut.conf.d/" ]; then 24 | echo "dracut" 25 | else 26 | exit 1 27 | fi 28 | elif [ "$COMMAND" = "kernelparams" ]; then 29 | if [ -f "/etc/default/grub" ]; then 30 | echo "grub" 31 | else 32 | exit 1 33 | fi 34 | elif [ "$COMMAND" = "package" ]; then 35 | if command -v dnf &> /dev/null; then 36 | echo "dnf" 37 | elif command -v yum &> /dev/null; then 38 | echo "yum" 39 | elif command -v apt-get &> /dev/null; then 40 | echo "apt" 41 | elif command -v pacman &> /dev/null; then 42 | echo "pacman" 43 | elif command -v zypper &> /dev/null; then 44 | echo "zypper" 45 | elif command -v emerge &> /dev/null; then 46 | echo "emerge" 47 | else 48 | exit 1 49 | fi 50 | elif [ "$COMMAND" = "gui-terminal" ]; then 51 | if command -v gnome-terminal &> /dev/null; then 52 | echo "gnome-terminal" 53 | elif command -v konsole &> /dev/null; then 54 | echo "konsole" 55 | elif command -v x-terminal-emulator &> /dev/null; then 56 | echo "x-terminal-emulator" 57 | elif command -v st &> /dev/null; then 58 | echo "st" 59 | else 60 | exit 1 61 | fi 62 | fi 63 | -------------------------------------------------------------------------------- /scripts/utils/common/tools/get-missing-executables: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | ##################################################################################################### 4 | # Simple script to check which executables in a given list are not installed 5 | # Usage: `./get-missing-executables "curl git wget docker"` 6 | ##################################################################################################### 7 | 8 | function getMissingExecutables() { 9 | EXECUTABLES_MISSING="" 10 | for CURRENT_EXECUTABLE in $1; do 11 | if ! command -v $CURRENT_EXECUTABLE &> /dev/null; then 12 | EXECUTABLES_MISSING+=" $CURRENT_EXECUTABLE" 13 | fi 14 | done 15 | echo "$EXECUTABLES_MISSING" 16 | } 17 | 18 | getMissingExecutables "$1" -------------------------------------------------------------------------------- /scripts/utils/common/tools/get-missing-files: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | ##################################################################################################### 4 | # Simple script to check which files in a given list do not exist 5 | # Usage: `./get-missing-files "curl git wget docker"` 6 | ##################################################################################################### 7 | 8 | function getMissingFiles() { 9 | FILES_MISSING="" 10 | for CURRENT_FILE in $1; do 11 | if [ ! -f "$CURRENT_FILE" ]; then 12 | FILES_MISSING+=" $CURRENT_FILE" 13 | fi 14 | done 15 | echo "$FILES_MISSING" 16 | } 17 | 18 | getMissingFiles "$1" -------------------------------------------------------------------------------- /scripts/utils/common/tools/lsiommu: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | ##################################################################################################### 4 | # Simple script to list all PCI devices and vGPUs by their IOMMU Group 5 | # Usage: `./lsiommu` 6 | ##################################################################################################### 7 | 8 | shopt -s nullglob 9 | for d in /sys/kernel/iommu_groups/*/devices/*; do 10 | n=${d#*/iommu_groups/*}; n=${n%%/*} 11 | printf 'IOMMU Group %s ' "$n" 12 | if [[ $d =~ "." ]]; then 13 | lspci -nns "${d##*/}" 14 | else 15 | printf "$(readlink -f "${d}" | cut -d'/' -f5- | cut -d':' -f2-) Virtual GPU of: " 16 | lspci -nns "$(basename "$(dirname "$(readlink -f "${d}")")")" | cut -d' ' -f2- 17 | fi 18 | done; 19 | -------------------------------------------------------------------------------- /scripts/utils/common/tools/runtime-kernel-has-params: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | function runtimeKernelHasParam() { 4 | cmdline="$(cat /proc/cmdline)" 5 | [[ $cmdline =~ ^$1.* ]] || [[ $cmdline =~ .*$1$ ]] || [[ $cmdline = *" $1 "* ]] 6 | } 7 | 8 | function runtimeKernelHasParams() { 9 | for param in $1; do 10 | runtimeKernelHasParam "$param" 11 | done 12 | } 13 | 14 | runtimeKernelHasParams "$1" -------------------------------------------------------------------------------- /scripts/utils/common/tools/vgpu-util: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | ##################################################################################################### 4 | # Simple tool to manage vGPUs more easily 5 | # Usage: `./vgpu-tool` 6 | ##################################################################################################### 7 | 8 | COMMAND="$1" 9 | 10 | # Load required kernel modules 11 | # returns: 0 on success; 1 on error 12 | function init() { 13 | sudo modprobe kvmgt #sudo modprobe xengt 14 | sudo modprobe vfio-mdev 15 | sudo modprobe vfio-iommu-type1 16 | } 17 | 18 | # Get currently existing vGPU ID(s) 19 | # Parameter 1: PCI address of Intel GPU (format: XX:XX.X) 20 | # Parameter 2 (optional): UUID of the vGPU (Leave empty to list all associated vGPUs) 21 | # stdout: vGPU UUID(s) (One per line) 22 | # returns: 0 on success; 1 on error 23 | function get() { 24 | local PCI_ADDRESS="$1" 25 | local VGPU_UUID="$2" 26 | if [ "$VGPU_UUID" = "" ]; then 27 | find "/sys/bus/pci/devices/0000:${PCI_ADDRESS}/" -maxdepth 1 -type d -name "*-*-*-*" -execdir basename {} ';' 28 | return 0 29 | fi 30 | if [ -f "/sys/bus/pci/devices/0000:${PCI_ADDRESS}/${VGPU_UUID}" ]; then 31 | return 0 32 | else 33 | return 1 34 | fi 35 | } 36 | 37 | # Create a vGPU from the given Intel GPU 38 | # Parameter 1: PCI address of the Intel GPU (format: XX:XX.X) 39 | # Parameter 2 (optional): UUID to be used for the vGPU 40 | # stdout: vGPU UUID of the created vGPU 41 | # returns: 0 on success; 1 on error 42 | function create() { 43 | local IGPU_PCI_ADDRESS="$1" 44 | local VGPU_UUID="$2" 45 | 46 | if [ "$VGPU_UUID" = "" ]; then 47 | VGPU_UUID=$(uuid) 48 | fi 49 | VGPU_TYPES_DIR="/sys/bus/pci/devices/0000:${IGPU_PCI_ADDRESS}/mdev_supported_types/*" 50 | VGPU_TYPE_DIR=( $VGPU_TYPES_DIR ) 51 | VGPU_TYPE=$(basename -- "${VGPU_TYPE_DIR}") 52 | # For further twaeking read: https://github.com/intel/gvt-linux/wiki/GVTg_Setup_Guide#53-create-vgpu-kvmgt-only 53 | if sudo bash -c "echo '${VGPU_UUID}' > '/sys/bus/pci/devices/0000:${IGPU_PCI_ADDRESS}/mdev_supported_types/${VGPU_TYPE}/create'"; then 54 | echo "${VGPU_UUID}" 55 | return 0 56 | else 57 | return 1 58 | fi 59 | } 60 | 61 | # Remove vGPUs from the given Intel GPU 62 | # Parameter 1: PCI address of the Intel GPU (format: XX:XX.X) 63 | # Parameter 2 (optional): UUID of the vGPU to remove (leave emtpy to remove all) 64 | # stdout: vGPU UUID of the removed vGPU 65 | # returns: 0 on success; 1 on or all error 66 | function remove() { 67 | local PCI_ADDRESS="$1" 68 | local VGPU_UUID="$2" 69 | 70 | if [ "$VGPU_UUID" = "" ]; then 71 | VGPU_UUID="$(get "${PCI_ADDRESS}")" 72 | fi 73 | 74 | if [ "$VGPU_UUID" != "" ]; then 75 | sudo bash -c "echo 1 > '/sys/bus/pci/devices/0000:${PCI_ADDRESS}/${VGPU_UUID}/remove'" && \ 76 | echo "${VGPU_UUID}" || return 1 77 | fi 78 | } 79 | 80 | if [ "$COMMAND" = "help" ] || [ "$COMMAND" = "--help" ] || [ "$COMMAND" = "-h" ] || [ "$COMMAND" = "" ]; then 81 | COMMAND="$2" 82 | if [ "$COMMAND" = "" ]; then 83 | echo 'vgpu-util [OPTIONS] COMMAND [ARG...]' 84 | echo 'vgpu-util [ -h | --help | -v | --version ]' 85 | echo '' 86 | echo 'A simple tool to manage vGPUs more easily.' 87 | echo '' 88 | echo 'Options:' 89 | echo ' -h, --help Print usage' 90 | echo ' -v, --version Print version information' 91 | echo '' 92 | echo 'Commands:' 93 | echo ' init Load required kernel modules' 94 | echo ' get Get currently existing vGPU UUID(s)' 95 | echo ' create Create a vGPU from the given Intel GPU' 96 | echo ' remove Remove vGPUs from the given Intel GPU' 97 | echo '' 98 | echo 'Examples:' 99 | echo ' # List all vGPUs associated with the iGPU with PCI Address 00:02.0' 100 | echo ' vgpu-util get 00:02.0' 101 | echo '' 102 | echo ' # Create vGPU with random ID for the iGPU with PCI address 03:00.0' 103 | echo ' vgpu-util create 03:00.0' 104 | echo '' 105 | echo ' # Create vGPU with ID 224b4ea4-b502-11eb-a58d-9cb6d0942801 for the iGPU with PCI address 00:02.0' 106 | echo ' vgpu-util create 00:02.0 224b4ea4-b502-11eb-a58d-9cb6d0942801' 107 | echo '' 108 | echo ' # Check if vGPUs with ID 224b4ea4-b502-11eb-a58d-9cb6d0942801 is associated with the iGPU with PCI Address 00:02.0' 109 | echo ' vgpu-util get 00:02.0 224b4ea4-b502-11eb-a58d-9cb6d0942801' 110 | echo '' 111 | echo ' # Remove the vGPU with the ID 224b4ea4-b502-11eb-a58d-9cb6d0942801 from iGPU with PCI address 00:02.0' 112 | echo ' vgpu-util remove 00:02.0 224b4ea4-b502-11eb-a58d-9cb6d0942801' 113 | else 114 | if [ "$COMMAND" = "init" ]; then 115 | echo 'vgpu-util init' 116 | echo '' 117 | echo 'Load required kernel modules' 118 | echo '' 119 | echo 'Examples:' 120 | echo ' # Load the kernel modules' 121 | echo ' vgpu-util init' 122 | elif [ "$COMMAND" = "get" ]; then 123 | echo 'vgpu-util get <PCI_ADDRESS> [VGPU_UUID]' 124 | echo '' 125 | echo 'Get currently existing vGPU ID(s)' 126 | echo '' 127 | echo 'Parameters:' 128 | echo ' PCI_ADDRESS PCI address of the Intel GPU (format: XX:XX.X)' 129 | echo ' VGPU_UUID UUID of the vGPU' 130 | echo '' 131 | echo 'Examples:'|| [ "$COMMAND" = "-h" 132 | echo ' # List all vGPUs associated with the iGPU with PCI Address 00:02.0' 133 | echo ' vgpu-util get 00:02.0' 134 | echo '' 135 | echo ' # Check if vGPUs with ID 224b4ea4-b502-11eb-a58d-9cb6d0942801 is associated with the iGPU with PCI Address 00:02.0' 136 | echo ' vgpu-util get 00:02.0 224b4ea4-b502-11eb-a58d-9cb6d0942801' 137 | elif [ "$COMMAND" = "create" ]; then 138 | echo 'vgpu-util get <PCI_ADDRESS>' 139 | echo '' 140 | echo 'Create a vGPU from the given Intel GPU' 141 | echo '' 142 | echo 'Parameters:' 143 | echo ' PCI_ADDRESS PCI address of the Intel GPU (format: XX:XX.X)' 144 | echo ' VGPU_UUID UUID of the vGPU' 145 | echo '' 146 | echo 'Examples:' 147 | echo ' # Create vGPU with random ID for the iGPU with PCI address 03:00.0' 148 | echo ' vgpu-util create 03:00.0' 149 | echo '' 150 | echo ' # Create vGPU with ID 224b4ea4-b502-11eb-a58d-9cb6d0942801 for the iGPU with PCI address 00:02.0' 151 | echo ' vgpu-util create 00:02.0 224b4ea4-b502-11eb-a58d-9cb6d0942801' 152 | elif [ "$COMMAND" = "remove" ]; then 153 | echo 'vgpu-util get <PCI_ADDRESS>' 154 | echo '' 155 | echo 'Remove vGPUs from the given Intel GPU' 156 | echo '' 157 | echo 'Parameters:' 158 | echo ' PCI_ADDRESS PCI address of the Intel GPU (format: XX:XX.X)' 159 | echo ' VGPU_UUID UUID of the vGPU' 160 | echo '' 161 | echo 'Examples:' 162 | echo ' # Remove the vGPU with the ID 224b4ea4-b502-11eb-a58d-9cb6d0942801 from iGPU with PCI address 00:02.0' 163 | echo ' vgpu-util remove 00:02.0 224b4ea4-b502-11eb-a58d-9cb6d0942801' 164 | fi 165 | fi 166 | elif [ "$COMMAND" = "init" ]; then 167 | init "${@:2}" 168 | elif [ "$COMMAND" = "get" ]; then 169 | get "${@:2}" 170 | elif [ "$COMMAND" = "create" ]; then 171 | create "${@:2}" 172 | elif [ "$COMMAND" = "remove" ]; then 173 | remove "${@:2}" 174 | fi -------------------------------------------------------------------------------- /scripts/utils/distro-specific/Ubuntu/pre-package-info-update: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | while [[ "$PROJECT_DIR" != */MobilePassThrough ]]; do PROJECT_DIR="$(readlink -f "$(dirname "${PROJECT_DIR:-0}")")"; done 3 | 4 | sudo add-apt-repository -y universe -------------------------------------------------------------------------------- /scripts/utils/distro-specific/Ubuntu/pre-package-install: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | while [[ "$PROJECT_DIR" != */MobilePassThrough ]]; do PROJECT_DIR="$(readlink -f "$(dirname "${PROJECT_DIR:-0}")")"; done 3 | 4 | alias commandAvailable="${COMMON_UTILS_TOOLS_DIR}/commands-available" 5 | 6 | if ! commandAvailable "x86_64-w64-mingw32-g++"; then 7 | sudo apt-get install -y g++-mingw-w64-x86-64-win32 8 | fi 9 | 10 | if ! commandAvailable "upx"; then 11 | sudo apt-get install -y upx-ucl 12 | fi -------------------------------------------------------------------------------- /scripts/utils/manager-specific/gui-terminal/gnome-terminal: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | while [[ "$PROJECT_DIR" != */MobilePassThrough ]]; do PROJECT_DIR="$(readlink -f "$(dirname "${PROJECT_DIR:-0}")")"; done 3 | 4 | COMMAND="$1" 5 | COMMAND_TO_EXECUTE="$2" 6 | 7 | if [ "$COMMAND" = "run-with-command" ]; then 8 | gnome-terminal -- bash -c "$COMMAND_TO_EXECUTE" 9 | fi 10 | -------------------------------------------------------------------------------- /scripts/utils/manager-specific/gui-terminal/konsole: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | while [[ "$PROJECT_DIR" != */MobilePassThrough ]]; do PROJECT_DIR="$(readlink -f "$(dirname "${PROJECT_DIR:-0}")")"; done 3 | source "$PROJECT_DIR/scripts/utils/common/libs/helpers" 4 | 5 | COMMAND="$1" 6 | COMMAND_TO_EXECUTE="$2" 7 | 8 | if [ "$COMMAND" = "run-with-command" ]; then 9 | konsole -e "$COMMAND_TO_EXECUTE" 10 | fi 11 | -------------------------------------------------------------------------------- /scripts/utils/manager-specific/gui-terminal/st: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | while [[ "$PROJECT_DIR" != */MobilePassThrough ]]; do PROJECT_DIR="$(readlink -f "$(dirname "${PROJECT_DIR:-0}")")"; done 3 | source "$PROJECT_DIR/scripts/utils/common/libs/helpers" 4 | 5 | COMMAND="$1" 6 | COMMAND_TO_EXECUTE="$2" 7 | 8 | if [ "$COMMAND" = "run-with-command" ]; then 9 | st -e "$COMMAND_TO_EXECUTE" 10 | fi 11 | -------------------------------------------------------------------------------- /scripts/utils/manager-specific/gui-terminal/x-terminal-emulator: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | while [[ "$PROJECT_DIR" != */MobilePassThrough ]]; do PROJECT_DIR="$(readlink -f "$(dirname "${PROJECT_DIR:-0}")")"; done 3 | source "$PROJECT_DIR/scripts/utils/common/libs/helpers" 4 | 5 | COMMAND="$1" 6 | COMMAND_TO_EXECUTE="$2" 7 | 8 | if [ "$COMMAND" = "run-with-command" ]; then 9 | x-terminal-emulator -e "$COMMAND_TO_EXECUTE" 10 | fi 11 | -------------------------------------------------------------------------------- /scripts/utils/manager-specific/initramfs/dracut: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | VFIO_CFG_PATH=/etc/dracut.conf.d/vfio.conf 4 | 5 | COMMAND="$1" # Supported commands: add-driver, apply 6 | PARAM="$2" 7 | 8 | function addInitramfsDriver() { 9 | driver="$1" 10 | sudo touch "$VFIO_CFG_PATH" 11 | if ! sudo cat "$VFIO_CFG_PATH" | grep --quiet "add_driver+="; then 12 | echo 'add_driver+=" "' >> "$VFIO_CFG_PATH" 13 | fi 14 | if ! sudo cat "$VFIO_CFG_PATH" | grep "add_driver+=" | grep --quiet -P "( |\")$driver( |\")"; then 15 | sudo sed -i "s/^add_driver+=\" \{0,1\}/&$driver /" "$VFIO_CFG_PATH" 16 | echo "addDriverToInitramfs: Added \"$driver\" to add_driver in $VFIO_CFG_PATH" 17 | else 18 | echo "addDriverToInitramfs: No action required. \"$driver\" already exists in add_driver in $VFIO_CFG_PATH" 19 | fi 20 | } 21 | 22 | function applyInitramfsChanges() { 23 | sudo dracut -f --kver `uname -r` 24 | #TODO: Find out if this needs to be executed again after every kernel update. 25 | } 26 | 27 | if [ "$COMMAND" = "add-driver" ]; then 28 | addInitramfsDriver "$PARAM" 29 | elif [ "$COMMAND" = "apply" ]; then 30 | applyInitramfsChanges 31 | fi -------------------------------------------------------------------------------- /scripts/utils/manager-specific/kernelparams/grub: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | GRUB_CFG_PATH=/etc/default/grub 4 | 5 | COMMAND="$1" # Supported commands: add, remove, apply 6 | PARAM="$2" 7 | 8 | if sudo cat "$GRUB_CFG_PATH" | grep --quiet "GRUB_CMDLINE_LINUX_DEFAULT="; then 9 | GRUB_CMDLINE_VAR="GRUB_CMDLINE_LINUX_DEFAULT" 10 | else 11 | GRUB_CMDLINE_VAR="GRUB_CMDLINE_LINUX" 12 | fi 13 | 14 | function addKernelParam() { 15 | if ! sudo cat "$GRUB_CFG_PATH" | grep "$GRUB_CMDLINE_VAR=" | grep --quiet "$1"; then 16 | sudo sed -i "s/^$GRUB_CMDLINE_VAR=\"/&$1 /" "$GRUB_CFG_PATH" 17 | echo "addKernelParam: Added \"$1\" to $GRUB_CMDLINE_VAR in $GRUB_CFG_PATH" 18 | else 19 | echo "addKernelParam: No action required. \"$1\" already exists in $GRUB_CMDLINE_VAR of $GRUB_CFG_PATH" 20 | fi 21 | } 22 | function addKernelParams() { 23 | for param in $1; do 24 | addKernelParam "$param" 25 | done 26 | } 27 | function removeKernelParam() { 28 | if sudo cat "$GRUB_CFG_PATH" | grep "$GRUB_CMDLINE_VAR=" | grep --quiet "$1"; then 29 | sudo sed -i "s/$1 //" "$GRUB_CFG_PATH" 30 | echo "removeKernelParam: Removed \"$1\" from $GRUB_CMDLINE_VAR in $GRUB_CFG_PATH" 31 | else 32 | echo "removeKernelParam: No action required. \"$1\" is not set in $GRUB_CMDLINE_VAR of $GRUB_CFG_PATH" 33 | fi 34 | } 35 | function removeKernelParams() { 36 | for param in $1; do 37 | removeKernelParam "$param" 38 | done 39 | } 40 | 41 | function applyKernelParamChanges() { 42 | if command -v update-grub &> /dev/null; then 43 | sudo update-grub 44 | elif [ -f "/etc/grub2-efi.cfg" ]; then 45 | sudo sh -c 'grub2-mkconfig > /etc/grub2-efi.cfg' 46 | fi 47 | } 48 | 49 | if [ "$COMMAND" = "add" ]; then 50 | addKernelParams "$PARAM" 51 | elif [ "$COMMAND" = "remove" ]; then 52 | removeKernelParams "$PARAM" 53 | elif [ "$COMMAND" = "apply" ]; then 54 | applyKernelParamChanges 55 | fi 56 | -------------------------------------------------------------------------------- /scripts/utils/manager-specific/package/apt: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | while [[ "$PROJECT_DIR" != */MobilePassThrough ]]; do PROJECT_DIR="$(readlink -f "$(dirname "${PROJECT_DIR:-0}")")"; done 3 | source "$PROJECT_DIR/scripts/utils/common/libs/helpers" 4 | loadConfig 5 | 6 | ##################################################################################################### 7 | # Simple script to install the packages containing the given executable names or file names 8 | # Usage: `./apt --executables "curl git wget docker"` 9 | # Usage: `./apt --files "/usr/include/{ree,ruby}/ruby.h /usr/share/virtio-win/virtio-win.iso"` 10 | ##################################################################################################### 11 | 12 | alias getMissingExecutables="${COMMON_UTILS_TOOLS_DIR}/get-missing-executables" 13 | alias getMissingFiles="${COMMON_UTILS_TOOLS_DIR}/get-missing-files" 14 | 15 | COMMAND="$1" 16 | SEARCH_MODE="$2" 17 | WANTED_ITEMS="$3" 18 | 19 | function updatePackageInfo() { 20 | sudo apt-get update 21 | if ! command -v apt-file &> /dev/null; then 22 | sudo apt-get install -y apt-file 23 | fi 24 | sudo apt-file update 25 | } 26 | 27 | function installPackages() { 28 | SEARCH_MODE="$1" 29 | WANTED_ITEMS="$2" 30 | if ! command -v apt-file &> /dev/null; then 31 | sudo apt-get install -y apt-file 32 | sudo apt-file update 33 | fi 34 | PACKAGES_TO_INSTALL="" 35 | for CURRENT_ITEM in $WANTED_ITEMS; do 36 | if [ "$SEARCH_MODE" = "--executables" ]; then 37 | PACKAGE_TO_INSTALL="$(sudo apt-file search -l -x "^/(bin|sbin|usr/bin|usr/sbin)/${CURRENT_ITEM}$" | head -1)" 38 | elif [ "$SEARCH_MODE" = "--files" ]; then 39 | PACKAGE_TO_INSTALL="$(sudo apt-file search $CURRENT_ITEM | grep "${CURRENT_ITEM}$" | head -1 | cut -d':' -f1)" 40 | fi 41 | if [ "$?" = "0" ] && [ "$PACKAGE_TO_INSTALL" != "" ]; then 42 | PACKAGES_TO_INSTALL+=" $PACKAGE_TO_INSTALL" 43 | else 44 | STILL_MISSING_ITEMS+=" $CURRENT_ITEM" 45 | fi 46 | done 47 | if [ "$PACKAGES_TO_INSTALL" != "" ]; then 48 | sudo bash -c "DEBIAN_FRONTEND=noninteractive apt-get install -yq $PACKAGES_TO_INSTALL" 49 | fi 50 | } 51 | 52 | if [ "$COMMAND" = "install" ]; then 53 | if [ "$SEARCH_MODE" = "--executables" ]; then 54 | MISSING_EXECUTABLES="$(getMissingExecutables "$WANTED_ITEMS")" 55 | installPackages "$SEARCH_MODE" "$MISSING_EXECUTABLES" 56 | MISSING_EXECUTABLES="$(getMissingExecutables "$WANTED_ITEMS")" 57 | elif [ "$SEARCH_MODE" = "--files" ]; then 58 | MISSING_FILES="$(getMissingFiles "$WANTED_ITEMS")" 59 | installPackages "$SEARCH_MODE" "$MISSING_FILES" 60 | MISSING_FILES="$(getMissingFiles "$WANTED_ITEMS")" 61 | else 62 | echo "ERROR: Invalid mode or no mode at all was speficied!" 63 | exit 1 64 | fi 65 | if [ "$MISSING_EXECUTABLES" != "" ]; then 66 | echo "ERROR: Still missing package providing the following executables: $MISSING_EXECUTABLES" 67 | fi 68 | if [ "$MISSING_FILES" != "" ]; then 69 | echo "ERROR: Still missing package providing the following files: $MISSING_FILES" 70 | fi 71 | if [ "$MISSING_EXECUTABLES" != "" ] && [ "$MISSING_FILES" != "" ]; then 72 | exit 1 73 | fi 74 | elif [ "$COMMAND" = "update" ]; then 75 | updatePackageInfo 76 | else 77 | echo "ERROR: Invalid command" 78 | exit 1 79 | fi 80 | -------------------------------------------------------------------------------- /scripts/utils/manager-specific/package/dnf: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | while [[ "$PROJECT_DIR" != */MobilePassThrough ]]; do PROJECT_DIR="$(readlink -f "$(dirname "${PROJECT_DIR:-0}")")"; done 3 | source "$PROJECT_DIR/scripts/utils/common/libs/helpers" 4 | loadConfig 5 | 6 | ##################################################################################################### 7 | # Simple script to install the packages containing the given executable names or files 8 | # Usage: `./dnf --executables "curl git wget docker"` 9 | # Usage: `./dnf --files "/usr/include/{ree,ruby}/ruby.h /usr/share/virtio-win/virtio-win.iso"` 10 | ##################################################################################################### 11 | 12 | alias getMissingExecutables="${COMMON_UTILS_TOOLS_DIR}/get-missing-executables" 13 | alias getMissingFiles="${COMMON_UTILS_TOOLS_DIR}/get-missing-files" 14 | 15 | COMMAND="$1" 16 | SEARCH_MODE="$2" 17 | WANTED_ITEMS="$3" 18 | 19 | function updatePackageInfo() { 20 | sudo dnf check-update 21 | } 22 | 23 | function installPackages() { 24 | SEARCH_MODE="$1" 25 | WANTED_ITEMS="$2" 26 | 27 | PACKAGES_TO_INSTALL="" 28 | for CURRENT_ITEM in $WANTED_ITEMS; do 29 | if [ "$SEARCH_MODE" = "--executables" ]; then 30 | PACKAGE_TO_INSTALL="$(sudo dnf provides {/bin,/sbin,/usr/bin/,/usr/sbin}/$CURRENT_ITEM 2> /dev/null | grep ' : ' | head -1 | cut -d'.' -f1 | rev | cut -d'-' -f 2- | rev)" 31 | elif [ "$SEARCH_MODE" = "--files" ]; then 32 | PACKAGE_TO_INSTALL="$(sudo dnf provides $CURRENT_ITEM 2> /dev/null | grep ' : ' | head -1 | cut -d'.' -f1 | rev | cut -d'-' -f 2- | rev)" 33 | fi 34 | if [ "$?" = "0" ] && [ "$PACKAGE_TO_INSTALL" != "" ]; then 35 | PACKAGES_TO_INSTALL+=" $PACKAGE_TO_INSTALL" 36 | else 37 | STILL_MISSING_ITEMS+=" $CURRENT_ITEM" 38 | fi 39 | done 40 | if [ "$PACKAGES_TO_INSTALL" != "" ]; then 41 | sudo dnf install -y $PACKAGES_TO_INSTALL 42 | fi 43 | } 44 | 45 | if [ "$COMMAND" = "install" ]; then 46 | if [ "$SEARCH_MODE" = "--executables" ]; then 47 | MISSING_EXECUTABLES="$(getMissingExecutables "$WANTED_ITEMS")" 48 | installPackages "$SEARCH_MODE" "$MISSING_EXECUTABLES" 49 | MISSING_EXECUTABLES="$(getMissingExecutables "$WANTED_ITEMS")" 50 | elif [ "$SEARCH_MODE" = "--files" ]; then 51 | MISSING_FILES="$(getMissingFiles "$WANTED_ITEMS")" 52 | installPackages "$SEARCH_MODE" "$MISSING_FILES" 53 | MISSING_FILES="$(getMissingFiles "$WANTED_ITEMS")" 54 | else 55 | echo "ERROR: Invalid mode or no mode at all was speficied!" 56 | exit 1 57 | fi 58 | if [ "$MISSING_EXECUTABLES" != "" ]; then 59 | echo "ERROR: Still missing package providing the following executables: $MISSING_EXECUTABLES" 60 | fi 61 | if [ "$MISSING_FILES" != "" ]; then 62 | echo "ERROR: Still missing package providing the following files: $MISSING_FILES" 63 | fi 64 | if [ "$MISSING_EXECUTABLES" != "" ] && [ "$MISSING_FILES" != "" ]; then 65 | exit 1 66 | fi 67 | elif [ "$COMMAND" = "update" ]; then 68 | updatePackageInfo 69 | else 70 | echo "ERROR: Invalid command" 71 | exit 1 72 | fi 73 | 74 | -------------------------------------------------------------------------------- /scripts/utils/manager-specific/package/emerge: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | while [[ "$PROJECT_DIR" != */MobilePassThrough ]]; do PROJECT_DIR="$(readlink -f "$(dirname "${PROJECT_DIR:-0}")")"; done 3 | source "$PROJECT_DIR/scripts/utils/common/libs/helpers" 4 | loadConfig 5 | 6 | ##################################################################################################### 7 | # 8 | # WARNING!!!!!!!!!!!!!!!! The `e-file` calls in this file have not been properly implemented yet!!! 9 | # WARNING!!!!!!!!!!!!!!!! The `e-file` calls in this file have not been properly implemented yet!!! 10 | # WARNING!!!!!!!!!!!!!!!! The `e-file` calls in this file have not been properly implemented yet!!! 11 | # 12 | # Simple script to install the packages containing the given executable names or file names 13 | # Usage: `./emerge --executables "curl git wget docker"` 14 | # Usage: `./emerge --files "/usr/include/{ree,ruby}/ruby.h /usr/share/virtio-win/virtio-win.iso"` 15 | ##################################################################################################### 16 | 17 | alias getMissingExecutables="${COMMON_UTILS_TOOLS_DIR}/get-missing-executables" 18 | alias getMissingFiles="${COMMON_UTILS_TOOLS_DIR}/get-missing-files" 19 | 20 | COMMAND="$1" 21 | SEARCH_MODE="$2" 22 | WANTED_ITEMS="$3" 23 | 24 | function updatePackageInfo() { 25 | sudo emerge-webrsync -v 26 | } 27 | 28 | function installPackages() { 29 | SEARCH_MODE="$1" 30 | WANTED_ITEMS="$2" 31 | if ! command -v e-file &> /dev/null; then 32 | sudo emerge app-portage/pfl 33 | fi 34 | PACKAGES_TO_INSTALL="" 35 | for CURRENT_ITEM in $WANTED_ITEMS; do 36 | if [ "$SEARCH_MODE" = "--executables" ]; then 37 | PACKAGE_TO_INSTALL="$(sudo e-file $CURRENT_ITEM ????)" # TODO: FIXME 38 | elif [ "$SEARCH_MODE" = "--files" ]; then 39 | PACKAGE_TO_INSTALL="$(sudo e-file $CURRENT_ITEM ????)" # TODO: FIXME 40 | fi 41 | if [ "$?" = "0" ] && [ "$PACKAGE_TO_INSTALL" != "" ]; then 42 | PACKAGES_TO_INSTALL+=" $PACKAGE_TO_INSTALL" 43 | else 44 | STILL_MISSING_ITEMS+=" $CURRENT_ITEM" 45 | fi 46 | done 47 | if [ "$PACKAGES_TO_INSTALL" != "" ]; then 48 | sudo emerge $PACKAGES_TO_INSTALL 49 | fi 50 | } 51 | 52 | if [ "$SEARCH_MODE" = "--executables" ]; then 53 | MISSING_EXECUTABLES="$(getMissingExecutables "$WANTED_ITEMS")" 54 | installPackages "$SEARCH_MODE" "$MISSING_EXECUTABLES" 55 | MISSING_EXECUTABLES="$(getMissingExecutables "$WANTED_ITEMS")" 56 | elif [ "$SEARCH_MODE" = "--files" ]; then 57 | MISSING_FILES="$(getMissingFiles "$WANTED_ITEMS")" 58 | installPackages "$SEARCH_MODE" "$MISSING_FILES" 59 | MISSING_FILES="$(getMissingFiles "$WANTED_ITEMS")" 60 | else 61 | echo "ERROR: Invalid mode or no mode at all was speficied!" 62 | exit 1 63 | fi 64 | if [ "$MISSING_EXECUTABLES" != "" ]; then 65 | echo "ERROR: Still missing package providing the following executables: $MISSING_EXECUTABLES" 66 | fi 67 | if [ "$MISSING_FILES" != "" ]; then 68 | echo "ERROR: Still missing package providing the following files: $MISSING_FILES" 69 | fi 70 | if [ "$MISSING_EXECUTABLES" != "" ] && [ "$MISSING_FILES" != "" ]; then 71 | exit 1 72 | fi 73 | -------------------------------------------------------------------------------- /scripts/utils/manager-specific/package/pacman: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | while [[ "$PROJECT_DIR" != */MobilePassThrough ]]; do PROJECT_DIR="$(readlink -f "$(dirname "${PROJECT_DIR:-0}")")"; done 3 | source "$PROJECT_DIR/scripts/utils/common/libs/helpers" 4 | loadConfig 5 | 6 | ##################################################################################################### 7 | # Simple script to install the packages containing the given executable names or file names 8 | # Usage: `./pacman --executables "curl git wget docker"` 9 | # Usage: `./pacman --files "/usr/include/{ree,ruby}/ruby.h /usr/share/virtio-win/virtio-win.iso"` 10 | ##################################################################################################### 11 | 12 | alias getMissingExecutables="${COMMON_UTILS_TOOLS_DIR}/get-missing-executables" 13 | alias getMissingFiles="${COMMON_UTILS_TOOLS_DIR}/get-missing-files" 14 | 15 | COMMAND="$1" 16 | SEARCH_MODE="$2" 17 | WANTED_ITEMS="$3" 18 | 19 | function updatePackageInfo() { 20 | sudo pacman -Syy 21 | sudo pacman -Fy 22 | } 23 | 24 | function installPackages() { 25 | SEARCH_MODE="$1" 26 | WANTED_ITEMS="$2" 27 | PACKAGES_TO_INSTALL="" 28 | for CURRENT_ITEM in $WANTED_ITEMS; do 29 | if [ "$SEARCH_MODE" = "--executables" ]; then 30 | PACKAGE_TO_INSTALL="$(sudo pacman -F $CURRENT_ITEM | grep -B 1 /bin/$CURRENT_ITEM | head -1 | cut -d' ' -f1)" 31 | elif [ "$SEARCH_MODE" = "--files" ]; then 32 | PACKAGE_TO_INSTALL="$(sudo pacman -F $CURRENT_ITEM | head -1 | rev | cut -d' ' -f2 | rev)" 33 | fi 34 | if [ "$?" = "0" ] && [ "$PACKAGE_TO_INSTALL" != "" ]; then 35 | PACKAGES_TO_INSTALL+=" $PACKAGE_TO_INSTALL" 36 | else 37 | STILL_MISSING_ITEMS+=" $CURRENT_ITEM" 38 | fi 39 | done 40 | if [ "$PACKAGES_TO_INSTALL" != "" ]; then 41 | sudo pacman -S --noconfirm $PACKAGES_TO_INSTALL 42 | fi 43 | } 44 | 45 | if [ "$SEARCH_MODE" = "--executables" ]; then 46 | MISSING_EXECUTABLES="$(getMissingExecutables "$WANTED_ITEMS")" 47 | installPackages "$SEARCH_MODE" "$MISSING_EXECUTABLES" 48 | MISSING_EXECUTABLES="$(getMissingExecutables "$WANTED_ITEMS")" 49 | elif [ "$SEARCH_MODE" = "--files" ]; then 50 | MISSING_FILES="$(getMissingFiles "$WANTED_ITEMS")" 51 | installPackages "$SEARCH_MODE" "$MISSING_FILES" 52 | MISSING_FILES="$(getMissingFiles "$WANTED_ITEMS")" 53 | else 54 | echo "ERROR: Invalid mode or no mode at all was speficied!" 55 | exit 1 56 | fi 57 | if [ "$MISSING_EXECUTABLES" != "" ]; then 58 | echo "ERROR: Still missing package providing the following executables: $MISSING_EXECUTABLES" 59 | fi 60 | if [ "$MISSING_FILES" != "" ]; then 61 | echo "ERROR: Still missing package providing the following files: $MISSING_FILES" 62 | fi 63 | if [ "$MISSING_EXECUTABLES" != "" ] && [ "$MISSING_FILES" != "" ]; then 64 | exit 1 65 | fi 66 | -------------------------------------------------------------------------------- /scripts/utils/manager-specific/package/yum: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | while [[ "$PROJECT_DIR" != */MobilePassThrough ]]; do PROJECT_DIR="$(readlink -f "$(dirname "${PROJECT_DIR:-0}")")"; done 3 | source "$PROJECT_DIR/scripts/utils/common/libs/helpers" 4 | loadConfig 5 | 6 | ##################################################################################################### 7 | # Simple script to install the packages containing the given executable names or files 8 | # Usage: `./yum --executables "curl git wget docker"` 9 | # Usage: `./yum --files "/usr/include/{ree,ruby}/ruby.h /usr/share/virtio-win/virtio-win.iso"` 10 | ##################################################################################################### 11 | 12 | alias getMissingExecutables="${COMMON_UTILS_TOOLS_DIR}/get-missing-executables" 13 | alias getMissingFiles="${COMMON_UTILS_TOOLS_DIR}/get-missing-files" 14 | 15 | COMMAND="$1" 16 | SEARCH_MODE="$2" 17 | WANTED_ITEMS="$3" 18 | 19 | function updatePackageInfo() { 20 | sudo yum check-update 21 | } 22 | 23 | function installPackages() { 24 | SEARCH_MODE="$1" 25 | WANTED_ITEMS="$2" 26 | 27 | PACKAGES_TO_INSTALL="" 28 | for CURRENT_ITEM in $WANTED_ITEMS; do 29 | if [ "$SEARCH_MODE" = "--executables" ]; then 30 | PACKAGE_TO_INSTALL="$(sudo yum provides {/bin,/sbin,/usr/bin/,/usr/sbin}/$CURRENT_ITEM 2> /dev/null | grep ' : ' | head -1 | cut -d'.' -f1 | rev | cut -d'-' -f 2- | rev)" 31 | elif [ "$SEARCH_MODE" = "--files" ]; then 32 | PACKAGE_TO_INSTALL="$(sudo yum provides $CURRENT_ITEM 2> /dev/null | grep ' : ' | head -1 | cut -d'.' -f1 | rev | cut -d'-' -f 2- | rev)" 33 | fi 34 | if [ "$?" = "0" ] && [ "$PACKAGE_TO_INSTALL" != "" ]; then 35 | PACKAGES_TO_INSTALL+=" $PACKAGE_TO_INSTALL" 36 | else 37 | STILL_MISSING_ITEMS+=" $CURRENT_ITEM" 38 | fi 39 | done 40 | if [ "$PACKAGES_TO_INSTALL" != "" ]; then 41 | sudo yum install -y $PACKAGES_TO_INSTALL 42 | fi 43 | } 44 | 45 | if [ "$COMMAND" = "install" ]; then 46 | if [ "$SEARCH_MODE" = "--executables" ]; then 47 | MISSING_EXECUTABLES="$(getMissingExecutables "$WANTED_ITEMS")" 48 | installPackages "$SEARCH_MODE" "$MISSING_EXECUTABLES" 49 | MISSING_EXECUTABLES="$(getMissingExecutables "$WANTED_ITEMS")" 50 | elif [ "$SEARCH_MODE" = "--files" ]; then 51 | MISSING_FILES="$(getMissingFiles "$WANTED_ITEMS")" 52 | installPackages "$SEARCH_MODE" "$MISSING_FILES" 53 | MISSING_FILES="$(getMissingFiles "$WANTED_ITEMS")" 54 | else 55 | echo "ERROR: Invalid mode or no mode at all was speficied!" 56 | exit 1 57 | fi 58 | if [ "$MISSING_EXECUTABLES" != "" ]; then 59 | echo "ERROR: Still missing package providing the following executables: $MISSING_EXECUTABLES" 60 | fi 61 | if [ "$MISSING_FILES" != "" ]; then 62 | echo "ERROR: Still missing package providing the following files: $MISSING_FILES" 63 | fi 64 | if [ "$MISSING_EXECUTABLES" != "" ] && [ "$MISSING_FILES" != "" ]; then 65 | exit 1 66 | fi 67 | elif [ "$COMMAND" = "update" ]; then 68 | updatePackageInfo 69 | else 70 | echo "ERROR: Invalid command" 71 | exit 1 72 | fi 73 | 74 | -------------------------------------------------------------------------------- /scripts/utils/manager-specific/package/zypper: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | while [[ "$PROJECT_DIR" != */MobilePassThrough ]]; do PROJECT_DIR="$(readlink -f "$(dirname "${PROJECT_DIR:-0}")")"; done 3 | source "$PROJECT_DIR/scripts/utils/common/libs/helpers" 4 | loadConfig 5 | 6 | ##################################################################################################### 7 | # Simple script to install the packages containing the given executable names or file names 8 | # Usage: `./zypper --executables "curl git wget docker"` 9 | # Usage: `./zypper --files "/usr/include/{ree,ruby}/ruby.h /usr/share/virtio-win/virtio-win.iso"` 10 | ##################################################################################################### 11 | 12 | alias getMissingExecutables="${COMMON_UTILS_TOOLS_DIR}/get-missing-executables" 13 | alias getMissingFiles="${COMMON_UTILS_TOOLS_DIR}/get-missing-files" 14 | 15 | COMMAND="$1" 16 | SEARCH_MODE="$2" 17 | WANTED_ITEMS="$3" 18 | 19 | function updatePackageInfo() { 20 | sudo zypper refresh 21 | } 22 | 23 | function installPackages() { 24 | SEARCH_MODE="$1" 25 | WANTED_ITEMS="$2" 26 | PACKAGES_TO_INSTALL="" 27 | for CURRENT_ITEM in $WANTED_ITEMS; do 28 | if [ "$SEARCH_MODE" = "--executables" ]; then 29 | PACKAGE_TO_INSTALL="$(sudo zypper search -f {/bin,/sbin,/usr/bin/,/usr/sbin}/$CURRENT_ITEM | grep " | package" | head -1 | tr -d ' ' | cut -d'|' -f2)" 30 | elif [ "$SEARCH_MODE" = "--files" ]; then 31 | PACKAGE_TO_INSTALL="$(sudo zypper search -f $CURRENT_ITEM | grep " | package" | head -1 | tr -d ' ' | cut -d'|' -f2)" 32 | fi 33 | if [ "$?" = "0" ] && [ "$PACKAGE_TO_INSTALL" != "" ]; then 34 | PACKAGES_TO_INSTALL+=" $PACKAGE_TO_INSTALL" 35 | else 36 | STILL_MISSING_ITEMS+=" $CURRENT_ITEM" 37 | fi 38 | done 39 | if [ "$PACKAGES_TO_INSTALL" != "" ]; then 40 | sudo zypper --non-interactive install $PACKAGES_TO_INSTALL 41 | fi 42 | } 43 | 44 | if [ "$SEARCH_MODE" = "--executables" ]; then 45 | MISSING_EXECUTABLES="$(getMissingExecutables "$WANTED_ITEMS")" 46 | installPackages "$SEARCH_MODE" "$MISSING_EXECUTABLES" 47 | MISSING_EXECUTABLES="$(getMissingExecutables "$WANTED_ITEMS")" 48 | elif [ "$SEARCH_MODE" = "--files" ]; then 49 | MISSING_FILES="$(getMissingFiles "$WANTED_ITEMS")" 50 | installPackages "$SEARCH_MODE" "$MISSING_FILES" 51 | MISSING_FILES="$(getMissingFiles "$WANTED_ITEMS")" 52 | else 53 | echo "ERROR: Invalid mode or no mode at all was speficied!" 54 | exit 1 55 | fi 56 | if [ "$MISSING_EXECUTABLES" != "" ]; then 57 | echo "ERROR: Still missing package providing the following executables: $MISSING_EXECUTABLES" 58 | fi 59 | if [ "$MISSING_FILES" != "" ]; then 60 | echo "ERROR: Still missing package providing the following files: $MISSING_FILES" 61 | fi 62 | if [ "$MISSING_EXECUTABLES" != "" ] && [ "$MISSING_FILES" != "" ]; then 63 | exit 1 64 | fi 65 | -------------------------------------------------------------------------------- /scripts/utils/manager-specific/service/initctl: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | while [[ "$PROJECT_DIR" != */MobilePassThrough ]]; do PROJECT_DIR="$(readlink -f "$(dirname "${PROJECT_DIR:-0}")")"; done 3 | source "$PROJECT_DIR/scripts/utils/common/libs/helpers" 4 | 5 | COMMAND="$1" 6 | SERVICE_NAME="$2" 7 | 8 | if [ "$COMMAND" = "create-autostart-service" ]; then 9 | echo "Not implemented" 10 | exit 1 11 | elif [ "$COMMAND" = "remove-autostart-service" ]; then 12 | echo "Not implemented" 13 | exit 1 14 | elif [ "$COMMAND" = "start" ]; then 15 | sudo service start ${SERVICE_NAME} &> /dev/null 16 | elif [ "$COMMAND" = "stop" ]; then 17 | sudo service stop ${SERVICE_NAME} &> /dev/null 18 | elif [ "$COMMAND" = "restart" ]; then 19 | sudo initctl restart ${SERVICE_NAME} &> /dev/null 20 | fi 21 | -------------------------------------------------------------------------------- /scripts/utils/manager-specific/service/service: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | while [[ "$PROJECT_DIR" != */MobilePassThrough ]]; do PROJECT_DIR="$(readlink -f "$(dirname "${PROJECT_DIR:-0}")")"; done 3 | source "$PROJECT_DIR/scripts/utils/common/libs/helpers" 4 | 5 | COMMAND="$1" 6 | SERVICE_NAME="$2" 7 | 8 | if [ "$COMMAND" = "create-autostart-service" ]; then 9 | echo "Not implemented" 10 | exit 1 11 | elif [ "$COMMAND" = "remove-autostart-service" ]; then 12 | echo "Not implemented" 13 | exit 1 14 | elif [ "$COMMAND" = "start" ]; then 15 | sudo service ${SERVICE_NAME} start &> /dev/null 16 | elif [ "$COMMAND" = "stop" ]; then 17 | sudo service ${SERVICE_NAME} stop &> /dev/null 18 | elif [ "$COMMAND" = "restart" ]; then 19 | sudo service ${SERVICE_NAME} stop &> /dev/null 20 | sudo service ${SERVICE_NAME} start &> /dev/null 21 | fi 22 | -------------------------------------------------------------------------------- /scripts/utils/manager-specific/service/systemd: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | while [[ "$PROJECT_DIR" != */MobilePassThrough ]]; do PROJECT_DIR="$(readlink -f "$(dirname "${PROJECT_DIR:-0}")")"; done 3 | source "$PROJECT_DIR/scripts/utils/common/libs/helpers" 4 | 5 | COMMAND="$1" 6 | 7 | SERVICE_NAME="$2" 8 | if [ "$COMMAND" = "create-autostart-service" ]; then 9 | COMMAND_TO_RUN="$2" 10 | EXEC_START="'$GUI_TERMINAL' run-with-command '$COMMAND_TO_RUN'" 11 | 12 | sudo echo "[Unit] 13 | Description=${SERVICE_NAME} 14 | After=multi-user.target network.target 15 | 16 | [Service] 17 | User=$(logname) 18 | Group=$(id -gn $(logname)) 19 | Type=simple 20 | Environment=DISPLAY=:0 21 | WorkingDirectory=${PROJECT_DIR} 22 | ExecStart=${EXEC_START} 23 | Restart=never 24 | 25 | [Install] 26 | WantedBy=multi-user.target" > /etc/systemd/system/${SERVICE_NAME}.service 27 | 28 | sudo systemctl daemon-reload 29 | sudo systemctl enable ${SERVICE_NAME}.service 30 | elif [ "$COMMAND" = "remove-autostart-service" ]; then 31 | sudo systemctl disable ${SERVICE_NAME}.service &> /dev/null 32 | elif [ "$COMMAND" = "start" ]; then 33 | sudo systemctl start ${SERVICE_NAME}.service &> /dev/null 34 | elif [ "$COMMAND" = "stop" ]; then 35 | sudo systemctl stop ${SERVICE_NAME}.service &> /dev/null 36 | elif [ "$COMMAND" = "restart" ]; then 37 | sudo systemctl restart ${SERVICE_NAME}.service &> /dev/null 38 | fi 39 | --------------------------------------------------------------------------------