vm-run.sh 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. #!/bin/bash
  2. cd "$(dirname $0)"
  3. if [ -z "$TESTDIR" ] ; then
  4. TESTDIR=$(pwd)/../
  5. fi
  6. LOGS=/tmp/hwsim-test-logs/
  7. # increase the memory size if you want to run with valgrind, 512 MB works
  8. MEMORY=128
  9. # Some ubuntu systems (notably 12.04) have issues with this - since the guest
  10. # mounts as read-only it should be safe to not specify ,readonly. Override in
  11. # vm-config if needed (see below)
  12. ROTAG=,readonly
  13. # set this to ttyS0 to see kvm messages (if something doesn't work)
  14. KVMOUT=ttyS1
  15. # you can set EPATH if you need anything extra in $PATH inside the VM
  16. #EPATH=/some/dir
  17. # extra KVM arguments, e.g., -s for gdbserver
  18. #KVMARGS=-s
  19. # number of channels each hwsim device supports
  20. CHANNELS=1
  21. test -f vm-config && . vm-config
  22. if [ -z "$KERNEL" ] && [ -z "$KERNELDIR" ] ; then
  23. echo "You need to set a KERNEL or KERNELDIR (in the environment or vm-config)"
  24. exit 2
  25. fi
  26. if [ -z "$KERNEL" ] ; then
  27. KERNEL=$KERNELDIR/arch/x86_64/boot/bzImage
  28. fi
  29. CMD=$TESTDIR/vm/inside.sh
  30. LOGDIR=$LOGS/$(date +%s)
  31. mkdir -p $LOGDIR
  32. exec kvm \
  33. -kernel $KERNEL -smp 4 \
  34. $KVMARGS -m $MEMORY -nographic \
  35. -fsdev local,security_model=none,id=fsdev-root,path=/$ROTAG \
  36. -device virtio-9p-pci,id=fs-root,fsdev=fsdev-root,mount_tag=/dev/root \
  37. -fsdev local,security_model=none,id=fsdev-logs,path="$LOGDIR",writeout=immediate \
  38. -device virtio-9p-pci,id=fs-logs,fsdev=fsdev-logs,mount_tag=logshare \
  39. -monitor null -serial stdio -serial file:$LOGDIR/console \
  40. -append "mac80211_hwsim.channels=$CHANNELS mac80211_hwsim.radios=5 init=$CMD testdir=$TESTDIR console=$KVMOUT root=/dev/root rootflags=trans=virtio,version=9p2000.u ro rootfstype=9p EPATH=$EPATH ARGS=$*"