ohetfi

qemu-kvm-windows-7-pro.sh

Dec 11th, 2015
405
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 3.59 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. # QEMU name and PID
  4. VM_NAME="windows-7-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=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.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. # Disable display
  35. OPTS="$OPTS -vga none"
  36. OPTS="$OPTS -serial null"
  37. OPTS="$OPTS -parallel null"
  38. OPTS="$OPTS -display none"
  39. OPTS="$OPTS -nographic"
  40.  
  41. # Primary GPU
  42. #OPTS="$OPTS -device qxl-vga"
  43.  
  44. # Graphic card passthrough (Gigabyte GeForce GTX 980 G1 Gaming)
  45. OPTS="$OPTS -device vfio-pci,host=03:00.0,multifunction=on,x-vga=on"
  46. OPTS="$OPTS -device vfio-pci,host=03:00.1"
  47.  
  48. # Graphic card passthrough (MSI GeForce GTX 560 Ti Hawk)
  49. #OPTS="$OPTS -device vfio-pci,host=02:00.0,multifunction=on,x-vga=on,romfile=/data/machines/$VM_NAME/rom/MSI.GTX560Ti.1024.110315.rom"
  50. #OPTS="$OPTS -device vfio-pci,host=02:00.1"
  51.  
  52. # USB 3.0 passthrough (NEC/Renesas)
  53. OPTS="$OPTS -device vfio-pci,host=09:00.0"
  54.  
  55. # Keyboard layout
  56. OPTS="$OPTS -k en-us"
  57.  
  58. # Input passthrough
  59. #OPTS="$OPTS -input-linux /dev/input/by-id/usb-Logitech_Gaming_Mouse_G502_1192346A3437-event-mouse"
  60. #OPTS="$OPTS -input-linux /dev/input/by-id/usb-04d9_USB_Keyboard-event-kbd"
  61.  
  62. # Boot priority
  63. OPTS="$OPTS -boot order=c"
  64.  
  65. # System drive
  66. 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"
  67. OPTS="$OPTS -device driver=virtio-scsi-pci,id=scsi0"
  68. OPTS="$OPTS -device scsi-hd,drive=disk0"
  69.  
  70. # Windows 7 Pro installer
  71. #OPTS="$OPTS -drive id=cd0,if=none,format=raw,readonly,file=/data/machines/$VM_NAME/iso/PreActivated/Win7Ult-SP1-x64-en-US-Sep2013.iso"
  72. #OPTS="$OPTS -device driver=ide-cd,bus=ide.0,drive=cd0"
  73.  
  74. # Virtio driver
  75. #OPTS="$OPTS -drive id=virtiocd,if=none,format=raw,file=/data/iso/VirtIO/virtio-win-0.1.110.iso"
  76. #OPTS="$OPTS -device driver=ide-cd,bus=ide.1,drive=virtiocd"
  77.  
  78. # QEMU accepts various commands and queries from the user on the monitor
  79. # interface. Connect the monitor with the qemu process's standard input and
  80. # output.
  81. OPTS="$OPTS -monitor stdio"
  82.  
  83. # A USB tablet device in the guest allows for accurate pointer tracking
  84. # between the host and the guest.
  85. OPTS="$OPTS -usb"
  86. OPTS="$OPTS -device usb-tablet"
  87. OPTS="$OPTS -device piix3-usb-uhci"
  88.  
  89. # Network
  90. OPTS="$OPTS -netdev tap,vhost=on,id=brlan"
  91. OPTS="$OPTS -device virtio-net-pci,mac=$(/usr/local/bin/qemu-mac-hasher $VM_NAME),netdev=brlan"
  92.  
  93. # QEMU Guest Agent
  94. OPTS="$OPTS -chardev socket,path=/tmp/qga_$VM_NAME.sock,server,nowait,id=qga_$VM_NAME"
  95. OPTS="$OPTS -device virtio-serial"
  96. OPTS="$OPTS -device virtserialport,chardev=qga_$VM_NAME,name=org.qemu.guest_agent.$VM_NAME"
  97.  
  98. sudo echo "Starting $VM_NAME machine"
  99.  
  100. # Disable Dell U2312HM display
  101. xrandr --output DVI-I-1 --off --output HDMI-0 --mode 1920x1080 --pos 0x0 --rotate normal
  102.  
  103. # Start the machine
  104. sudo taskset -c 0-11 qemu-system-$PLATFORM $OPTS
  105.  
  106. # Restore Dell U2312HM display
  107. xrandr --output DVI-I-1 --mode 1920x1080 --pos 0x0 --rotate normal --output HDMI-0 --mode 1920x1080 --pos 1920x0 --rotate normal
Advertisement
Add Comment
Please, Sign In to add comment