Skip to content

Commit

Permalink
Clean up vm.sh; Add plugin mechanism for display modes
Browse files Browse the repository at this point in the history
  • Loading branch information
T-vK committed Aug 24, 2021
1 parent 708e580 commit 5d3e652
Show file tree
Hide file tree
Showing 14 changed files with 559 additions and 555 deletions.
55 changes: 7 additions & 48 deletions default.conf
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ DGPU_PCI_ADDRESS=auto # Required; If you don't use Bumblebee, you have to set th
# This project has only been tested with Bumblebee enabled.
IGPU_PCI_ADDRESS=auto # Recommended; required for mediated iGPU passthrough. you can cehck your iGPU PCI address using lspci

DGPU_PASSTHROUGH=true # Recommended
DGPU_PASSTHROUGH=auto # Recommended

SHARE_IGPU=auto # Recommended to save battery life (this is mediated iGPU passthrough using GVT-g)

Expand All @@ -34,59 +34,18 @@ HOST_DGPU_DRIVER=auto # Only tested with "nvidia" and "amdgpu", not tested with
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"

MAC_ADDRESS="" # Required
NETWORK_MODE=TAP # This option is currently ignored (bridged, NAT and none don't work atm)
NETWORK_MODE="bridged" # Supports bridged or none

USE_LOOKING_GLASS=true # Optional
LOOKING_GLASS_MAX_SCREEN_WIDTH=1920 # Recommended (bigger resolutions will result in a bigger buffer with worse performance)
LOOKING_GLASS_MAX_SCREEN_HEIGHT=1080 # Recommended (bigger resolutions will result in a bigger buffer with worse performance)
LOOKING_GLASS_VERSION=B4 # Recommended
LOOKING_GLASS_MAX_SCREEN_WIDTH=1920 # 1920 Recommended (bigger resolutions will result in a bigger buffer with worse performance)
LOOKING_GLASS_MAX_SCREEN_HEIGHT=1080 # 1080 Recommended (bigger resolutions will result in a bigger buffer with worse performance)
LOOKING_GLASS_VERSION=B4 # B4 Recommended

USE_SPICE=true # Required for Windows installation and recommended for Looking Glass
SPICE_PORT=5900 # 5900 is recommended
SPICE_PORT=5904 # 5900 is the normal port, but it may already be used by something else on your system like VNC

USE_SPICE_CLIENT="true" # Required for installation

USE_DMA_BUF=false # Optional

USE_QXL=true # Required for RDP

DISPLAY_MODE=1

# DISPLAY_MODES
# if [ "$DISPLAY_MODE" == 1 ]; then
# if [ "$DMA_BUF_AVAILABLE" == true ]; then
# LOOKING_GLASS=true
# DMA_BUF=true
# QXL=false
# RDP=false
# else
# DMA_BUF=false
# RDP=true
# if [ "$VM_INSTALL" == true ]; then
# QXL=true
# LOOKING_GLASS=false
# else
# QXL=false
# LOOKING_GLASS=true
# fi
# fi
# elif [ "$DISPLAY_MODE" == 2 ]; then
# RDP=true
# if [ "$DMA_BUF_AVAILABLE" == true ]; then
# LOOKING_GLASS=true
# DMA_BUF=true
# QXL=false
# else
# DMA_BUF=false
# if [ "$VM_INSTALL" == true ]; then
# QXL=true
# LOOKING_GLASS=false
# else
# QXL=false
# LOOKING_GLASS=true
# fi
# fi
# fi
DISPLAY_MODE=4 # See scripts/utils/common/plugins ; Mode 4 is the only working one atm ; Looking Glass doesn't play nicely yet

USE_FAKE_BATTERY="true" # Recommended to avoid Error 43

Expand Down
2 changes: 0 additions & 2 deletions scripts/main/generate-helper-iso.sh
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,6 @@ else
echo "> Spice WebDAV daemon already exists in iso folder..."
fi

https://www.spice-space.org/download/windows/spice-webdavd/spice-webdavd-x64-2.4.msi

if [ ! -f "${HELPER_ISO_FILES_DIR}/bin/looking-glass-host-setup.exe" ]; then
#echo "> Downloading Looking Glass Host application..."
#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"
Expand Down
45 changes: 17 additions & 28 deletions scripts/main/generate-vm-config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ interactiveCfg() {
# TODO: change modified value on config file USER_CONFIG_FILE
}

echo "!!!!!!"
echo "IF IN DOUBT WITH ANY OF THE FOLLOWING, JUST PRESS ENTER TO USE THE RECOMMENDED/DEFAULT VALUE!"
echo "!!!!!!"
echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
echo "!!IF IN DOUBT WITH ANY OF THE FOLLOWING, JUST PRESS ENTER TO USE THE RECOMMENDED/DEFAULT VALUE!!"
echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
interactiveCfg "Where should the VM files be saved?" VM_FILES_DIR
echo "> Directory set to '${VM_FILES_DIR}'"

Expand All @@ -52,45 +52,34 @@ cp "${PROJECT_DIR}/default.conf" "${USER_CONFIG_FILE}"
echo "> Config will be created at ${USER_CONFIG_FILE}'"

