2015-12-22 11:10:07 +01:00
|
|
|
#!/bin/sh
|
|
|
|
|
2017-01-20 01:54:11 +01:00
|
|
|
# This file is part of Jehanne.
|
|
|
|
#
|
|
|
|
# Copyright (C) 2016-2017 Giacomo Tesio <giacomo@tesio.it>
|
|
|
|
|
2017-12-19 00:27:32 +01:00
|
|
|
export SDL_VIDEO_X11_DGAMOUSE=0 # see https://wiki.archlinux.org/index.php/QEMU#Mouse_cursor_is_jittery_or_erratic
|
2016-11-25 14:41:57 +01:00
|
|
|
|
|
|
|
if [ "$JEHANNE" = "" ]; then
|
|
|
|
echo $0 requires the shell started by ./hacking/devshell.sh
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2015-12-22 11:10:07 +01:00
|
|
|
trap : 2
|
|
|
|
|
|
|
|
$JEHANNE/hacking/bin/ufs -root=$JEHANNE &
|
2020-01-17 02:03:11 +01:00
|
|
|
# To debug ufs add: -d 5 > $JEHANNE/../ufs.log 2>&1
|
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
|
|
|
export NVRAM=/boot/nvram
|
|
|
|
export FS="nobootprompt=tcp fs=10.0.2.2 auth=10.0.2.2"
|
|
|
|
|
|
|
|
if [ "$DISK" = "" ]; then
|
|
|
|
export DISK=$JEHANNE/hacking/sample-disk.img
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ -f $DISK ]; then
|
|
|
|
usbDev="-drive if=none,id=usbstick,file=$DISK -usb -device nec-usb-xhci,id=xhci -device usb-storage,bus=xhci.0,drive=usbstick"
|
2017-12-19 00:27:32 +01:00
|
|
|
usbDev="-readconfig /usr/share/doc/qemu-system-x86/common/ich9-ehci-uhci.cfg -drive if=none,id=usbstick,file=$DISK -usb -device usb-storage,bus=ehci.0,drive=usbstick "
|
2016-11-25 14:41:57 +01:00
|
|
|
fi
|
|
|
|
|
2017-01-19 22:44:33 +01:00
|
|
|
if [ "$KERNDIR" = "" ]; then
|
|
|
|
KERNDIR=$JEHANNE/arch/$ARCH/kern/
|
|
|
|
fi
|
|
|
|
if [ "$KERNEL" = "" ]; then
|
|
|
|
KERNEL="jehanne.32bit"
|
|
|
|
fi
|
|
|
|
if [ "$NCPU" = "" ]; then
|
|
|
|
NCPU=4
|
|
|
|
fi
|
|
|
|
|
2017-08-30 23:15:17 +02:00
|
|
|
QEMU_USER=`whoami`
|
|
|
|
|
2017-01-19 22:44:33 +01:00
|
|
|
cd $KERNDIR
|
2015-12-22 11:10:07 +01:00
|
|
|
read -r cmd <<EOF
|
2017-01-19 22:44:33 +01:00
|
|
|
$kvmdo qemu-system-x86_64 -s -cpu Haswell -smp $NCPU -m 2048 $kvmflag \
|
2017-05-15 01:15:07 +02:00
|
|
|
-rtc clock=vm \
|
2016-11-25 14:41:57 +01:00
|
|
|
-no-reboot -serial mon:stdio \
|
2015-12-22 11:10:07 +01:00
|
|
|
--machine $machineflag \
|
2016-11-25 14:41:57 +01:00
|
|
|
$bootDisk \
|
2017-09-04 22:56:36 +02:00
|
|
|
-netdev user,id=ethernet.0,hostfwd=tcp::5555-:1522,hostfwd=tcp::9999-:9,hostfwd=tcp::17010-:17010,hostfwd=tcp::17013-:17013 \
|
|
|
|
-device rtl8139,netdev=ethernet.0 \
|
2016-11-25 14:41:57 +01:00
|
|
|
$usbDev \
|
2017-08-30 23:15:17 +02:00
|
|
|
-append "maxcores=1024 nvram=$NVRAM nvrlen=512 nvroff=0 console=0 qemu-user=$QEMU_USER *acpi= $FS $KAPPEND" \
|
2016-11-25 14:41:57 +01:00
|
|
|
-initrd ./initrd \
|
|
|
|
-kernel $KERNEL $*
|
2015-12-22 11:10:07 +01:00
|
|
|
EOF
|
|
|
|
|
2016-11-25 14:41:57 +01:00
|
|
|
# To enable qemu log:
|
|
|
|
#-D $JEHANNE/../qemu.log -d int,cpu_reset,in_asm \
|
|
|
|
|
2017-09-04 22:56:36 +02:00
|
|
|
#-net dump,file=/tmp/vm0.pcap \
|
|
|
|
|
2015-12-22 11:10:07 +01:00
|
|
|
echo $cmd
|
|
|
|
eval $cmd
|
|
|
|
|
|
|
|
kill $ufspid
|
|
|
|
wait
|