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"
- KVM_DIR="/data/machines/kvm"
- 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.5,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"
- # Disable display
- OPTS="$OPTS -vga none"
- OPTS="$OPTS -serial null"
- OPTS="$OPTS -parallel null"
- OPTS="$OPTS -display none"
- # GPU passthrough (MSI GeForce GTX 980 Ti Gaming 6G)
- 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"
- # USB 3.0 passthrough (Renesas Technology Corp. uPD720201 USB 3.0 Host Controller)
- OPTS="$OPTS -device vfio-pci,host=08:00.0"
- # Boot priority
- OPTS="$OPTS -boot order=c"
- # OVMF split image
- OPTS="$OPTS -drive if=pflash,format=raw,file=$KVM_DIR/$VM_NAME/ovmf/OVMF_CODE-pure-efi.fd,readonly"
- OPTS="$OPTS -drive if=pflash,format=raw,file=$KVM_DIR/$VM_NAME/ovmf/OVMF_VARS-pure-efi.fd"
- # System drive
- OPTS="$OPTS -object iothread,id=iothread0"
- OPTS="$OPTS -drive id=disk0,if=none,aio=threads,cache=unsafe,detect-zeroes=on,format=raw,file=$KVM_DIR/$VM_NAME/disks/disk0-system.img"
- OPTS="$OPTS -device driver=virtio-scsi-pci,id=scsi0,ioeventfd=on,iothread=iothread0"
- OPTS="$OPTS -device scsi-hd,drive=disk0"
- # Game drive
- OPTS="$OPTS -object iothread,id=iothread1"
- 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,ioeventfd=on,iothread=iothread1"
- OPTS="$OPTS -device scsi-hd,drive=disk1"
- # Backup drive
- OPTS="$OPTS -object iothread,id=iothread2"
- 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,ioeventfd=on,iothread=iothread2"
- OPTS="$OPTS -device scsi-hd,drive=disk2"
- # Windows 10 installer media
- OPTS="$OPTS -drive id=cd0,if=none,format=raw,readonly,file=$KVM_DIR/$VM_NAME/iso/Win10_1511_1_EnglishInternational_x64.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.117.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"
- # 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"
- # Start the machine
- sudo taskset -c 0-11 qemu-system-$PLATFORM $OPTS
Advertisement
Add Comment
Please, Sign In to add comment