Advertisement
Guest User

DrownedFire's Nodefaults QEMU Script

a guest
May 4th, 2018
637
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 5.48 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. sudo ip tuntap add tap1 mode tap user $(whoami) # Create tap interface
  4. sudo ip link set dev tap1 address 52:54:BE:EF:E3:A6
  5. sudo ip link set tap1 up # Set tap up
  6. sudo route add -host 192.168.1.110 tap1 # Create distinct host-only route for the VM address
  7. sudo sysctl net.ipv4.conf.tap1.proxy_arp=1 # Enable tap ARP
  8. sudo sysctl net.ipv4.conf.wlp4s0.proxy_arp=1 # Enable wlan ARP
  9. sudo sysctl net.ipv4.ip_forward=1 # Enable IP Forwarding
  10.  
  11. # General
  12. OPTS="-name 'Windows10-QEMU'"
  13. OPTS="$OPTS -machine type=q35,accel=kvm"
  14. OPTS="$OPTS -global ICH9-LPC.disable_s3=1" # Disable S3 from Q35 chipset
  15. OPTS="$OPTS -global ICH9-LPC.disable_s4=1" # Disable S4 from Q35 chipset
  16. #OPTS="$OPTS -global kvm-pit.lost_tick_policy=discard" # ?
  17.  
  18. # CPU
  19. OPTS="$OPTS -cpu host,kvm=off,hv_relaxed,hv_spinlocks=0x1fff,hv_time,hv_vendor_id=5DIE45JG7EAY" # Trick Nvidia with kvm=off, Enable Hyper-V enlightenments, Mask with hv_vendor_id. Avoid hv_vapic for Haswell (causes overhead)
  20. OPTS="$OPTS -smp sockets=1,cores=4,threads=2"
  21.  
  22. # OVMF
  23. OPTS="$OPTS -drive file=OvmfX64/DEBUG_GCC5/FV/OVMF_CODE.fd,if=pflash,format=raw,readonly=on"
  24. OPTS="$OPTS -drive file=WIN10_VARS.fd,if=pflash,format=raw"
  25.  
  26. # Boot
  27. OPTS="$OPTS -boot menu=on"
  28. OPTS="$OPTS -boot order=c"
  29.  
  30. # Memory
  31. OPTS="$OPTS -m 8G"
  32. #OPTS="$OPTS -mem-path /dev/hugepages/libvirt/qemu"
  33. OPTS="$OPTS -mem-prealloc"
  34.  
  35. # Misc
  36. OPTS="$OPTS -balloon none" # Disable decrease/increase memory size via ballooning
  37. OPTS="$OPTS -rtc clock=host,base=localtime" # Local time required for Windows
  38. OPTS="$OPTS -nodefaults" # No default devices
  39. OPTS="$OPTS -nographic" # Disable graphical output, use command line
  40. OPTS="$OPTS -vga none" # Emulated video device
  41. OPTS="$OPTS -parallel none" # Disable parallel ports
  42. OPTS="$OPTS -serial none" # Disable serial ports
  43. OPTS="$OPTS -k en-us" # Use EN-US as keyboard layout
  44. OPTS="$OPTS -enable-kvm"
  45.  
  46. # VNC
  47. #OPTS="$OPTS -vnc 127.0.0.1:1" # Listen to VNC display
  48.  
  49. # Spice
  50. OPTS="$OPTS -spice port=5930,disable-ticketing"
  51. OPTS="$OPTS -device virtio-serial-pci,addr=0b.0"
  52. OPTS="$OPTS -device virtserialport,chardev=spicechannel0,name=com.redhat.spice.0"
  53. OPTS="$OPTS -chardev spicevmc,id=spicechannel0,name=vdagent"
  54.  
  55. # Use Spice QXL GPU (primary, vga compatible) for display device, on root bus
  56. #OPTS="$OPTS -device qxl-vga,bus=pcie.0,addr=02.0,id=video-0"
  57. OPTS="$OPTS -device qxl-vga,ram_size=134217728,vram_size=134217728,vram64_size_mb=0,vgamem_mb=128,max_outputs=1,bus=pcie.0,addr=02.0,id=video-0"
  58.  
  59. # Root Port 1
  60. OPTS="$OPTS -device ioh3420,bus=pcie.0,addr=01.0,multifunction=on,chassis=1,id=root.1"
  61. OPTS="$OPTS -device vfio-pci,host=01:00.0,bus=root.1,addr=00.0,x-pci-sub-device-id=6237,x-pci-sub-vendor-id=4163,multifunction=on,rombar=0,id=host-device-0"
  62.  
  63. # Root Port 2
  64. OPTS="$OPTS -device ioh3420,bus=pcie.0,addr=09.0,chassis=2,id=root.2"
  65. OPTS="$OPTS -device virtio-scsi-pci,bus=root.2,addr=00.0,id=virtio-pci-scsi-0"
  66. OPTS="$OPTS -drive file=WindowsVM.img,format=raw,if=none,id=virtio-scsi-disk-0,cache=none,aio=native"
  67. OPTS="$OPTS -device scsi-hd,drive=virtio-scsi-disk-0"
  68.  
  69. # Root Port 3
  70. OPTS="$OPTS -device ioh3420,bus=pcie.0,addr=03.0,chassis=3,id=root.3"
  71. OPTS="$OPTS -device ich9-ahci,bus=root.3,addr=00.0,id=ich9-ahci-0"
  72. OPTS="$OPTS -drive file=/home/fire/vfio/windows10.iso,format=raw,index=1,if=none,media=cdrom,readonly=on,id=sata-cd-0"
  73. OPTS="$OPTS -device ide-cd,bus=ich9-ahci-0.0,drive=sata-cd-0"
  74. OPTS="$OPTS -drive file=virtio-win-0.1.149.iso,index=2,if=none,media=cdrom,id=sata-cd-1"
  75. OPTS="$OPTS -device ide-cd,bus=ich9-ahci-0.1,drive=sata-cd-1"
  76.  
  77. # Root Port 4
  78. #OPTS="$OPTS -device ioh3420,bus=pcie.0,addr=04.0,chassis=4,id=root.4"
  79. #OPTS="$OPTS -device nec-usb-xhci,bus=root.4,addr=00.0,id=nec-usb-xhci-0"
  80. #OPTS="$OPTS -device usb-host,bus=nec-usb-xhci-0.0,hostbus=2,hostaddr=11"
  81.  
  82. # Root Port 5
  83. #OPTS="$OPTS -device ioh3420,bus=pcie.0,addr=05.0,chassis=5,id=root.5"
  84. #OPTS="$OPTS -device ich9-intel-hda,bus=root.5,addr=00.0,id=intel-hda-0"
  85. #OPTS="$OPTS -device hda-duplex,bus=intel-hda-0.0,cad=0"
  86.  
  87. # Root Port 6
  88. #OPTS="$OPTS -device ioh3420,bus=pcie.0,addr=06.0,chassis=6,id=root.6"
  89. #OPTS="$OPTS -netdev user,hostfwd=udp::2046-10.0.2.15:2046,id=host-network-0"
  90. #OPTS="$OPTS -device virtio-net-pci,netdev=host-network-0,mac=46:21:83:0D:59:3F,bus=root.6,addr=00.0"
  91.  
  92. # Root Port 7
  93. OPTS="$OPTS -device ioh3420,bus=pcie.0,addr=07.0,chassis=7,id=root.7"
  94. #OPTS="$OPTS -netdev tap,ifname=tap0,script=tap_ifup,downscript=tap_ifdown,vhost=on,id=host-network-1"
  95. OPTS="$OPTS -netdev tap,ifname=tap1,script=no,downscript=no,vhost=on,id=host-network-1"
  96. OPTS="$OPTS -device virtio-net-pci,netdev=host-network-1,mac=52:54:BE:EF:4B:F1,bus=root.7,addr=00.0"
  97.  
  98. # Root Port 8
  99. #OPTS="$OPTS -device ioh3420,bus=pcie.0,addr=08.0,chassis=8,id=root.8"
  100. #OPTS="$OPTS -device virtio-balloon-pci,bus=root.8,addr=00.0,id=virtio-balloon-pci-0"
  101.  
  102. # Looking Glass
  103. #OPTS="$OPTS -object memory-backend-file,id=ivshmem,share=on,mem-path=/dev/shm/looking-glass,size=32M"
  104. #OPTS="$OPTS -device ivshmem-plain,memdev=ivshmem,addr=0c.0"
  105.  
  106. # Commandline
  107. OPTS="$OPTS -chardev stdio,mux=on,id=monitor-0" # Character device with standard I/O backend and multiplexing mode on [Backend]
  108. OPTS="$OPTS -mon chardev=monitor-0" # Monitor character device [Frontend]
  109.  
  110. sudo qemu-system-x86_64 $OPTS
  111.  
  112. sudo sysctl net.ipv4.ip_forward=0 # Disable IP Forwarding
  113. sudo sysctl net.ipv4.conf.wlp4s0.proxy_arp=0 # Disable wlan ARP
  114. sudo sysctl net.ipv4.conf.tap1.proxy_arp=0 # Disable tap ARP
  115. sudo ip link set tap1 down # Set tap down
  116. sudo route -n
  117. sudo ip link del tap1 # Delete tap interface
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement