Advertisement
ohetfi

qemu-kvm-windows-10-pro.sh

Nov 30th, 2015
143
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 4.67 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. # QEMU name and PID
  4. VM_NAME="windows-10-pro"
  5. PLATFORM="x86_64"
  6. OPTS="-name $VM_NAME"
  7. OPTS="$OPTS -pidfile /run/qemu_$VM_NAME.pid"
  8.  
  9. # Processor
  10. OPTS="$OPTS -cpu host,kvm=off,hv_time,hv_relaxed,hv_vapic,hv_spinlocks=0x1fff,hv_vendor_id=freyja"
  11. OPTS="$OPTS -smp cpus=8,cores=4,threads=2,sockets=1"
  12. OPTS="$OPTS -enable-kvm"
  13.  
  14. # Memory
  15. OPTS="$OPTS -m size=16G"
  16. OPTS="$OPTS -mem-path /dev/hugepages"
  17. OPTS="$OPTS -mem-prealloc"
  18. OPTS="$OPTS -balloon none"
  19.  
  20. # Machine
  21. OPTS="$OPTS -machine type=pc-i440fx-2.5,accel=kvm"
  22.  
  23. # The following setting enables S3 (suspend to RAM). OVMF supports S3
  24. # suspend/resume. Disable when using Q35
  25. OPTS="$OPTS -global PIIX4_PM.disable_s3=0"
  26.  
  27. # Hardware clock
  28. OPTS="$OPTS -rtc clock=host,base=utc"
  29.  
  30. # Sound hardware
  31. export QEMU_AUDIO_DRV=alsa
  32. OPTS="$OPTS -device AC97"
  33.  
  34. # Virtual Primary GPU
  35. #OPTS="$OPTS -device qxl-vga"
  36.  
  37. # Virtual Secondary GPU
  38. #OPTS="$OPTS -device qxl"
  39.  
  40. # Disable display
  41. OPTS="$OPTS -vga none"
  42. OPTS="$OPTS -serial null"
  43. OPTS="$OPTS -parallel null"
  44. OPTS="$OPTS -display none"
  45.  
  46. # Graphic card passthrough (Gigabyte GeForce GTX 980 G1 Gaming)
  47. OPTS="$OPTS -device vfio-pci,host=01:00.0,multifunction=on"
  48. OPTS="$OPTS -device vfio-pci,host=01:00.1"
  49.  
  50. # Graphic card passthrough (MSI GeForce GTX 560 Ti Hawk)
  51. #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"
  52. #OPTS="$OPTS -device vfio-pci,host=02:00.1"
  53.  
  54. # USB 3.0 passthrough (NEC/Renesas)
  55. OPTS="$OPTS -device vfio-pci,host=08:00.0"
  56.  
  57. # Keyboard layout
  58. OPTS="$OPTS -k en-us"
  59.  
  60. # Input passthrough
  61. #OPTS="$OPTS -input-linux /dev/input/by-id/usb-Logitech_Gaming_Mouse_G502_1192346A3437-event-mouse"
  62. #OPTS="$OPTS -input-linux /dev/input/by-id/usb-04d9_USB_Keyboard-event-kbd,grab-all=on"
  63.  
  64. # Boot priority
  65. OPTS="$OPTS -boot order=c"
  66.  
  67. # OVMF
  68. OPTS="$OPTS -drive if=pflash,format=raw,readonly,file=/data/machines/$VM_NAME/ovmf/OVMF_CODE-pure-efi.fd"
  69. OPTS="$OPTS -drive if=pflash,format=raw,file=/data/machines/$VM_NAME/ovmf/OVMF_VARS-pure-efi.fd"
  70.  
  71. # System drive
  72. 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"
  73. OPTS="$OPTS -device driver=virtio-scsi-pci,id=scsi0"
  74. OPTS="$OPTS -device scsi-hd,drive=disk0"
  75.  
  76. # 1st Game drive
  77. 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"
  78. OPTS="$OPTS -device driver=virtio-scsi-pci,id=scsi1"
  79. OPTS="$OPTS -device scsi-hd,drive=disk1"
  80.  
  81. # 2nd Game drive
  82. 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"
  83. OPTS="$OPTS -device driver=virtio-scsi-pci,id=scsi2"
  84. OPTS="$OPTS -device scsi-hd,drive=disk2"
  85.  
  86. # Windows 10 Pro installer
  87. OPTS="$OPTS -drive id=cd0,if=none,format=raw,readonly,file=/data/machines/$VM_NAME/iso/Windows10_Threshold2_EN_64Bit.iso"
  88. OPTS="$OPTS -device driver=ide-cd,bus=ide.0,drive=cd0"
  89.  
  90. # Virtio driver
  91. OPTS="$OPTS -drive id=virtiocd,if=none,format=raw,file=/data/iso/VirtIO/virtio-win-0.1.110.iso"
  92. OPTS="$OPTS -device driver=ide-cd,bus=ide.1,drive=virtiocd"
  93.  
  94. # OVMF emits a number of info / debug messages to the QEMU debug console, at
  95. # ioport 0x402. We configure qemu so that the debug console is indeed
  96. # available at that ioport. We redirect the host side of the debug console to
  97. # a file.
  98. OPTS="$OPTS -global isa-debugcon.iobase=0x402 -debugcon file:/tmp/qemu_$VM_NAME.ovmf.log"
  99.  
  100. # QEMU accepts various commands and queries from the user on the monitor
  101. # interface. Connect the monitor with the qemu process's standard input and
  102. # output.
  103. OPTS="$OPTS -monitor stdio"
  104.  
  105. # A USB tablet device in the guest allows for accurate pointer tracking
  106. # between the host and the guest.
  107. OPTS="$OPTS -usb"
  108. OPTS="$OPTS -device usb-tablet"
  109. OPTS="$OPTS -device piix3-usb-uhci"
  110.  
  111. # Network
  112. OPTS="$OPTS -netdev tap,vhost=on,id=brlan"
  113. OPTS="$OPTS -device virtio-net-pci,mac=$(/usr/local/bin/qemu-mac-hasher $VM_NAME),netdev=brlan"
  114.  
  115. # QEMU Guest Agent
  116. OPTS="$OPTS -chardev socket,path=/tmp/qga_$VM_NAME.sock,server,nowait,id=qga_$VM_NAME"
  117. OPTS="$OPTS -device virtio-serial"
  118. OPTS="$OPTS -device virtserialport,chardev=qga_$VM_NAME,name=org.qemu.guest_agent.$VM_NAME"
  119.  
  120. sudo echo "Starting $VM_NAME machine"
  121.  
  122. # Disable Dell U2312HM display
  123. xrandr --output HDMI1 --off --output HDMI3 --mode 1920x1080 --pos 0x0 --rotate normal
  124.  
  125. # Start the machine
  126. sudo taskset -c 0-7 qemu-system-$PLATFORM $OPTS
  127.  
  128. # Restore Dell U2312HM display
  129. 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