rename mips-vm as run-liminix-vm
This commit is contained in:
19
pkgs/run-liminix-vm/default.nix
Normal file
19
pkgs/run-liminix-vm/default.nix
Normal file
@@ -0,0 +1,19 @@
|
||||
{
|
||||
qemu
|
||||
, socat
|
||||
, writeShellScriptBin
|
||||
, symlinkJoin
|
||||
, lib
|
||||
}: let
|
||||
run-liminix-vm = writeShellScriptBin "run-liminix-vm" ''
|
||||
export PATH="${lib.makeBinPath [qemu]}:$PATH"
|
||||
${builtins.readFile ./run-liminix-vm.sh}
|
||||
'';
|
||||
connect = writeShellScriptBin "connect-vm" ''
|
||||
export PATH="${lib.makeBinPath [socat]}:$PATH"
|
||||
socat -,raw,echo=0,icanon=0,isig=0,icrnl=0,escape=0x0f unix-connect:$1
|
||||
'';
|
||||
in symlinkJoin {
|
||||
name = "run-liminix-vm";
|
||||
paths = [ run-liminix-vm connect ];
|
||||
}
|
55
pkgs/run-liminix-vm/mips-vm.sh
Executable file
55
pkgs/run-liminix-vm/mips-vm.sh
Executable file
@@ -0,0 +1,55 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
cleanup(){
|
||||
test -n "$rootfs" && test -f $rootfs && rm $rootfs
|
||||
}
|
||||
trap 'exit 1' INT HUP QUIT TERM ALRM USR1
|
||||
trap 'cleanup' EXIT
|
||||
|
||||
usage(){
|
||||
echo "usage: $(basename $0) [--background /path/to/state_directory] kernel rootimg [initramfs]"
|
||||
echo -e "\nWithout --background, use C-p c (not C-a c) to switch to the monitor"
|
||||
exit 1
|
||||
}
|
||||
|
||||
if test "$1" = "--background" ; then
|
||||
statedir=$2
|
||||
if test -z "$statedir" || ! test -d $statedir ; then
|
||||
usage
|
||||
fi
|
||||
pid="${statedir}/pid"
|
||||
socket="${statedir}/console"
|
||||
monitor="${statedir}/monitor"
|
||||
echo "running in background, socket is $socket, pid $pid"
|
||||
flags="--daemonize --pidfile $pid -serial unix:$socket,server,nowait -monitor unix:$monitor,server,nowait"
|
||||
shift;shift
|
||||
else
|
||||
flags="-serial mon:stdio"
|
||||
fi
|
||||
|
||||
test -n "$2" || usage
|
||||
|
||||
lan=${LAN-"socket,mcast=230.0.0.1:1235,localaddr=127.0.0.1"}
|
||||
|
||||
rootfs=$(mktemp run-liminix-vm-fs-XXXXXX)
|
||||
dd if=/dev/zero of=$rootfs bs=1M count=16 conv=sync
|
||||
dd if=$2 of=$rootfs bs=65536 conv=sync,nocreat,notrunc
|
||||
|
||||
if test -n "$3"; then
|
||||
initramfs="-initrd $3"
|
||||
fi
|
||||
|
||||
|
||||
INIT=${INIT-/bin/init}
|
||||
echo $QEMU_OPTIONS
|
||||
qemu-system-mips \
|
||||
-M malta -m 256 \
|
||||
-echr 16 \
|
||||
-append "liminix default console=ttyS0,38400n8 panic=10 oops=panic init=$INIT loglevel=8 root=/dev/mtdblock0 block2mtd.block2mtd=/dev/vda,65536" \
|
||||
-drive file=$rootfs,format=raw,readonly=off,if=virtio,index=0 \
|
||||
${initramfs} \
|
||||
-netdev socket,id=access,mcast=230.0.0.1:1234,localaddr=127.0.0.1 \
|
||||
-device virtio-net,disable-legacy=on,disable-modern=off,netdev=access,mac=ba:ad:1d:ea:21:02 \
|
||||
-netdev ${lan},id=lan \
|
||||
-device virtio-net,disable-legacy=on,disable-modern=off,netdev=lan,mac=ba:ad:1d:ea:21:01 \
|
||||
-kernel $1 -display none $flags ${QEMU_OPTIONS}
|
Reference in New Issue
Block a user