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