GO9PUROOT 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. #!/bin/bash
  2. set -e
  3. trap : 2
  4. $HARVEY/linux_amd64/bin/centre -i "" -ninep-dir=$HARVEY &
  5. centrepid=$!
  6. export machineflag=q35
  7. if [ "$(uname)" = "Linux" ] && [ -e /dev/kvm ]; then
  8. export kvmflag='-enable-kvm'
  9. export machineflag='pc,accel=kvm'
  10. if [ ! -w /dev/kvm ]; then
  11. # we don't have access as a regular user
  12. export kvmdo=sudo
  13. fi
  14. fi
  15. # vmware-cpuid-freq=on,+invtsc exposes the 0x40000000 hypervisor cpuid values to
  16. # the guest, which we can use to identify the TSC frequency
  17. read -r cmd <<EOF
  18. $kvmdo qemu-system-x86_64 -s -cpu max,vmware-cpuid-freq=on,+invtsc -smp 4 -m 2048 $kvmflag \
  19. -initrd plan9_amd64/uroot.cpio.lzma \
  20. -usb \
  21. -serial stdio \
  22. --machine $machineflag \
  23. -net nic,model=rtl8139 \
  24. -net user,id=user.0,\
  25. hostfwd=tcp::5555-:1522,\
  26. hostfwd=tcp::9999-:9,\
  27. hostfwd=tcp::17010-:17010,\
  28. hostfwd=tcp::1666-:1666,\
  29. hostfwd=tcp::5356-:5356,\
  30. hostfwd=tcp::17013-:17013 \
  31. -object filter-dump,id=f1,netdev=user.0,file=/tmp/vm0.pcap \
  32. -append "service=uroot nobootprompt=tcp maxcores=1024 fs=10.0.2.2 auth=10.0.2.2 nvram=/boot/nvram nvrlen=512 nvroff=0 acpiirq=1 mouseport=ps2 vgasize=1024x768x24 monitor=vesa" \
  33. -kernel $HARVEY/sys/src/9/amd64/harvey.32bit $*
  34. EOF
  35. echo $cmd
  36. eval $cmd
  37. kill $centrepid
  38. wait