Advertisement
ohetfi

qemu-windows10.sh

Feb 15th, 2016
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 5.10 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_spinlocks=0x1fff,hv_vpindex,hv_reset,hv_runtime,hv_crash,hv_vendor_id=freyja"
  11. OPTS="$OPTS -smp cpus=12,cores=6,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.6,accel=kvm,usb=off,vmport=off,kernel_irqchip=on"
  22. OPTS="$OPTS -nodefaults"
  23. OPTS="$OPTS -nodefconfig"
  24.  
  25. # Random number generator
  26. OPTS="$OPTS -device virtio-rng-pci"
  27.  
  28. # The following setting enables S3 (suspend to RAM). OVMF supports S3
  29. # suspend/resume. Disable when using Q35
  30. OPTS="$OPTS -global PIIX4_PM.disable_s3=0"
  31.  
  32. # Hardware clock
  33. OPTS="$OPTS -rtc clock=host,base=utc"
  34.  
  35. # Sound hardware
  36. export QEMU_AUDIO_DRV=alsa
  37. OPTS="$OPTS -device AC97"
  38.  
  39. # Virtual primary GPU
  40. #OPTS="$OPTS -device qxl-vga"
  41.  
  42. # Virtual secondary GPU
  43. #OPTS="$OPTS -device qxl"
  44.  
  45. # Disable display
  46. OPTS="$OPTS -vga none"
  47. OPTS="$OPTS -serial null"
  48. OPTS="$OPTS -parallel null"
  49. OPTS="$OPTS -display none"
  50.  
  51. # GPU passthrough (Gigabyte GeForce GTX 980 G1 Gaming)
  52. OPTS="$OPTS -device vfio-pci,host=03:00.0,multifunction=on"
  53. OPTS="$OPTS -device vfio-pci,host=03:00.1"
  54.  
  55. # USB 3.0 passthrough (ASMedia ASM1042A USB 3.0 Host Controller)
  56. OPTS="$OPTS -device vfio-pci,host=07:00.0"
  57.  
  58. # Gigabit network passthrough (Intel 82574L Gigabit Network Connection)
  59. OPTS="$OPTS -device vfio-pci,host=08:00.0"
  60.  
  61. # USB 3.0 passthrough (Renesas Technology Corp. uPD720201 USB 3.0 Host Controller)
  62. OPTS="$OPTS -device vfio-pci,host=09:00.0"
  63.  
  64. # Keyboard layout
  65. OPTS="$OPTS -k en-us"
  66.  
  67. # Input passthrough
  68. #OPTS="$OPTS -input-linux /dev/input/by-id/usb-Logitech_Gaming_Mouse_G502_1192346A3437-event-mouse"
  69. #OPTS="$OPTS -input-linux /dev/input/by-id/usb-04d9_USB_Keyboard-event-kbd,grab-all=on"
  70.  
  71. # Boot priority
  72. OPTS="$OPTS -boot order=c"
  73.  
  74. # OVMF split image
  75. OPTS="$OPTS -drive if=pflash,format=raw,file=/data/machines/$VM_NAME/ovmf/OVMF_CODE-pure-efi.fd,readonly"
  76. OPTS="$OPTS -drive if=pflash,format=raw,file=/data/machines/$VM_NAME/ovmf/OVMF_VARS-pure-efi.fd"
  77.  
  78. # System drive
  79. 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"
  80. OPTS="$OPTS -device driver=virtio-scsi-pci,id=scsi0"
  81. OPTS="$OPTS -device scsi-hd,drive=disk0"
  82.  
  83. # Game drive
  84. 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"
  85. OPTS="$OPTS -device driver=virtio-scsi-pci,id=scsi1"
  86. OPTS="$OPTS -device scsi-hd,drive=disk1"
  87.  
  88. # Backup drive
  89. 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"
  90. OPTS="$OPTS -device driver=virtio-scsi-pci,id=scsi2"
  91. OPTS="$OPTS -device scsi-hd,drive=disk2"
  92.  
  93. # Windows 10 installer media
  94. OPTS="$OPTS -drive id=cd0,if=none,format=raw,readonly,file=/data/machines/$VM_NAME/iso/Windows10_Threshold2_EN_64Bit.iso"
  95. OPTS="$OPTS -device driver=ide-cd,bus=ide.0,drive=cd0"
  96.  
  97. # Virtio driver media
  98. OPTS="$OPTS -drive id=virtiocd,if=none,format=raw,file=/data/iso/VirtIO/virtio-win-0.1.110.iso"
  99. OPTS="$OPTS -device driver=ide-cd,bus=ide.1,drive=virtiocd"
  100.  
  101. # OVMF emits a number of info / debug messages to the QEMU debug console, at
  102. # ioport 0x402. We configure qemu so that the debug console is indeed
  103. # available at that ioport. We redirect the host side of the debug console to
  104. # a file.
  105. OPTS="$OPTS -global isa-debugcon.iobase=0x402 -debugcon file:/tmp/qemu_$VM_NAME.ovmf.log"
  106.  
  107. # QEMU accepts various commands and queries from the user on the monitor
  108. # interface. Connect the monitor with the qemu process's standard input and
  109. # output.
  110. OPTS="$OPTS -monitor stdio"
  111.  
  112. # A USB tablet device in the guest allows for accurate pointer tracking
  113. # between the host and the guest.
  114. #OPTS="$OPTS -usb"
  115. #OPTS="$OPTS -device usb-tablet"
  116. #OPTS="$OPTS -device piix3-usb-uhci"
  117.  
  118. # USB wireless adapter passthrough
  119. #OPTS="$OPTS -usb"
  120. #OPTS="$OPTS -device usb-host,hostbus=3,hostaddr=3"
  121.  
  122. # Network
  123. #OPTS="$OPTS -netdev tap,vhost=on,id=brlan"
  124. #OPTS="$OPTS -device virtio-net-pci,mac=$(/usr/local/bin/qemu-mac-hasher $VM_NAME),netdev=brlan"
  125.  
  126. # QEMU Guest Agent
  127. OPTS="$OPTS -chardev socket,path=/tmp/qga_$VM_NAME.sock,server,nowait,id=qga_$VM_NAME"
  128. OPTS="$OPTS -device virtio-serial"
  129. OPTS="$OPTS -device virtserialport,chardev=qga_$VM_NAME,name=org.qemu.guest_agent.$VM_NAME"
  130.  
  131. sudo echo "Starting $VM_NAME machine"
  132.  
  133. # Disable BenQ XL2420G display
  134. #xrandr --output DVI-I-1 --off --output HDMI-0 --mode 1920x1080 --pos 0x0 --rotate normal
  135. #xrandr --output HDMI-0 --off --output DVI-I-1 --mode 1920x1080 --pos 0x0 --rotate normal
  136.  
  137. # Start the machine
  138. sudo taskset -c 0-11 qemu-system-$PLATFORM $OPTS
  139.  
  140. # Restore BenQ XL2420G display
  141. #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