spacepaste

  1.  
  2. #!/bin/bash
  3. #Brindge connection for Host-only-networking for Windows10 VM
  4. if [[ -e /sys/class/net/br0 ]] && [[ -e /sys/class/net/tap0 ]]; then
  5. echo "br0 and tap0, both exists , so continuing with qemu"
  6. else
  7. #create a bridge on the host machine:
  8. ip link add br0 type bridge
  9. #If you want to use already created bridge don't forget to clean out IP.
  10. ip addr flush dev br0
  11. #Assign IP to the bridge.
  12. ip addr add 192.168.100.50/24 brd 192.168.100.255 dev br0
  13. #Create TAP interface.
  14. ip tuntap add mode tap user $"(whoami)"
  15. #Add TAP interface to the bridge.
  16. ip link set tap0 master br0
  17. #Make sure everything is up:
  18. ip link set dev br0 up
  19. ip link set dev tap0 up
  20. #Assign IP range to the bridge.
  21. dnsmasq --interface=br0 --bind-interfaces \
  22. --dhcp-range=192.168.100.50,192.168.100.254
  23. fi
  24. #---------------------------------------------------------------------------------------------------------------------------------
  25. #Obtiain value of hugepages
  26. hugepages=$( cat /proc/sys/vm/nr_hugepages )
  27. printf '%d ' "${hugepages[@]}"
  28. if [ $"(hugepages)" = "1024" ]; then
  29. echo "hugepages value already set"
  30. else
  31. #Assign hugepages value
  32. sysctl -w vm.nr_hugepages=1024
  33. echo "hugepages value assigned as 1024"
  34. fi
  35. #----------------------------------------------------------------------------------------------------------------------------------
  36. #Shell script for qemu-kvm emulation of Windows10 OS installed on my HDD
  37. #remote-viewer spice://127.0.0.1:5959
  38. #spicy -h 127.0.0.1 -p 5959
  39. exec qemu-system-x86_64 --enable-kvm -daemonize -name "Windows 10"\
  40. -cpu host -m 2G -smp 2 -mem-path /dev/hugepages \
  41. -vga qxl -soundhw hda \
  42. -device virtio-net-pci,netdev=winnet0,mac=52:54:00:32:45:12 \
  43. -netdev tap,id=winnet0,ifname=tap0,script=no,downscript=no \
  44. -device qemu-xhci,id=xhci -usb -device usb-tablet \
  45. -drive file=/usr/share/ovmf/x64/OVMF_CODE.fd,if=pflash,format=raw,unit=0,readonly=on \
  46. -drive file=/home/chen/vm/Win10Part/qemu-windows.nvram,if=pflash,format=raw,unit=1 \
  47. -drive file=/dev/sda,index=0,media=disk,driver=raw \
  48. -spice port=5959,disable-ticketing -device virtio-serial-pci \
  49. -device virtserialport,chardev=Win10channel0,name=com.redhat.spice.0 \
  50. -chardev spicevmc,id=Win10channel0,name=vdagent \
  51. "$@"
  52.