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_spinlocks=0x1fff,hv_vpindex,hv_reset,hv_runtime,hv_crash,hv_vendor_id=freyja"
- OPTS="$OPTS -smp cpus=12,cores=6,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.6,accel=kvm,usb=off,vmport=off,kernel_irqchip=on"
- OPTS="$OPTS -nodefaults"
- OPTS="$OPTS -nodefconfig"
- # Random number generator
- OPTS="$OPTS -device virtio-rng-pci"
- # 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"
- # GPU passthrough (Gigabyte GeForce GTX 980 G1 Gaming)
- OPTS="$OPTS -device vfio-pci,host=03:00.0,multifunction=on"
- OPTS="$OPTS -device vfio-pci,host=03:00.1"
- # USB 3.0 passthrough (ASMedia ASM1042A USB 3.0 Host Controller)
- OPTS="$OPTS -device vfio-pci,host=07:00.0"
- # Gigabit network passthrough (Intel 82574L Gigabit Network Connection)
- OPTS="$OPTS -device vfio-pci,host=08:00.0"
- # USB 3.0 passthrough (Renesas Technology Corp. uPD720201 USB 3.0 Host Controller)
- OPTS="$OPTS -device vfio-pci,host=09: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 split image
- OPTS="$OPTS -drive if=pflash,format=raw,file=/data/machines/$VM_NAME/ovmf/OVMF_CODE-pure-efi.fd,readonly"
- 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,aio=threads,cache=unsafe,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"
- # Game drive
- OPTS="$OPTS -drive id=disk1,if=none,aio=native,cache=none,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"
- # Backup drive
- OPTS="$OPTS -drive id=disk2,if=none,aio=native,cache=none,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 installer media
- 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 media
- 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"
- # USB wireless adapter passthrough
- #OPTS="$OPTS -usb"
- #OPTS="$OPTS -device usb-host,hostbus=3,hostaddr=3"
- # 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 BenQ XL2420G display
- #xrandr --output DVI-I-1 --off --output HDMI-0 --mode 1920x1080 --pos 0x0 --rotate normal
- #xrandr --output HDMI-0 --off --output DVI-I-1 --mode 1920x1080 --pos 0x0 --rotate normal
- # Start the machine
- sudo taskset -c 0-11 qemu-system-$PLATFORM $OPTS
- # Restore BenQ XL2420G display
- #xrandr --output HDMI-0 --mode 1920x1080 --pos 0x0 --rotate normal --output DVI-I-1 --mode 1920x1080 --pos 1920x0 --rotate normal
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement