Skip to content

Instantly share code, notes, and snippets.

@dmgolubovsky
Created June 12, 2016 15:37
Show Gist options
  • Save dmgolubovsky/2895c66c1b93906c03840cc01fc0aa7a to your computer and use it in GitHub Desktop.
Save dmgolubovsky/2895c66c1b93906c03840cc01fc0aa7a to your computer and use it in GitHub Desktop.
#! /bin/sh
# Run Harvey in terminal mode
trap : 2
export HARVEY=$HOME/src/harvey
export KVM=/usr/bin/kvm
$HARVEY/util/ufs -root=$HARVEY &
ufspid=$!
export machineflag=pc
if [ "$(uname)" = "Linux" ] && [ -e /dev/kvm ]; then
export kvmflag='-enable-kvm'
export machineflag='pc,accel=kvm'
if [ ! -w /dev/kvm ]; then
# we don't have access as a regular user
export kvmdo=sudo
fi
fi
read -r cmd <<EOF
$kvmdo $KVM -s -cpu host -smp 4 -m 2048 $kvmflag \
-serial stdio \
--machine $machineflag \
-net nic,model=rtl8139 \
-net user,hostfwd=tcp::5555-:1522 \
-net dump,file=/tmp/vm0.pcap \
-vga qxl \
-display sdl -no-frame \
-append "service=terminal nobootprompt=tcp fs=10.0.2.2 auth=127.0.0.1 nvram=/boot/nvram nvrlen=512 nvroff=0 user=harvey mouseport=ps2 vgasize=1920x1080x24 monitor=vesa" \
-fsdev local,path=/tmp,id=fstmp,security_model=none \
-device virtio-9p-pci,fsdev=fstmp,mount_tag=hosttmp \
-drive file=$HOME/.local/share/gnome-boxes/images/fedora-unknown,if=virtio \
-device virtio-serial-pci \
-device virtio-scsi-pci \
-drive file=$HOME/Downloads/ubuntu-16.04-desktop-amd64.iso,id=xyz,if=none \
-device virtio-blk-pci,drive=xyz \
-device virtio-rng-pci \
-net nic,model=virtio \
-balloon virtio \
-redir tcp:9999::9 \
-redir tcp:17010::17010 \
-redir tcp:17013::17013 \
-kernel $HARVEY/sys/src/9/amd64/harvey.32bit $*
EOF
#-append "service=cpu nobootprompt=tcp maxcores=1024 fs=10.0.2.2 auth=10.0.2.2 nvram=/boot/nvram nvrlen=512 nvroff=0" \
echo $cmd
eval $cmd
kill $ufspid
wait
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment