Source

bin / vm

Full commit
#!/bin/bash

lsmod | grep -q kvm-intel || sudo modprobe kvm-intel

case "$1" in
	win7)
		CORES=2
		MEM=4096
		TAP=tap0
		IMAGE=/dev/sdb5
		VGA=vmware
		shift
		;;
	winxp)
		CORES=2
		MEM=4096
		TAP=tap0
		VGA=std
		IMAGE=/dev/sdb6
		shift
		;;
	*)
		echo "Unknown VM: $1"
		exit 1;
		;;
esac

if [[ $1 =~ ^-- ]]; then
	echo sudo qemu-kvm -m "$MEM" -smp "cores=$CORES,threads=1,sockets=1" -vga std -usbdevice tablet -drive file=$IMAGE"${@#--}"
	sudo qemu-kvm -m "$MEM" -smp "cores=$CORES,threads=1,sockets=1" -vga std -usbdevice tablet -drive file=$IMAGE"${@#--}"
	exit
fi

echo sudo qemu-kvm                                              \
	-usbdevice "tablet"                                         \
	-vga       "$VGA"                                           \
	-m         "$MEM"                                           \
	-smp       "cores=$CORES,threads=1,sockets=1"               \
	-boot      "order=c"                                        \
	-drive     "file=$IMAGE,if=virtio"                          \
	-net       "nic,model=virtio,vlan=0"                        \
	-net       "tap,ifname=$TAP,script=no,downscript=no,vlan=0" \
	"$@"

sudo qemu-kvm                                                   \
	-usbdevice "tablet"                                         \
	-vga       "$VGA"                                           \
	-m         "$MEM"                                           \
	-smp       "cores=$CORES,threads=1,sockets=1"               \
	-boot      "order=c"                                        \
	-drive     "file=$IMAGE,if=virtio"                          \
	-net       "nic,model=virtio,vlan=0"                        \
	-net       "tap,ifname=$TAP,script=no,downscript=no,vlan=0" \
	"$@"