2015-12-22 11:10:07 +01:00
|
|
|
#!/bin/bash
|
2016-11-25 14:41:57 +01:00
|
|
|
|
2017-01-20 01:54:11 +01:00
|
|
|
# This file is part of Jehanne.
|
|
|
|
#
|
|
|
|
# Copyright (C) 2016-2017 Giacomo Tesio <giacomo@tesio.it>
|
|
|
|
|
2016-11-25 14:41:57 +01:00
|
|
|
if [ "$JEHANNE" = "" ]; then
|
|
|
|
echo ./hacking/QA.sh requires the shell started by ./hacking/devshell.sh
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2015-12-22 11:10:07 +01:00
|
|
|
trap : 2
|
|
|
|
|
2016-11-25 14:41:57 +01:00
|
|
|
$JEHANNE/hacking/bin/ufs -d=0 -root=$JEHANNE &
|
2015-12-22 11:10:07 +01:00
|
|
|
ufspid=$!
|
|
|
|
|
|
|
|
export machineflag=pc
|
|
|
|
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
|
|
|
|
|
2016-11-25 14:41:57 +01:00
|
|
|
if [ "$KERNDIR" = "" ]; then
|
|
|
|
KERNDIR=$JEHANNE/arch/$ARCH/kern/
|
|
|
|
fi
|
|
|
|
if [ "$KERNEL" = "" ]; then
|
|
|
|
KERNEL=jehanne.32bit
|
|
|
|
fi
|
2016-12-15 22:47:10 +01:00
|
|
|
if [ "$NCPU" = "" ]; then
|
|
|
|
NCPU=1
|
|
|
|
fi
|
2017-02-05 02:37:00 +01:00
|
|
|
if [ "$CPU_MODEL" = "" ]; then
|
|
|
|
CPU_MODEL=Opteron_G1
|
|
|
|
fi
|
|
|
|
|
|
|
|
appendLine="nobootprompt=tcp maxcores=1024 fs=10.0.2.2 auth=10.0.2.2 nvram=/boot/nvram nvrlen=512 nvroff=0 $KAPPEND"
|
|
|
|
appendLine="-append '$appendLine'"
|
|
|
|
kernelLine="-kernel $KERNEL $*"
|
|
|
|
if [ "$DISK" = "" ]; then
|
|
|
|
if [ "$QA_DISK" != "" ]; then
|
|
|
|
# disk to run QA checks
|
|
|
|
export DISK=$QA_DISK
|
|
|
|
# will boot from disk, no need for kernel and so on
|
|
|
|
appendLine=""
|
|
|
|
kernelLine=""
|
|
|
|
else
|
|
|
|
export DISK=$JEHANNE/hacking/sample-disk.img
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ -a $DISK ]; then
|
|
|
|
bootDisk="-device ahci,id=ahci -drive id=boot,file=$DISK,index=0,cache=writeback,if=none -device ide-drive,drive=boot,bus=ahci.0"
|
|
|
|
fi
|
2016-11-25 14:41:57 +01:00
|
|
|
|
|
|
|
cd $KERNDIR
|
2015-12-22 11:10:07 +01:00
|
|
|
read -r cmd <<EOF
|
2017-02-05 02:37:00 +01:00
|
|
|
$kvmdo qemu-system-x86_64 -s -cpu $CPU_MODEL -smp $NCPU -m 2048 $kvmflag \
|
2015-12-22 11:10:07 +01:00
|
|
|
-serial stdio \
|
|
|
|
--nographic \
|
|
|
|
--monitor /dev/null \
|
|
|
|
--machine $machineflag \
|
2016-11-25 14:41:57 +01:00
|
|
|
$bootDisk \
|
2015-12-22 11:10:07 +01:00
|
|
|
-net nic,model=rtl8139 \
|
|
|
|
-net user,hostfwd=tcp::5555-:1522 \
|
|
|
|
-net dump,file=/tmp/vm0.pcap \
|
|
|
|
-redir tcp:9999::9 \
|
|
|
|
-redir tcp:17010::17010 \
|
|
|
|
-redir tcp:17013::17013 \
|
2017-02-05 02:37:00 +01:00
|
|
|
$appendLine $kernelLine
|
2015-12-22 11:10:07 +01:00
|
|
|
EOF
|
|
|
|
|
2016-11-25 14:41:57 +01:00
|
|
|
#-no-reboot -D $JEHANNE/../qemu.log -d int,cpu_reset,in_asm \
|
|
|
|
|
2015-12-22 11:10:07 +01:00
|
|
|
echo $cmd
|
|
|
|
eval $cmd
|
|
|
|
|
|
|
|
kill $ufspid
|
|
|
|
wait
|
|
|
|
|