vm-run.sh 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  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. test -f vm-config && . vm-config
  18. if [ -z "$KERNELDIR" ] ; then
  19. echo "You need to set a KERNELDIR (in the environment or vm-config)"
  20. exit 2
  21. fi
  22. KERNEL=$KERNELDIR/arch/x86_64/boot/bzImage
  23. CMD=$TESTDIR/vm/inside.sh
  24. LOGDIR=$LOGS/$(date +%s)
  25. mkdir -p $LOGDIR
  26. exec kvm \
  27. -kernel $KERNEL -smp 4 \
  28. -s -m $MEMORY -nographic \
  29. -fsdev local,security_model=none,id=fsdev-root,path=/$ROTAG \
  30. -device virtio-9p-pci,id=fs-root,fsdev=fsdev-root,mount_tag=/dev/root \
  31. -fsdev local,security_model=none,id=fsdev-logs,path="$LOGDIR",writeout=immediate \
  32. -device virtio-9p-pci,id=fs-logs,fsdev=fsdev-logs,mount_tag=logshare \
  33. -monitor null -serial stdio -serial file:$LOGDIR/console \
  34. -append "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=$*"