interactiveCfg "What should the name of the VM be?" VM_NAME
interactiveCfg "Where to save the VM drive image?" DRIVE_IMG
interactiveCfg "Where to save the VM drive image? (At least 40G is highly recommended; Can't be changed wihtout a reinstall)" DRIVE_IMG
interactiveCfg "How big should the VM drive image be?" VM_DISK_SIZE
interactiveCfg "How many CPU cores should the VM get?" CPU_CORE_COUNT
interactiveCfg "How much RAM should the VM get?" RAM_SIZE
interactiveCfg "Path to your Windows installation iso. (If it doesn't exist it will be downloaded automatically.)" INSTALL_IMG
interactiveCfg "How many CPU cores should the VM get? (e.g. 8 or auto; auto=AVAILABLE_CORES-1G)" CPU_CORE_COUNT
interactiveCfg "How much RAM should the VM get? (e.g. 16G or auto; auto=FREE_RAM-1G)" RAM_SIZE
interactiveCfg "Path to your Windows installation iso. (If it doesn't exist it will be downloaded to that location automatically.)" INSTALL_IMG
interactiveCfg "Path to a dGPU ROM. (Optional)" DGPU_ROM
interactiveCfg "Path to a iGPU ROM. (Optional)" IGPU_ROM
interactiveCfg "Path to a folder to share with the VM via SMB. (Optional)" SMB_SHARE_FOLDER
interactiveCfg "Location of OVMF_VARS.fd." OVMF_VARS
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
interactiveCfg "Location of OVMF_CODE.fd." OVMF_CODE
interactiveCfg "Location of helper iso or where to create it." HELPER_ISO
interactiveCfg "Pass the dGPU through to the VM." DGPU_PASSTHROUGH
interactiveCfg "Share the iGPU with the VM to allow using Optimus within the VM to save battery life" SHARE_IGPU
interactiveCfg "dGPU driver used by the Linux host (nvidia, nouveau, amdgpu, radeon). (nouveau & radeon are untested)" HOST_DGPU_DRIVER
interactiveCfg "The PCI address of your dGPU as obtained by 'lspci' or 'optimus lspci'. (01:00.0 if you use Bumblebee)" DGPU_PCI_ADDRESS
interactiveCfg "The PCI address of your iGPU as obtained by 'lspci'. (Usually 00:02.0)" IGPU_PCI_ADDRESS
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
interactiveCfg "Share the iGPU 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
interactiveCfg "dGPU driver used by the Linux host (E.g. nvidia, nouveau, amdgpu, radeon or auto to detect it automatically)" HOST_DGPU_DRIVER
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
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
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
interactiveCfg "MAC address to use or leave empty to generate a random one" MAC_ADDRESS
if [ "$MAC_ADDRESS" == "" ]; then
MAC_ADDRESS=$(printf '52:54:BE:EF:%02X:%02X\n' $((RANDOM%256)) $((RANDOM%256)))
echo "> MAC_ADDRESS generated: ${MAC_ADDRESS}"
echo "> Set MAC_ADDRESS to '${MAC_ADDRESS}'"
crudini --set "${USER_CONFIG_FILE}" "" "MAC_ADDRESS" "\"${MAC_ADDRESS}\""
fi
interactiveCfg "Network mode to use? Only supports TAP at the moment." NETWORK_MODE
interactiveCfg "Use Looking Glass to get super low latency video output." USE_LOOKING_GLASS
interactiveCfg "MAC address to use (e.g. 11:22:33:44:55:66 or auto to generate it automatically)" MAC_ADDRESS
interactiveCfg "Network mode to use? Only supports bridge at the moment." NETWORK_MODE
interactiveCfg "Max screen width with Looking Glass." LOOKING_GLASS_MAX_SCREEN_WIDTH
interactiveCfg "Max screen height with Looking Glass." LOOKING_GLASS_MAX_SCREEN_HEIGHT
interactiveCfg "Version of Looking Glass to use (B4 is highly recommended)" LOOKING_GLASS_VERSION
interactiveCfg "Enable spice. (Recommended for Looking Glass, required to install Windows)" USE_SPICE
interactiveCfg "Enable spice. (Leave this on unless you know what you're doing!)" USE_SPICE
interactiveCfg "Port to use for spice." SPICE_PORT
interactiveCfg "Enable dma-buf. (Yet another way to get display access to your VM)" USE_DMA_BUF
interactiveCfg "Enable QXL. (Required for Windows installation; has to be disabled after the Nvidia driver has been installed!)" USE_QXL
interactiveCfg "Display mode to use (e.g. 1 or 2 ... see scripts/utils/common/plugins)" DISPLAY_MODE
interactiveCfg "Provide the VM with a fake battery (Highly recommended to avoid Error 43)" USE_FAKE_BATTERY
interactiveCfg "Patch OVMF with your dGPU ROM if you supply one. (Highly recommended to avoid Error 43)" PATCH_OVMF_WITH_VROM
interactiveCfg "Tool to use to start/install the VM. (qemu or virt-install)" VM_START_MODE
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
# TODO: Auto detect PCI addresses for GPUs
# TODO: Don't ask for Bumblebee if there is no nvidia gpu
# TODO: Add auto option for CPU cores, RAM and dGPU driver
# TODO: Make selecting USB devices easier
Loading

0 comments on commit 5d3e652

Please sign in to comment.