Skip to content

Commit

Permalink
Lots of fixes and refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
T-vK committed Jul 12, 2019
1 parent e6cc6d4 commit a1fb734
Show file tree
Hide file tree
Showing 9 changed files with 62 additions and 64 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Expand Up @@ -9,6 +9,6 @@
.*.swo
thirdparty
/user.conf
/mobile-passthrough-iso/bin
/helper-iso-files/bin
/LookingGlass
/utils/nvflash_linux
4 changes: 2 additions & 2 deletions README.md
Expand Up @@ -51,8 +51,8 @@ And there is also a lot of advanced stuff that I managed to fully automate, like
- It might also be necessary to disable fastboot in the UEFI.

### Installation and configuration
- Downlaod and install [normal Fedora](https://getfedora.org/) or the [KDE version](https://spins.fedoraproject.org/kde/)
- Make sure to crate a user account (with administrator rights) when you are asked
- Download and install [standard Fedora](https://getfedora.org/) or the [KDE version](https://spins.fedoraproject.org/kde/) (ideally in UEFI mode)
- Make sure to create a user account (with administrator rights) when you are asked
- Open a terminal and install git by typing the following, pressing enter after each line:

``` bash
Expand Down
3 changes: 1 addition & 2 deletions compatibility-check.sh
Expand Up @@ -220,8 +220,7 @@ fi
if [ "${UEFI_VIRTUALIZATION_ENABLED}" = true ] && [ "${UEFI_IOMMU_ENABLED}" = true ] && [ "${KERNEL_IOMMU_ENABLED}" = true ] && [ "${IOMMU_COMPATIBILITY_LVL}" -gt "0" ] ; then
log_green "If you found a notebook that appears to be GPU passthrough compatible, please open an issue on Github and let me know."
if [ "${IOMMU_COMPATIBILITY_LVL}" -gt "1" ] ; then
log_green "You may now proceed and run the start-vm.sh script."
log_green "However, you should adjust how much RAM, CPU cores, disk space etc the VM can use at the very top of the script."
log_green "You may now proceed and run the generate-vm-config.sh script as mentioned in the README."
fi
fi

Expand Down
2 changes: 1 addition & 1 deletion default.conf
Expand Up @@ -57,7 +57,7 @@ USB_DEVICES=""
# example3: USB_DEVICES="vendorid=0x0b12,productid=0x9348;vendorid=0x0b95,productid=0x1790;hostbus=3,hostaddr=9"

####### This part of the config get's burned into the helper iso that you can generate using generate-helper-iso.sh ######
# Not implemented yet; Please change the mobile-passthrough-iso/start.bat file manually, if you need to change the IPs
# Not implemented yet; Please change the helper-iso-files/start.bat file manually, if you need to change the IPs
#V_NETWORK_GATEWAY_IP=192.168.99.1 # Recommended (Leave this as is unless you know what you're doing)
#V_NETWORK_DNS_IP=192.168.99.1 # Recommended (Leave this as is unless you know what you're doing)
#V_NETWORK_IP=192.168.99.2 # Recommended (Leave this as is unless you know what you're doing)
Expand Down
76 changes: 38 additions & 38 deletions generate-helper-iso.sh
Expand Up @@ -18,76 +18,76 @@ else
exit
fi

mkdir -p "${PROJECT_DIR}/mobile-passthrough-iso/bin"
#if [ ! -f "${PROJECT_DIR}/mobile-passthrough-iso/bin/AutoHotkeyU64.exe" ]; then
mkdir -p "${PROJECT_DIR}/helper-iso-files/bin"
#if [ ! -f "${PROJECT_DIR}/helper-iso-files/bin/AutoHotkeyU64.exe" ]; then
# echo "> Downloading AutoHotkey..."
# rm -rf "${PROJECT_DIR}/mobile-passthrough-iso/tmp"
# mkdir -p "${PROJECT_DIR}/mobile-passthrough-iso/tmp"
# wget "https://autohotkey.com/download/ahk.zip" -O "${PROJECT_DIR}/mobile-passthrough-iso/tmp/ahk.zip"
# unzip "${PROJECT_DIR}/mobile-passthrough-iso/tmp/ahk.zip" -d "${PROJECT_DIR}/mobile-passthrough-iso/tmp/"
# rm -rf "${PROJECT_DIR}/helper-iso-files/tmp"
# mkdir -p "${PROJECT_DIR}/helper-iso-files/tmp"
# wget "https://autohotkey.com/download/ahk.zip" -O "${PROJECT_DIR}/helper-iso-files/tmp/ahk.zip"
# unzip "${PROJECT_DIR}/helper-iso-files/tmp/ahk.zip" -d "${PROJECT_DIR}/helper-iso-files/tmp/"
# echo "> Adding AutoHotkey to iso folder..."
# cp "${PROJECT_DIR}/mobile-passthrough-iso/tmp/AutoHotkeyU64.exe" "${PROJECT_DIR}/mobile-passthrough-iso/bin/"
# rm -rf "${PROJECT_DIR}/mobile-passthrough-iso/tmp"
# cp "${PROJECT_DIR}/helper-iso-files/tmp/AutoHotkeyU64.exe" "${PROJECT_DIR}/helper-iso-files/bin/"
# rm -rf "${PROJECT_DIR}/helper-iso-files/tmp"
#else
# echo "> AutoHotkey already exist in iso folder..."
#fi

if [ ! -f "${PROJECT_DIR}/mobile-passthrough-iso/bin/VC_redist.x64.exe" ]; then
if [ ! -f "${PROJECT_DIR}/helper-iso-files/bin/VC_redist.x64.exe" ]; then
echo "> Downloading Visual C++ Redistributable Package 2017 x64 for the Looking Glass Host application..."
wget "https://download.microsoft.com/download/8/9/D/89D195E1-1901-4036-9A75-FBE46443FC5A/VC_redist.x64.exe" -O "${PROJECT_DIR}/mobile-passthrough-iso/bin/VC_redist.x64.exe"
wget "https://download.microsoft.com/download/8/9/D/89D195E1-1901-4036-9A75-FBE46443FC5A/VC_redist.x64.exe" -O "${PROJECT_DIR}/helper-iso-files/bin/VC_redist.x64.exe"
else
echo "> Visual C++ Redistributable Package 2017 x64 already exist in iso folder..."
fi

if [ ! -f "${PROJECT_DIR}/mobile-passthrough-iso/bin/looking-glass-host.exe" ]; then
if [ ! -f "${PROJECT_DIR}/helper-iso-files/bin/looking-glass-host.exe" ]; then
echo "> Downloading Looking Glass Host application..."
wget "https://github.com/gnif/LookingGlass/releases/download/${LOOKING_GLASS_VERSION}/looking-glass-host.exe" -O "${PROJECT_DIR}/mobile-passthrough-iso/bin/looking-glass-host.exe"
wget "https://github.com/gnif/LookingGlass/releases/download/${LOOKING_GLASS_VERSION}/looking-glass-host.exe" -O "${PROJECT_DIR}/helper-iso-files/bin/looking-glass-host.exe"
else
echo "> Looking Glass Host application already exist in iso folder..."
fi

#if [ ! -f "${PROJECT_DIR}/mobile-passthrough-iso/bin/ivshmem-driver/ivshmem.cat" ] || [ ! -f "${PROJECT_DIR}/mobile-passthrough-iso/bin/ivshmem-driver/ivshmem.inf" ] || [ ! -f "${PROJECT_DIR}/mobile-passthrough-iso/bin/ivshmem-driver/ivshmem.pdb" ] || [ ! -f "${PROJECT_DIR}/mobile-passthrough-iso/bin/ivshmem-driver/ivshmem.sys" ]; then
#if [ ! -f "${PROJECT_DIR}/helper-iso-files/bin/ivshmem-driver/ivshmem.cat" ] || [ ! -f "${PROJECT_DIR}/helper-iso-files/bin/ivshmem-driver/ivshmem.inf" ] || [ ! -f "${PROJECT_DIR}/helper-iso-files/bin/ivshmem-driver/ivshmem.pdb" ] || [ ! -f "${PROJECT_DIR}/helper-iso-files/bin/ivshmem-driver/ivshmem.sys" ]; then
# echo "> Downloading IVSHMEM driver..."
# rm -rf "${PROJECT_DIR}/mobile-passthrough-iso/tmp"
# mkdir -p "${PROJECT_DIR}/mobile-passthrough-iso/tmp"
# wget "https://fedorapeople.org/groups/virt/virtio-win/direct-downloads/upstream-virtio/virtio-win10-prewhql-0.1-161.zip" -O "${PROJECT_DIR}/mobile-passthrough-iso/tmp/virtio-win10-prewhql.zip"
# unzip "${PROJECT_DIR}/mobile-passthrough-iso/tmp/virtio-win10-prewhql.zip" -d "${PROJECT_DIR}/mobile-passthrough-iso/tmp"
# rm -f "${PROJECT_DIR}/mobile-passthrough-iso/tmp/virtio-win10-prewhql.zip"
# rm -rf "${PROJECT_DIR}/mobile-passthrough-iso/bin/ivshmem-driver"
# mkdir -p "${PROJECT_DIR}/mobile-passthrough-iso/bin/ivshmem-driver"
# cp "${PROJECT_DIR}/mobile-passthrough-iso/tmp/Win10/amd64/ivshmem*" "${PROJECT_DIR}/mobile-passthrough-iso/bin/ivshmem-driver/"
# #cp -r "${PROJECT_DIR}/mobile-passthrough-iso/tmp" "${PROJECT_DIR}/mobile-passthrough-iso/bin/ivshmem-driver"
# rm -rf "${PROJECT_DIR}/mobile-passthrough-iso/tmp"
# rm -rf "${PROJECT_DIR}/helper-iso-files/tmp"
# mkdir -p "${PROJECT_DIR}/helper-iso-files/tmp"
# wget "https://fedorapeople.org/groups/virt/virtio-win/direct-downloads/upstream-virtio/virtio-win10-prewhql-0.1-161.zip" -O "${PROJECT_DIR}/helper-iso-files/tmp/virtio-win10-prewhql.zip"
# unzip "${PROJECT_DIR}/helper-iso-files/tmp/virtio-win10-prewhql.zip" -d "${PROJECT_DIR}/helper-iso-files/tmp"
# rm -f "${PROJECT_DIR}/helper-iso-files/tmp/virtio-win10-prewhql.zip"
# rm -rf "${PROJECT_DIR}/helper-iso-files/bin/ivshmem-driver"
# mkdir -p "${PROJECT_DIR}/helper-iso-files/bin/ivshmem-driver"
# cp "${PROJECT_DIR}/helper-iso-files/tmp/Win10/amd64/ivshmem*" "${PROJECT_DIR}/helper-iso-files/bin/ivshmem-driver/"
# #cp -r "${PROJECT_DIR}/helper-iso-files/tmp" "${PROJECT_DIR}/helper-iso-files/bin/ivshmem-driver"
# rm -rf "${PROJECT_DIR}/helper-iso-files/tmp"
#else
# echo "> IVSHMEM driver already exist in iso folder..."
#fi

if [ ! -d "${PROJECT_DIR}/mobile-passthrough-iso/bin/virtio-drivers/Win10" ]; then
if [ ! -d "${PROJECT_DIR}/helper-iso-files/bin/virtio-drivers/Win10" ]; then
echo "> Downloading virtio drivers..."
rm -rf "${PROJECT_DIR}/mobile-passthrough-iso/tmp"
mkdir -p "${PROJECT_DIR}/mobile-passthrough-iso/tmp"
wget "https://fedorapeople.org/groups/virt/virtio-win/direct-downloads/upstream-virtio/virtio-win10-prewhql-0.1-161.zip" -O "${PROJECT_DIR}/mobile-passthrough-iso/tmp/virtio-win10-prewhql.zip"
mkdir -p "${PROJECT_DIR}/mobile-passthrough-iso/bin/virtio-drivers"
unzip "${PROJECT_DIR}/mobile-passthrough-iso/tmp/virtio-win10-prewhql.zip" -d "${PROJECT_DIR}/mobile-passthrough-iso/bin/virtio-drivers"
rm -rf "${PROJECT_DIR}/mobile-passthrough-iso/tmp"
rm -rf "${PROJECT_DIR}/helper-iso-files/tmp"
mkdir -p "${PROJECT_DIR}/helper-iso-files/tmp"
wget "https://fedorapeople.org/groups/virt/virtio-win/direct-downloads/upstream-virtio/virtio-win10-prewhql-0.1-161.zip" -O "${PROJECT_DIR}/helper-iso-files/tmp/virtio-win10-prewhql.zip"
mkdir -p "${PROJECT_DIR}/helper-iso-files/bin/virtio-drivers"
unzip "${PROJECT_DIR}/helper-iso-files/tmp/virtio-win10-prewhql.zip" -d "${PROJECT_DIR}/helper-iso-files/bin/virtio-drivers"
rm -rf "${PROJECT_DIR}/helper-iso-files/tmp"
else
echo "> virtio drivers already exist in iso folder..."
fi

#if [ ! -f "${PROJECT_DIR}/mobile-passthrough-iso/bin/devcon.exe" ]; then
#if [ ! -f "${PROJECT_DIR}/helper-iso-files/bin/devcon.exe" ]; then
# echo "> Downloading Microsoft's devcon driver tool..."
# rm -rf "${PROJECT_DIR}/mobile-passthrough-iso/tmp"
# mkdir -p "${PROJECT_DIR}/mobile-passthrough-iso/tmp"
# wget "https://download.microsoft.com/download/B/5/8/B58D625D-17D6-47A8-B3D3-668670B6D1EB/wdk/Installers/787bee96dbd26371076b37b13c405890.cab" -O "${PROJECT_DIR}/mobile-passthrough-iso/tmp/devcon.cab"
# cabextract -d "${PROJECT_DIR}/mobile-passthrough-iso/tmp" "${PROJECT_DIR}/mobile-passthrough-iso/tmp/devcon.cab"
# cp "${PROJECT_DIR}/mobile-passthrough-iso/tmp/devcon.cab" "${PROJECT_DIR}/mobile-passthrough-iso/bin/devcon.exe"
# rm -rf "${PROJECT_DIR}/helper-iso-files/tmp"
# mkdir -p "${PROJECT_DIR}/helper-iso-files/tmp"
# wget "https://download.microsoft.com/download/B/5/8/B58D625D-17D6-47A8-B3D3-668670B6D1EB/wdk/Installers/787bee96dbd26371076b37b13c405890.cab" -O "${PROJECT_DIR}/helper-iso-files/tmp/devcon.cab"
# cabextract -d "${PROJECT_DIR}/helper-iso-files/tmp" "${PROJECT_DIR}/helper-iso-files/tmp/devcon.cab"
# cp "${PROJECT_DIR}/helper-iso-files/tmp/devcon.cab" "${PROJECT_DIR}/helper-iso-files/bin/devcon.exe"
# #TODO: check if installing the cabextract is necessary or if it actually is devcon directly
# rm -rf "${PROJECT_DIR}/mobile-passthrough-iso/tmp"
# rm -rf "${PROJECT_DIR}/helper-iso-files/tmp"
#else
# echo "> devcon driver tool already exist in iso folder..."
#fi

rm -rf "${PROJECT_DIR}/mobile-passthrough-iso/tmp"
rm -rf "${PROJECT_DIR}/helper-iso-files/tmp"

echo "> Generating new iso..."
rm -f "${PROJECT_DIR}/mobile-passthrough.iso"
Expand Down
3 changes: 2 additions & 1 deletion generate-vm-config.sh
Expand Up @@ -85,7 +85,8 @@ interactiveCfg "Enable QXL. (Required for Windows installation; has to be disabl
interactiveCfg "List of USB devices to pass through. (Semicolon separated, e.g. vendorid=0x0b12,productid=0x9348;vendorid=0x0b95,productid=0x1790)" USB_DEVICES
# TODO: Make selecting USB devices easier

source "$USER_CONFIG_FILE"
if [ ! -f "$INSTALL_IMG" ]; then
echo "'$INSTALL_IMG' does not exist and will be downloaded automatically now. If you don't want that, press Ctrl+C to cancel it."
$UTILS_DIR/download-windows-iso.sh
$UTILS_DIR/download-windows-iso "$INSTALL_IMG"
fi
File renamed without changes.
18 changes: 9 additions & 9 deletions start-vm.sh
Expand Up @@ -121,11 +121,11 @@ fi
if [ "$DGPU_PASSTHROUGH" = true ] ; then
echo "> Using dGPU passthrough..."
echo "> Unbinding dGPU from ${HOST_DGPU_DRIVER} driver..."
sudo echo "0000:${DGPU_PCI_ADDRESS}" | sudo tee "/sys/bus/pci/devices/0000:${DGPU_PCI_ADDRESS}/driver/unbind" > /dev/null
sudo bash -c "echo '0000:${DGPU_PCI_ADDRESS}' '/sys/bus/pci/devices/0000:${DGPU_PCI_ADDRESS}/driver/unbind'"
echo "> Binding dGPU to VFIO driver..."
sudo echo "${DGPU_VENDOR_ID} ${DGPU_DEVICE_ID}" | sudo tee "/sys/bus/pci/drivers/vfio-pci/new_id" > /dev/null
#sudo echo "options vfio-pci ids=${DGPU_VENDOR_ID}:${DGPU_DEVICE_ID}" | sudo tee /etc/modprobe.d/vfio.conf > /dev/null
#sudo echo "8086:1901" | sudo tee "/sys/bus/pci/drivers/vfio-pci/new_id" > /dev/null
sudo bash -c "echo '${DGPU_VENDOR_ID} ${DGPU_DEVICE_ID}' > '/sys/bus/pci/drivers/vfio-pci/new_id'"
#sudo bash -c "echo 'options vfio-pci ids=${DGPU_VENDOR_ID}:${DGPU_DEVICE_ID}' > '/etc/modprobe.d/vfio.conf'"
#sudo bash -c "echo '8086:1901' > '/sys/bus/pci/drivers/vfio-pci/new_id'"
# TODO: Make sure to also do the rebind for the other devices that are in the same iommu group (exclude stuff like PCI Bridge root ports that don't have vfio drivers)
DGPU_ROOT_PORT_PARAM="-device ioh3420,bus=pcie.0,addr=1c.0,multifunction=on,port=1,chassis=1,id=root.1"
DGPU_PARAM="-device vfio-pci,host=${DGPU_PCI_ADDRESS},bus=root.1,addr=00.0,x-pci-sub-device-id=0x${DGPU_SS_DEVICE_ID},x-pci-sub-vendor-id=0x${DGPU_SS_VENDOR_ID},multifunction=on${DGPU_ROM_PARAM}"
Expand All @@ -146,7 +146,7 @@ if [ "$SHARE_IGPU" = true ] ; then
VGPU_TYPE=$(basename -- "${VGPU_TYPE_DIR}")
# For further twaeking read: https://github.com/intel/gvt-linux/wiki/GVTg_Setup_Guide#53-create-vgpu-kvmgt-only
echo "> Create vGPU for mediated iGPU passthrough..."
sudo echo "${VGPU_UUID}" > "/sys/bus/pci/devices/0000:${IGPU_PCI_ADDRESS}/mdev_supported_types/${VGPU_TYPE}/create"
sudo bash -c "echo '${VGPU_UUID}' > '/sys/bus/pci/devices/0000:${IGPU_PCI_ADDRESS}/mdev_supported_types/${VGPU_TYPE}/create'"
# display=on when using dmabuf

if [ "$USE_DMA_BUF" = true ] ; then
Expand Down Expand Up @@ -185,7 +185,7 @@ if [ -z "$USB_DEVICES" ]; then
echo "> Not using USB passthrough..."
USB_DEVICE_PARAMS=""
else
echo "> Using USB passthorugh..."
echo "> Using USB passthrough..."
IFS=';' read -a USB_DEVICES_ARRAY <<< "${USB_DEVICES}"
USB_DEVICE_PARAMS=""
for USB_DEVICE in "${USB_DEVICES_ARRAY[@]}"; do
Expand Down Expand Up @@ -252,10 +252,10 @@ sudo qemu-system-x86_64 \
# This gets executed when the vm exits
echo "> Binding dGPU back to ${HOST_DGPU_DRIVER} driver..."
if [ "$DGPU_PASSTHROUGH" = true ] ; then
sudo echo "0000:${DGPU_PCI_ADDRESS}" | sudo tee "/sys/bus/pci/drivers/vfio-pci/0000:${DGPU_PCI_ADDRESS}/driver/unbind" > /dev/null
sudo bash -c 'echo "OFF" >> /proc/acpi/bbswitch'
sudo bash -c "echo '0000:${DGPU_PCI_ADDRESS}' > '/sys/bus/pci/drivers/vfio-pci/0000:${DGPU_PCI_ADDRESS}/driver/unbind'"
sudo bash -c "echo 'OFF' >> /proc/acpi/bbswitch"
fi
if [ "$SHARE_IGPU" = true ] ; then
echo "> Remove Intel vGPU..."
sudo echo 1 > "/sys/bus/pci/devices/0000:${IGPU_PCI_ADDRESS}/${VGPU_UUID}/remove"
sudo bash -c "echo 1 > '/sys/bus/pci/devices/0000:${IGPU_PCI_ADDRESS}/${VGPU_UUID}/remove'"
fi
18 changes: 8 additions & 10 deletions utils/download-windows-iso.sh → utils/download-windows-iso 100644 → 100755
@@ -1,24 +1,22 @@
#!/usr/bin/env bash

SCRIPT_DIR=$(cd "$(dirname "$0")"; pwd)
PROJECT_DIR="${SCRIPT_DIR}/.."
UTILS_DIR="${PROJECT_DIR}/utils"
DISTRO=$("${UTILS_DIR}/distro-info")
DISTRO_UTILS_DIR="${UTILS_DIR}/${DISTRO}"
WIN10_IMG_DESTINATION="$1"
WIN10_IMG_ARCH="$2"
echo "$WIN10_IMG_DESTINATION"

if [[ "$WIN10_IMG_ARCH" == "x86" ]] || [[ "$WIN10_IMG_ARCH" == "i386" ]] ; then
echo "Retrieving the x86 Windows 10 iso URL."
echo "Retrieving the x86 Windows 10 iso URL..."
WINDOWS_10_ISO_URL=$(curl -LsI -o /dev/null -w %{url_effective} "https://www.itechtics.com/?dl_id=71")
else
echo "Retrieving the x64 Windows 10 iso URL."
echo "Retrieving the x64 Windows 10 iso URL..."
WINDOWS_10_ISO_URL=$(curl -LsI -o /dev/null -w %{url_effective} "https://www.itechtics.com/?dl_id=70")
fi

echo "Making sure the URL comes from a trusted Microsoft domain..."
if [[ $WINDOWS_10_ISO_URL == https://software-download.microsoft.com/* ]] ; then
echo "Downloading the Windows 10 installation iso."
wget "$WINDOWS_10_ISO_URL" -O "$VM_FILES_DIR/windows10.iso"
echo "Downloading the Windows 10 installation iso..."
wget "$WINDOWS_10_ISO_URL" -O "$WIN10_IMG_DESTINATION"
else
echo "URL validation failed. Please download the Windows 10 iso manually."
exit 1
fi
fi

0 comments on commit a1fb734

Please sign in to comment.