GO9PIMGUSB 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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 usb-storage,drive=disk
  49. -boot menu=on
  50. $*
  51. EOF
  52. echo $cmd
  53. eval $cmd
  54. kill $ufspid
  55. wait