GO9PIMG 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. #!/bin/bash
  2. set -e
  3. if [ -f "$HARVEY/util/harvey.qcow2" ]
  4. then
  5. HARVEY_DISK="$HARVEY/util/harvey.qcow2"
  6. elif [ -f "$HARVEY/util/harvey.raw" ]
  7. then
  8. HARVEY_DISK="$HARVEY/util/harvey.raw,format=raw"
  9. else
  10. echo "ERROR: Disk image not found"
  11. exit 1
  12. fi
  13. trap : 2
  14. $HARVEY/util/ufs -root=$HARVEY &
  15. ufspid=$!
  16. export machineflag=q35
  17. if [ "$(uname)" = "Linux" ] && [ -e /dev/kvm ]; then
  18. export kvmflag='-enable-kvm'
  19. export machineflag='pc,accel=kvm'
  20. if [ ! -w /dev/kvm ]; then
  21. # we don't have access as a regular user
  22. export kvmdo=sudo
  23. fi
  24. fi
  25. # The -usb flag is necessary for the system to recognize usb devices
  26. # To specify a specific device you must follow the following format:
  27. # -device usb-host,hostbus='X',hostaddr='Y'
  28. # The 'X'/'Y' values can be found with lsusb(8) (Linux/BSD)
  29. # Provided is an example lsusb(8) output:
  30. # Bus 002 Device 004: ID 056a:00e6 Wacom Co., Ltd TPCE6
  31. # Where 'X'== 2 and 'Y'== 4
  32. read -r cmd <<EOF
  33. $kvmdo qemu-system-x86_64 -s -cpu Opteron_G1 -smp 4 -m 2048 $kvmflag \
  34. -usb \
  35. -serial stdio \
  36. --machine $machineflag \
  37. -net nic,model=rtl8139 \
  38. -net user,id=user.0,\
  39. hostfwd=tcp::5555-:1522,\
  40. hostfwd=tcp::9999-:9,\
  41. hostfwd=tcp::17010-:17010,\
  42. hostfwd=tcp::1666-:1666,\
  43. hostfwd=tcp::5356-:5356,\
  44. hostfwd=tcp::17013-:17013 \
  45. -object filter-dump,id=f1,netdev=user.0,file=/tmp/vm0.pcap \
  46. -drive id=disk,file=$HARVEY_DISK,if=none \
  47. -device ich9-ahci,id=ahci \
  48. -device ide-drive,drive=disk,bus=ahci.0 \
  49. $*
  50. EOF
  51. echo $cmd
  52. eval $cmd
  53. kill $ufspid
  54. wait