1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162 |
- #!/bin/bash
- set -e
- if [ -f "$HARVEY/util/harvey.qcow2" ]
- then
- HARVEY_DISK="$HARVEY/util/harvey.qcow2"
- elif [ -f "$HARVEY/util/harvey.raw" ]
- then
- HARVEY_DISK="$HARVEY/util/harvey.raw,format=raw"
- else
- echo "ERROR: Disk image not found"
- exit 1
- fi
- trap : 2
- $HARVEY/util/ufs -root=$HARVEY &
- ufspid=$!
- export machineflag=q35
- 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
- # The -usb flag is necessary for the system to recognize usb devices
- # To specify a specific device you must follow the following format:
- # -device usb-host,hostbus='X',hostaddr='Y'
- # The 'X'/'Y' values can be found with lsusb(8) (Linux/BSD)
- # Provided is an example lsusb(8) output:
- # Bus 002 Device 004: ID 056a:00e6 Wacom Co., Ltd TPCE6
- # Where 'X'== 2 and 'Y'== 4
- read -r cmd <<EOF
- $kvmdo qemu-system-x86_64 -s -cpu Opteron_G1 -smp 4 -m 2048 $kvmflag \
- -usb \
- -serial stdio \
- --machine $machineflag \
- -net nic,model=rtl8139 \
- -net user,id=user.0,\
- hostfwd=tcp::5555-:1522,\
- hostfwd=tcp::9999-:9,\
- hostfwd=tcp::17010-:17010,\
- hostfwd=tcp::1666-:1666,\
- hostfwd=tcp::5356-:5356,\
- hostfwd=tcp::17013-:17013 \
- -object filter-dump,id=f1,netdev=user.0,file=/tmp/vm0.pcap \
- -drive id=disk,file=$HARVEY_DISK,if=none \
- -device ich9-ahci,id=ahci \
- -device usb-storage,drive=disk
- -boot menu=on
- $*
- EOF
- echo $cmd
- eval $cmd
- kill $ufspid
- wait
|