Skip to content

Instantly share code, notes, and snippets.

@darkxanter
Last active February 7, 2017 17:47
Show Gist options
  • Save darkxanter/1d4f93352dffd437deadaebcc2f59e33 to your computer and use it in GitHub Desktop.
Save darkxanter/1d4f93352dffd437deadaebcc2f59e33 to your computer and use it in GitHub Desktop.
windows 10 + vga passthrough Nvidia GTX 980
#!/bin/bash
# QEMU name and PID
OPTS="-name windows-10-pro"
OPTS="$OPTS -pidfile /tmp/windows-10-pro.pid"
# Processor
#OPTS="$OPTS -cpu host,kvm=off"
OPTS="$OPTS -cpu host,kvm=off,hv_relaxed,hv_spinlocks=0x1fff,hv_vapic,hv_time,hv_vendor_id=whatever"
OPTS="$OPTS -smp 8,sockets=1,cores=4,threads=2"
OPTS="$OPTS -enable-kvm"
# Machine
OPTS="$OPTS -machine type=pc,accel=kvm"
#OPTS="$OPTS -machine type=pc-i440fx-2.1,accel=kvm"
#OPTS="$OPTS -machine type=q35,accel=kvm"
# The following setting enables S3 (suspend to RAM). OVMF supports S3
# suspend/resume. Disable when using Q35
OPTS="$OPTS -global PIIX4_PM.disable_s3=0"
# Memory
OPTS="$OPTS -m 16G"
OPTS="$OPTS -mem-path /dev/hugepages"
OPTS="$OPTS -mem-prealloc"
OPTS="$OPTS -balloon none"
# Hardware clock
OPTS="$OPTS -rtc clock=host,base=utc"
# Sound hardware
QEMU_PA_SAMPLES=128
export QEMU_AUDIO_DRV=pa
OPTS="$OPTS -soundhw hda"
# Graphic card passthrough GeForce GTX 980
OPTS="$OPTS -device ioh3420,addr=1c.0,multifunction=on,port=1,chassis=1,id=root.1"
OPTS="$OPTS -device vfio-pci,host=01:00.0,multifunction=on"
OPTS="$OPTS -device vfio-pci,host=01:00.1"
# USB 3.0 passthrough (NEC/Renesas)
#OPTS="$OPTS -device vfio-pci,host=03:00.0"
# USB 2.0 passthrough (NEC)
#OPTS="$OPTS -device vfio-pci,host=0a:01.0"
# Keyboard layout
#OPTS="$OPTS -k en-us"
# Boot priority
OPTS="$OPTS -boot order=c"
# OVMF
OVMF_DIR=/usr/share/ovmf/x64
cp $OVMF_DIR/ovmf_vars_x64.bin /tmp/my_vars.fd
OPTS="$OPTS -drive if=pflash,format=raw,readonly,file=$OVMF_DIR/ovmf_code_x64.bin"
OPTS="$OPTS -drive if=pflash,format=raw,file=/tmp/my_vars.fd"
# OPTS="$OPTS -drive if=pflash,format=raw,readonly,file=/data/machines/windows-10-pro/ovmf/OVMF_CODE-pure-efi.fd"
# OPTS="$OPTS -drive if=pflash,format=raw,file=/data/machines/windows-10-pro/ovmf/OVMF_VARS-pure-efi.fd"
# System drive
OPTS="$OPTS -drive id=disk0,if=none,format=qcow2,file=windows.qcow2,l2-cache-size=26M"
OPTS="$OPTS -device driver=virtio-scsi-pci,id=scsi0"
OPTS="$OPTS -device scsi-hd,drive=disk0"
# 1st drive
OPTS="$OPTS -drive id=disk1,if=none,cache=none,aio=native,format=raw,file=/dev/disk/by-id/ata-WDC_WD20EARS-00MVWB0_WD-WMAZA1486785-part5"
OPTS="$OPTS -device driver=virtio-scsi-pci,id=scsi1"
OPTS="$OPTS -device scsi-hd,drive=disk1"
# 2nd Game drive
OPTS="$OPTS -drive id=disk2,if=none,cache=none,aio=native,format=raw,file=/dev/disk/by-id/ata-WDC_WD1002FAEX-00Z3A0_WD-WCATRC214198-part5"
OPTS="$OPTS -device driver=virtio-scsi-pci,id=scsi2"
OPTS="$OPTS -device scsi-hd,drive=disk2"
# 3nd Game drive
OPTS="$OPTS -drive id=disk3,if=none,cache=none,aio=native,format=raw,file=/dev/disk/by-id/ata-WDC_WD20EARS-00MVWB0_WD-WMAZA1486785-part6"
OPTS="$OPTS -device driver=virtio-scsi-pci,id=scsi3"
OPTS="$OPTS -device scsi-hd,drive=disk3"
# Windows 10 Pro installer
OPTS="$OPTS -drive id=cd0,if=none,format=raw,readonly,file=win10_1607.iso"
OPTS="$OPTS -device driver=ide-cd,bus=ide.0,drive=cd0"
# Virtio driver
OPTS="$OPTS -drive id=virtiocd,if=none,format=raw,file=virtio-win-0.1.126.iso"
OPTS="$OPTS -device driver=ide-cd,bus=ide.1,drive=virtiocd"
# OVMF emits a number of info / debug messages to the QEMU debug console, at
# ioport 0x402. We configure qemu so that the debug console is indeed
# available at that ioport. We redirect the host side of the debug console to
# a file.
OPTS="$OPTS -global isa-debugcon.iobase=0x402 -debugcon file:/tmp/windows_10_pro.ovmf.log"
# QEMU accepts various commands and queries from the user on the monitor
# interface. Connect the monitor with the qemu process's standard input and
# output.
OPTS="$OPTS -monitor stdio"
# A USB tablet device in the guest allows for accurate pointer tracking
# between the host and the guest.
OPTS="$OPTS -device piix3-usb-uhci -device usb-tablet"
OPTS="$OPTS -usb -device usb-ehci,id=ehci"
# Network
# OPTS="$OPTS -netdev tap,vhost=on,ifname=$VM,script=/usr/local/bin/vm_ifup_brlan,id=brlan"
# OPTS="$OPTS -device virtio-net-pci,mac=52:54:00:xx:xx:xx,netdev=brlan"
MAC='52:54:58:fb:54:33'
OPTS="$OPTS -net nic,macaddr=$MAC,model=virtio"
OPTS="$OPTS -net bridge,br=br0"
# Disable display
#OPTS="$OPTS -vga qxl"
OPTS="$OPTS -vga none"
OPTS="$OPTS -serial null"
OPTS="$OPTS -parallel null"
#OPTS="$OPTS -monitor none"
OPTS="$OPTS -display none"
#OPTS="$OPTS -display gtk"
#OPTS="$OPTS -daemonize"
# QEMU Guest Agent
OPTS="$OPTS -chardev socket,path=/tmp/qga.sock,server,nowait,id=qga0"
OPTS="$OPTS -device virtio-serial"
OPTS="$OPTS -device virtserialport,chardev=qga0,name=org.qemu.guest_agent.0"
#sudo taskset -c 0-7 qemu-system-x86_64 $OPTS
sudo qemu-system-x86_64 $OPTS
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment