|
| 1 | +#!/bin/bash |
| 2 | +# Huaicheng Li <huaicheng@cs.uchicago.edu> |
| 3 | +# Run VM with FEMU support |
| 4 | + |
| 5 | +IMGDIR=$HOME/images |
| 6 | + |
| 7 | +is_mounted=$(mount | grep "/mnt/tmpfs") |
| 8 | + |
| 9 | +if [[ $is_mounted == "" ]]; then |
| 10 | + sudo mkdir -p /mnt/tmpfs |
| 11 | + # huge=always |
| 12 | + #sudo mount -t tmpfs -o size=4G,huge=always tmpfs /mnt/tmpfs |
| 13 | +fi |
| 14 | + |
| 15 | + |
| 16 | +# every time we run a new SSD |
| 17 | +sudo rm -rf /mnt/tmpfs/test1.raw |
| 18 | +sudo rm -rf /mnt/tmpfs/test2.raw |
| 19 | + |
| 20 | +[[ ! -e /mnt/tmpfs/test1.raw ]] && ./qemu-img create -f raw /mnt/tmpfs/test1.raw 4G |
| 21 | +[[ ! -e /mnt/tmpfs/test2.raw ]] && ./qemu-img create -f raw /mnt/tmpfs/test2.raw 4G |
| 22 | + |
| 23 | +# huge page related settings |
| 24 | +#echo 25000 | sudo tee /proc/sys/vm/nr_hugepages |
| 25 | + |
| 26 | +[[ ! -d /dev/hugepages2M ]] && sudo mkdir /dev/hugepages2M && sudo mount -t hugetlbfs none /dev/hugepages2M -o pagesize=2M |
| 27 | + |
| 28 | + |
| 29 | +#-object iothread,id=iothread0 \ |
| 30 | +#-device virtio-blk-pci,iothread=iothread0,drive=id0 \ |
| 31 | + #-nographic \ |
| 32 | + #-device nvme,drive=id0,serial=serial0,id=nvme0 \ |
| 33 | + #-kernel /home/huaicheng/git/linux/arch/x86_64/boot/bzImage \ |
| 34 | + #-append "root=/dev/vda1 console=ttyS0,115200n8 console=tty0" \ |
| 35 | + #-virtfs local,path=/home/huaicheng/share/,security_model=passthrough,mount_tag=host_share \ |
| 36 | + |
| 37 | + #must come before all other qemu options!!!!!! |
| 38 | + #-trace events=/tmp/events \ |
| 39 | + #-object memory-backend-file,id=mem1,size=8G,mem-path=/dev/hugepages2M \ |
| 40 | + #-device pc-dimm,id=dimm1,memdev=mem1 \ |
| 41 | + |
| 42 | + |
| 43 | +sudo x86_64-softmmu/qemu-system-x86_64 \ |
| 44 | + -name "nvme-FEMU-test" \ |
| 45 | + -enable-kvm \ |
| 46 | + -cpu host \ |
| 47 | + -smp 4 \ |
| 48 | + -m 8G \ |
| 49 | + -device virtio-scsi-pci,id=scsi0 \ |
| 50 | + -device scsi-hd,drive=hd0 \ |
| 51 | + -drive file=$IMGDIR/u14s.qcow2,if=none,aio=native,cache=none,format=qcow2,id=hd0 \ |
| 52 | + -device virtio-scsi-pci,id=scsi1 \ |
| 53 | + -device scsi-hd,drive=hd1 \ |
| 54 | + -drive file=$IMGDIR/vmdata.qcow2,if=none,aio=native,cache=none,format=qcow2,id=hd1 \ |
| 55 | + -drive file=/mnt/tmpfs/test1.raw,if=none,aio=threads,format=raw,id=id0 \ |
| 56 | + -device nvme,drive=id0,serial=serial0,id=nvme0 \ |
| 57 | + -drive file=/mnt/tmpfs/test2.raw,if=none,aio=threads,format=raw,id=id1 \ |
| 58 | + -device nvme,drive=id1,serial=serial1,id=nvme1 \ |
| 59 | + -net user,hostfwd=tcp::8080-:22 \ |
| 60 | + -net nic,model=virtio \ |
| 61 | + -nographic \ |
| 62 | + -qmp unix:./qmp-sock,server,nowait | tee /media/log |
| 63 | + #-object iothread,id=iothread0 \ |
| 64 | + #-display none \ |
| 65 | + #-nographic \ |
| 66 | + #-monitor stdio \ |
| 67 | + #-s -S \ |
| 68 | + # |
| 69 | + |
| 70 | +#sleep 10 |
| 71 | + |
| 72 | +#./pin.sh |
| 73 | +#sshsim "~/tsc.sh" |
| 74 | +#sshsim "echo 0 | sudo tee /proc/sys/kernel/timer_migration" |
| 75 | +#sshsim "echo 0 | sudo tee /sys/kernel/debug/tracing/tracing_on" |
| 76 | + |
| 77 | +echo "VM is up, enjoy it :)" |
| 78 | + |
| 79 | +wait |
0 commit comments