2023-02-08 23:16:39 +01:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
|
|
|
usage(){
|
|
|
|
echo "usage: $(basename $0) [--background /path/to/state_directory] kernel rootimg"
|
|
|
|
echo -e "\nWithout --background, use C-p c (not C-a c) to switch to the monitor"
|
|
|
|
exit 1
|
|
|
|
}
|
2022-09-24 22:03:26 +02:00
|
|
|
|
|
|
|
if test "$1" = "--background" ; then
|
2023-02-08 23:16:39 +01:00
|
|
|
statedir=$2
|
|
|
|
if test -z "$statedir" || ! test -d $statedir ; then
|
|
|
|
usage
|
|
|
|
fi
|
|
|
|
pid="${statedir}/pid"
|
|
|
|
socket="${statedir}/console"
|
|
|
|
monitor="${statedir}/monitor"
|
2022-09-26 11:47:29 +02:00
|
|
|
echo "running in background, socket is $socket, pid $pid"
|
2023-02-08 23:16:39 +01:00
|
|
|
flags="--daemonize --pidfile $pid -serial unix:$socket,server,nowait -monitor unix:$monitor,server,nowait"
|
2022-09-24 22:03:26 +02:00
|
|
|
shift;shift
|
|
|
|
else
|
|
|
|
flags="-serial mon:stdio"
|
|
|
|
fi
|
|
|
|
|
2023-02-08 23:16:39 +01:00
|
|
|
test -n "$2" || usage
|
|
|
|
|
|
|
|
|
2022-09-27 15:06:39 +02:00
|
|
|
INIT=${INIT-/bin/init}
|
2022-10-02 11:05:28 +02:00
|
|
|
echo $QEMU_OPTIONS
|
2022-09-24 22:03:26 +02:00
|
|
|
qemu-system-mips \
|
|
|
|
-M malta -m 256 \
|
|
|
|
-echr 16 \
|
2023-04-02 19:49:40 +02:00
|
|
|
-append "liminix default console=ttyS0,38400n8 panic=10 oops=panic init=$INIT loglevel=8 root=/dev/mtdblock0 block2mtd.block2mtd=/dev/vda,4096" \
|
2022-09-24 22:03:26 +02:00
|
|
|
-drive file=$2,format=raw,readonly=on,if=virtio \
|
2023-02-05 18:37:31 +01:00
|
|
|
-netdev socket,id=access,mcast=230.0.0.1:1234,localaddr=127.0.0.1 \
|
2022-09-24 22:03:26 +02:00
|
|
|
-device virtio-net-pci,disable-legacy=on,disable-modern=off,netdev=access,mac=ba:ad:1d:ea:21:02 \
|
2023-02-05 18:37:31 +01:00
|
|
|
-netdev socket,id=lan,mcast=230.0.0.1:1235,localaddr=127.0.0.1 \
|
2022-09-24 22:03:26 +02:00
|
|
|
-device virtio-net-pci,disable-legacy=on,disable-modern=off,netdev=lan,mac=ba:ad:1d:ea:21:01 \
|
2023-02-08 23:16:39 +01:00
|
|
|
-kernel $1 -display none $flags ${QEMU_OPTIONS}
|