#! /bin/bash # Note that usermode networking supports TCP and UDP but not ICMP. In # particular, ping will not work. # Useful hint: Sometimes it's nice to pass the "-snapshot" argument # Note: requires "modprobe kvm-intel" # which loads "kvm" as well as "kvm-intel" if test -z "${USB}" ; then 1>&2 echo "Please export USB=/dev/something" exit 1 fi mounted=$( awk '{ if (match($1, "^'"${USB}"'") ) printf "%s ", $1; }' /proc/mounts ) if test -n "$mounted" ; then 1>&2 echo "You probably want to unmount some stuff:" for part in $mounted ; do 1>&2 echo " :; umount $part" done exit 1 fi if ! lsmod | grep -w -q '^kvm_intel' ; then 1>&2 echo 'Requires KVM modules.' 1>&2 echo 'Hint: sudo modprobe kvm_intel' exit 1 fi qemu-system-x86_64 \ -hda ${USB} \ -boot order=c \ -enable-kvm \ -m 1024M \ -rtc base=utc \ -object rng-random,filename=/dev/urandom,id=rng0 \ -device virtio-rng-pci,rng=rng0 \ "$@"