Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- # QEMU name and PID
- VM_NAME="windows-10-pro"
- PLATFORM="x86_64"
- OPTS="-name $VM_NAME"
- OPTS="$OPTS -pidfile /run/qemu_$VM_NAME.pid"
- # Processor
- OPTS="$OPTS -cpu host,kvm=off,hv_time,hv_relaxed,hv_vapic,hv_spinlocks=0x1fff,hv_vendor_id=freyja"
- OPTS="$OPTS -smp cpus=8,cores=4,threads=2,sockets=1"
- OPTS="$OPTS -enable-kvm"
- # Memory
- OPTS="$OPTS -m size=16G"
- OPTS="$OPTS -mem-path /dev/hugepages"
- OPTS="$OPTS -mem-prealloc"
- OPTS="$OPTS -balloon none"
- # Machine
- OPTS="$OPTS -machine type=pc-i440fx-2.5,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"
- # Hardware clock
- OPTS="$OPTS -rtc clock=host,base=utc"
- # Sound hardware
- export QEMU_AUDIO_DRV=alsa
- OPTS="$OPTS -device AC97"
- # Virtual Primary GPU
- #OPTS="$OPTS -device qxl-vga"
- # Virtual Secondary GPU
- #OPTS="$OPTS -device qxl"
- # Disable display
- OPTS="$OPTS -vga none"
- OPTS="$OPTS -serial null"
- OPTS="$OPTS -parallel null"
- OPTS="$OPTS -display none"
- # Graphic card passthrough (Gigabyte GeForce GTX 980 G1 Gaming)
- OPTS="$OPTS -device vfio-pci,host=01:00.0,multifunction=on"
- OPTS="$OPTS -device vfio-pci,host=01:00.1"
- # Graphic card passthrough (MSI GeForce GTX 560 Ti Hawk)
- #OPTS="$OPTS -device vfio-pci,host=02:00.0,multifunction=on,x-vga=on,romfile=/data/machines/$VM_NAME/rom/MSI.GTX560Ti.1024.120215.rom"
- #OPTS="$OPTS -device vfio-pci,host=02:00.1"
- # USB 3.0 passthrough (NEC/Renesas)
- OPTS="$OPTS -device vfio-pci,host=08:00.0"
- # Keyboard layout
- OPTS="$OPTS -k en-us"
- # Input passthrough
- #OPTS="$OPTS -input-linux /dev/input/by-id/usb-Logitech_Gaming_Mouse_G502_1192346A3437-event-mouse"
- #OPTS="$OPTS -input-linux /dev/input/by-id/usb-04d9_USB_Keyboard-event-kbd,grab-all=on"
- # Boot priority
- OPTS="$OPTS -boot order=c"
- # OVMF
- OPTS="$OPTS -drive if=pflash,format=raw,readonly,file=/data/machines/$VM_NAME/ovmf/OVMF_CODE-pure-efi.fd"
- OPTS="$OPTS -drive if=pflash,format=raw,file=/data/machines/$VM_NAME/ovmf/OVMF_VARS-pure-efi.fd"
- # System drive
- OPTS="$OPTS -drive id=disk0,if=none,cache=unsafe,aio=threads,detect-zeroes=on,format=raw,file=/data/machines/$VM_NAME/disks/disk0-system.img"
- OPTS="$OPTS -device driver=virtio-scsi-pci,id=scsi0"
- OPTS="$OPTS -device scsi-hd,drive=disk0"
- # 1st Game drive
- OPTS="$OPTS -drive id=disk1,if=none,cache=none,aio=native,detect-zeroes=on,format=raw,file=/dev/disk/by-id/ata-Hitachi_HDS721050CLA660_JP1570FR1ZWP7K"
- 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,detect-zeroes=on,format=raw,file=/dev/disk/by-id/ata-Hitachi_HDS5C3020ALA632_ML0220F30NX2DD"
- OPTS="$OPTS -device driver=virtio-scsi-pci,id=scsi2"
- OPTS="$OPTS -device scsi-hd,drive=disk2"
- # Windows 10 Pro installer
- OPTS="$OPTS -drive id=cd0,if=none,format=raw,readonly,file=/data/machines/$VM_NAME/iso/Windows10_Threshold2_EN_64Bit.iso"
- OPTS="$OPTS -device driver=ide-cd,bus=ide.0,drive=cd0"
- # Virtio driver
- OPTS="$OPTS -drive id=virtiocd,if=none,format=raw,file=/data/iso/VirtIO/virtio-win-0.1.110.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/qemu_$VM_NAME.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 -usb"
- OPTS="$OPTS -device usb-tablet"
- OPTS="$OPTS -device piix3-usb-uhci"
- # Network
- OPTS="$OPTS -netdev tap,vhost=on,id=brlan"
- OPTS="$OPTS -device virtio-net-pci,mac=$(/usr/local/bin/qemu-mac-hasher $VM_NAME),netdev=brlan"
- # QEMU Guest Agent
- OPTS="$OPTS -chardev socket,path=/tmp/qga_$VM_NAME.sock,server,nowait,id=qga_$VM_NAME"
- OPTS="$OPTS -device virtio-serial"
- OPTS="$OPTS -device virtserialport,chardev=qga_$VM_NAME,name=org.qemu.guest_agent.$VM_NAME"
- sudo echo "Starting $VM_NAME machine"
- # Disable Dell U2312HM display
- xrandr --output HDMI1 --off --output HDMI3 --mode 1920x1080 --pos 0x0 --rotate normal
- # Start the machine
- sudo taskset -c 0-7 qemu-system-$PLATFORM $OPTS
- # Restore Dell U2312HM display
- xrandr --output HDMI1 --mode 1920x1080 --pos 0x0 --rotate normal --output HDMI3 --mode 1920x1080 --pos 1920x0 --rotate normal
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement