ohetfi

qemu-windows10-pro-20160509.sh

May 8th, 2016
270
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 4.18 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. # QEMU name and PID
  4. VM_NAME="windows-10-pro"
  5. PLATFORM="x86_64"
  6. KVM_DIR="/data/machines/kvm"
  7. OPTS="-name $VM_NAME"
  8. OPTS="$OPTS -pidfile /run/qemu_$VM_NAME.pid"
  9.  
  10. # Processor
  11. 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"
  12. OPTS="$OPTS -smp cpus=12,cores=6,threads=2,sockets=1"
  13. OPTS="$OPTS -enable-kvm"
  14.  
  15. # Memory
  16. OPTS="$OPTS -m size=16G"
  17. OPTS="$OPTS -mem-path /dev/hugepages"
  18. OPTS="$OPTS -mem-prealloc"
  19. OPTS="$OPTS -balloon none"
  20.  
  21. # Machine
  22. OPTS="$OPTS -machine type=pc-i440fx-2.5,accel=kvm,usb=off,vmport=off,kernel_irqchip=on"
  23. OPTS="$OPTS -nodefaults"
  24. OPTS="$OPTS -nodefconfig"
  25.  
  26. # Random number generator
  27. OPTS="$OPTS -device virtio-rng-pci"
  28.  
  29. # The following setting enables S3 (suspend to RAM). OVMF supports S3
  30. # suspend/resume. Disable when using Q35
  31. OPTS="$OPTS -global PIIX4_PM.disable_s3=0"
  32.  
  33. # Hardware clock
  34. OPTS="$OPTS -rtc clock=host,base=utc"
  35.  
  36. # Sound hardware
  37. export QEMU_AUDIO_DRV=alsa
  38. OPTS="$OPTS -device AC97"
  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. # GPU passthrough (MSI GeForce GTX 980 Ti Gaming 6G)
  47. OPTS="$OPTS -device vfio-pci,host=03:00.0,multifunction=on"
  48. OPTS="$OPTS -device vfio-pci,host=03:00.1"
  49.  
  50. # USB 3.0 passthrough (ASMedia ASM1042A USB 3.0 Host Controller)
  51. OPTS="$OPTS -device vfio-pci,host=07:00.0"
  52.  
  53. # USB 3.0 passthrough (Renesas Technology Corp. uPD720201 USB 3.0 Host Controller)
  54. OPTS="$OPTS -device vfio-pci,host=08:00.0"
  55.  
  56. # Boot priority
  57. OPTS="$OPTS -boot order=c"
  58.  
  59. # OVMF split image
  60. OPTS="$OPTS -drive if=pflash,format=raw,file=$KVM_DIR/$VM_NAME/ovmf/OVMF_CODE-pure-efi.fd,readonly"
  61. OPTS="$OPTS -drive if=pflash,format=raw,file=$KVM_DIR/$VM_NAME/ovmf/OVMF_VARS-pure-efi.fd"
  62.  
  63. # System drive
  64. OPTS="$OPTS -object iothread,id=iothread0"
  65. 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"
  66. OPTS="$OPTS -device driver=virtio-scsi-pci,id=scsi0,ioeventfd=on,iothread=iothread0"
  67. OPTS="$OPTS -device scsi-hd,drive=disk0"
  68.  
  69. # Game drive
  70. OPTS="$OPTS -object iothread,id=iothread1"
  71. 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"
  72. OPTS="$OPTS -device driver=virtio-scsi-pci,id=scsi1,ioeventfd=on,iothread=iothread1"
  73. OPTS="$OPTS -device scsi-hd,drive=disk1"
  74.  
  75. # Backup drive
  76. OPTS="$OPTS -object iothread,id=iothread2"
  77. 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"
  78. OPTS="$OPTS -device driver=virtio-scsi-pci,id=scsi2,ioeventfd=on,iothread=iothread2"
  79. OPTS="$OPTS -device scsi-hd,drive=disk2"
  80.  
  81. # Windows 10 installer media
  82. OPTS="$OPTS -drive id=cd0,if=none,format=raw,readonly,file=$KVM_DIR/$VM_NAME/iso/Win10_1511_1_EnglishInternational_x64.iso"
  83. OPTS="$OPTS -device driver=ide-cd,bus=ide.0,drive=cd0"
  84.  
  85. # Virtio driver media
  86. OPTS="$OPTS -drive id=virtiocd,if=none,format=raw,file=/data/iso/VirtIO/virtio-win-0.1.117.iso"
  87. OPTS="$OPTS -device driver=ide-cd,bus=ide.1,drive=virtiocd"
  88.  
  89. # OVMF emits a number of info / debug messages to the QEMU debug console, at
  90. # ioport 0x402. We configure qemu so that the debug console is indeed
  91. # available at that ioport. We redirect the host side of the debug console to
  92. # a file.
  93. OPTS="$OPTS -global isa-debugcon.iobase=0x402 -debugcon file:/tmp/qemu_$VM_NAME.ovmf.log"
  94.  
  95. # QEMU accepts various commands and queries from the user on the monitor
  96. # interface. Connect the monitor with the qemu process's standard input and
  97. # output.
  98. OPTS="$OPTS -monitor stdio"
  99.  
  100. # Network
  101. OPTS="$OPTS -netdev tap,vhost=on,id=brlan"
  102. OPTS="$OPTS -device virtio-net-pci,mac=$(/usr/local/bin/qemu-mac-hasher $VM_NAME),netdev=brlan"
  103.  
  104. # QEMU Guest Agent
  105. OPTS="$OPTS -chardev socket,path=/tmp/qga_$VM_NAME.sock,server,nowait,id=qga_$VM_NAME"
  106. OPTS="$OPTS -device virtio-serial"
  107. OPTS="$OPTS -device virtserialport,chardev=qga_$VM_NAME,name=org.qemu.guest_agent.$VM_NAME"
  108.  
  109. sudo echo "Starting $VM_NAME machine"
  110.  
  111. # Start the machine
  112. sudo taskset -c 0-11 qemu-system-$PLATFORM $OPTS
Advertisement
Add Comment
Please, Sign In to add comment