|
| 1 | +#!/bin/bash |
| 2 | +# Huaicheng Li <huaicheng@cs.uchicago.edu> |
| 3 | +# Run FEMU as a black-box SSD (FTL managed by the device) |
| 4 | + |
| 5 | +#FDP real hw device |
| 6 | +#./vfio-bind.sh 0000:8b:00.0 |
| 7 | + |
| 8 | +# image directory |
| 9 | +IMGDIR=$HOME/image |
| 10 | +# Virtual machine disk image |
| 11 | +# OSIMGF=$IMGDIR/newimg2.qcow2 |
| 12 | +OSIMGF=$IMGDIR/u20s.qcow2 |
| 13 | + |
| 14 | + |
| 15 | +# Configurable SSD Controller layout parameter4s (must be power of 2) |
| 16 | +secsz=512 |
| 17 | +secs_per_pg=8 #4KiB |
| 18 | +pgs_per_blk=512 #512*4K:2MB (RU : 128MiB) |
| 19 | +blks_per_pl=4086 #2MB * 8 * 8 =RU 128MiB -> 4085.76 = (448*1.14*1024)/128 |
| 20 | +pls_per_lun=1 # still not support multiplanes |
| 21 | +luns_per_ch=8 # 16G 256*8 |
| 22 | +nchs=8 # 128G 256*8*8 |
| 23 | +ssd_size=458752 # in MegaBytes |
| 24 | +# # 128GiB ( 156GiB ) |
| 25 | +# # 256GiB ( 307GiB) 26214 |
| 26 | +# # 512GiB ( 614GiB) 524288 |
| 27 | +number_of_ru=$((blks_per_pl * pls_per_lun)) |
| 28 | +# Latency in nanoseconds |
| 29 | +#pg_rd_lat=40000 #40us |
| 30 | +#pg_wr_lat=200000 #200us |
| 31 | +#blk_er_lat=2000000 #2ms |
| 32 | +#ch_xfer_lat=0 |
| 33 | +pg_rd_lat=10000 #10us |
| 34 | +#pg_wr_lat=50000 #50us |
| 35 | +#blk_er_lat=500000 #400us |
| 36 | +pg_wr_lat=5000 # 500us : 50us : 5us : 2.5us |
| 37 | +blk_er_lat=20000 # 2000us : 200us : 20us: 10us |
| 38 | + |
| 39 | + |
| 40 | +ch_xfer_lat=0 |
| 41 | +# GC Threshold (1-100) |
| 42 | +custom_trim_all=true |
| 43 | +gc_thres_pcent=90 |
| 44 | +gc_thres_pcent_high=99 |
| 45 | + |
| 46 | +# FDP feature |
| 47 | +fdpruhs="0;1;2;3;4;5;6;7" |
| 48 | +subsys="femu-subsys-0" |
| 49 | +#----------------------------------------------------------------------- |
| 50 | + |
| 51 | +#Compose the entire FEMU BBSSD command line options |
| 52 | +FEMU_OPTIONS="-device femu" |
| 53 | +FEMU_OPTIONS=${FEMU_OPTIONS}",devsz_mb=${ssd_size}" |
| 54 | +FEMU_OPTIONS=${FEMU_OPTIONS}",namespaces=1" |
| 55 | +FEMU_OPTIONS=${FEMU_OPTIONS}",femu_mode=1" |
| 56 | +FEMU_OPTIONS=${FEMU_OPTIONS}",secsz=${secsz}" |
| 57 | +FEMU_OPTIONS=${FEMU_OPTIONS}",secs_per_pg=${secs_per_pg}" |
| 58 | +FEMU_OPTIONS=${FEMU_OPTIONS}",pgs_per_blk=${pgs_per_blk}" |
| 59 | +FEMU_OPTIONS=${FEMU_OPTIONS}",blks_per_pl=${blks_per_pl}" |
| 60 | +FEMU_OPTIONS=${FEMU_OPTIONS}",pls_per_lun=${pls_per_lun}" |
| 61 | +FEMU_OPTIONS=${FEMU_OPTIONS}",luns_per_ch=${luns_per_ch}" |
| 62 | +FEMU_OPTIONS=${FEMU_OPTIONS}",nchs=${nchs}" |
| 63 | +FEMU_OPTIONS=${FEMU_OPTIONS}",pg_rd_lat=${pg_rd_lat}" |
| 64 | +FEMU_OPTIONS=${FEMU_OPTIONS}",pg_wr_lat=${pg_wr_lat}" |
| 65 | +FEMU_OPTIONS=${FEMU_OPTIONS}",blk_er_lat=${blk_er_lat}" |
| 66 | +FEMU_OPTIONS=${FEMU_OPTIONS}",ch_xfer_lat=${ch_xfer_lat}" |
| 67 | +FEMU_OPTIONS=${FEMU_OPTIONS}",custom_trim_all=${custom_trim_all}" |
| 68 | +FEMU_OPTIONS=${FEMU_OPTIONS}",gc_thres_pcent=${gc_thres_pcent}" |
| 69 | +FEMU_OPTIONS=${FEMU_OPTIONS}",gc_thres_pcent_high=${gc_thres_pcent_high}" |
| 70 | +FEMU_OPTIONS=${FEMU_OPTIONS}",fdp.ruhs=${fdpruhs}" |
| 71 | +FEMU_OPTIONS=${FEMU_OPTIONS}",subsys=${subsys}" |
| 72 | +echo ${FEMU_OPTIONS} |
| 73 | + |
| 74 | +if [[ ! -e "$OSIMGF" ]]; then |
| 75 | + echo "" |
| 76 | + echo "VM disk image couldn't be found ..." |
| 77 | + echo "Please prepare a usable VM image and placeit as $OSIMGF" |
| 78 | + echo "Once VM disk image is ready, please rerun this script again" |
| 79 | + echo "" |
| 80 | + exit |
| 81 | +fi |
| 82 | + |
| 83 | +sudo x86_64-softmmu/qemu-system-x86_64 \ |
| 84 | + -name "FEMU-BBSSD-VM" \ |
| 85 | + -enable-kvm \ |
| 86 | + -cpu host \ |
| 87 | + -smp 16 \ |
| 88 | + -m 16G \ |
| 89 | + -device femu-subsys,id=femu-subsys-0,nqn=subsys0,fdp=on,fdp.nruh=8,fdp.nrg=1,fdp.nru=${number_of_ru} \ |
| 90 | + -device virtio-scsi-pci,id=scsi0 \ |
| 91 | + -device scsi-hd,drive=hd0 \ |
| 92 | + -drive file=$OSIMGF,if=none,aio=native,cache=none,format=qcow2,id=hd0 \ |
| 93 | + ${FEMU_OPTIONS} \ |
| 94 | + -net user,hostfwd=tcp::18080-:22 \ |
| 95 | + -net nic,model=virtio \ |
| 96 | + -nographic \ |
| 97 | + -qmp unix:./qmp-sock,server,nowait 2>&1 | tee log |
| 98 | + |
| 99 | +#-device vfio-pci,host=8b:00.0 \ |
| 100 | +#-virtfs local,path=/data/inho,mount_tag=hds03,security_model=passthrough,id=hds03 \ |
0 commit comments