2018-10-16 09:01:38 +00:00
|
|
|
#!/bin/sh
|
2020-02-10 06:09:08 +00:00
|
|
|
# shellcheck disable=SC2086 # FIXME: fix these globing warnings
|
|
|
|
|
|
|
|
set -e
|
2018-10-16 09:01:38 +00:00
|
|
|
|
2020-06-24 02:47:20 +00:00
|
|
|
die() {
|
|
|
|
echo "die: $*"
|
|
|
|
exit 1
|
|
|
|
}
|
|
|
|
|
2019-12-22 14:55:52 +00:00
|
|
|
#SERENITY_PACKET_LOGGING_ARG="-object filter-dump,id=hue,netdev=breh,file=e1000.pcap"
|
2019-11-05 17:56:13 +00:00
|
|
|
|
2020-02-10 06:09:08 +00:00
|
|
|
[ -e /dev/kvm ] && [ -r /dev/kvm ] && [ -w /dev/kvm ] && SERENITY_KVM_ARG="-enable-kvm"
|
2019-11-04 12:03:33 +00:00
|
|
|
|
2019-12-23 21:07:29 +00:00
|
|
|
[ -z "$SERENITY_BOCHS_BIN" ] && SERENITY_BOCHS_BIN="bochs"
|
|
|
|
|
2019-05-04 00:51:50 +00:00
|
|
|
[ -z "$SERENITY_QEMU_BIN" ] && SERENITY_QEMU_BIN="qemu-system-i386"
|
|
|
|
|
2019-06-16 12:05:07 +00:00
|
|
|
[ -z "$SERENITY_KERNEL_CMDLINE" ] && SERENITY_KERNEL_CMDLINE="hello"
|
2019-06-02 07:50:18 +00:00
|
|
|
|
2020-01-15 21:13:29 +00:00
|
|
|
[ -z "$SERENITY_RAM_SIZE" ] && SERENITY_RAM_SIZE=256M
|
2019-11-01 22:46:39 +00:00
|
|
|
|
2019-11-01 23:01:45 +00:00
|
|
|
[ -z "$SERENITY_COMMON_QEMU_ARGS" ] && SERENITY_COMMON_QEMU_ARGS="
|
|
|
|
$SERENITY_EXTRA_QEMU_ARGS
|
|
|
|
-s -m $SERENITY_RAM_SIZE
|
2019-12-25 14:18:09 +00:00
|
|
|
-cpu max
|
2020-01-14 14:19:05 +00:00
|
|
|
-d cpu_reset,guest_errors
|
2020-03-06 13:49:35 +00:00
|
|
|
-smp 2
|
2019-11-01 23:01:45 +00:00
|
|
|
-device VGA,vgamem_mb=64
|
run.sh: Pass -drive instead of -hda to qemu.
run.sh currently makes qemu print this as the very first output:
WARNING: Image format was not specified for '_disk_image' and probing guessed raw.
Automatically detecting the format is dangerous for raw images, write operations on block 0 will be restricted.
Specify the 'raw' format explicitly to remove the restrictions.
This is scary for people who don't know that this is normal, and
write operations to block 0 being restricted could be confusing
for some operations happening from within serenity too at some point.
So specify the 'raw' format explicitly, like the warning suggests.
Requires using -drive instead of -hda.
From `man qemu-system`:
Instead of -hda, -hdb, -hdc, -hdd, you can use:
qemu-system-x86_64 -drive file=file,index=0,media=disk
So use that, and also pass format=raw.
2020-06-04 23:41:25 +00:00
|
|
|
-drive file=_disk_image,format=raw,index=0,media=disk
|
2020-01-02 13:54:32 +00:00
|
|
|
-device ich9-ahci
|
|
|
|
-debugcon stdio
|
|
|
|
-soundhw pcspk
|
|
|
|
-soundhw sb16
|
|
|
|
"
|
|
|
|
|
|
|
|
[ -z "$SERENITY_COMMON_QEMU_Q35_ARGS" ] && SERENITY_COMMON_QEMU_Q35_ARGS="
|
|
|
|
$SERENITY_EXTRA_QEMU_ARGS
|
|
|
|
-s -m $SERENITY_RAM_SIZE
|
|
|
|
-cpu max
|
|
|
|
-machine q35
|
2020-02-10 06:09:08 +00:00
|
|
|
-d cpu_reset,guest_errors
|
2020-03-06 13:49:35 +00:00
|
|
|
-smp 2
|
2020-01-02 13:54:32 +00:00
|
|
|
-device VGA,vgamem_mb=64
|
|
|
|
-device piix3-ide
|
|
|
|
-drive file=_disk_image,id=disk,if=none
|
|
|
|
-device ide-hd,bus=ide.6,drive=disk,unit=0
|
2019-11-01 23:01:45 +00:00
|
|
|
-debugcon stdio
|
|
|
|
-soundhw pcspk
|
|
|
|
-soundhw sb16
|
|
|
|
"
|
|
|
|
|
2019-05-01 19:45:17 +00:00
|
|
|
export SDL_VIDEO_X11_DGAMOUSE=0
|
2019-03-27 12:02:29 +00:00
|
|
|
|
2020-06-24 02:47:20 +00:00
|
|
|
: "${SERENITY_BUILD:=.}"
|
|
|
|
cd -P -- "$SERENITY_BUILD" || die "Could not cd to \"$SERENITY_BUILD\""
|
|
|
|
|
2019-03-11 11:43:45 +00:00
|
|
|
if [ "$1" = "b" ]; then
|
2020-06-24 03:08:19 +00:00
|
|
|
# Meta/run.sh b: bochs
|
2020-06-24 02:47:20 +00:00
|
|
|
[ -z "$SERENITY_BOCHSRC" ] && {
|
|
|
|
# Make sure that SERENITY_ROOT is set and not empty
|
|
|
|
[ -z "$SERENITY_ROOT" ] && die 'SERENITY_ROOT not set or empty'
|
|
|
|
SERENITY_BOCHSRC="$SERENITY_ROOT/Meta/bochsrc"
|
|
|
|
}
|
|
|
|
"$SERENITY_BOCHS_BIN" -q -f "$SERENITY_BOCHSRC"
|
2019-03-11 11:43:45 +00:00
|
|
|
elif [ "$1" = "qn" ]; then
|
2020-06-24 03:08:19 +00:00
|
|
|
# Meta/run.sh qn: qemu without network
|
2020-06-24 01:17:27 +00:00
|
|
|
"$SERENITY_QEMU_BIN" \
|
2019-11-01 23:01:45 +00:00
|
|
|
$SERENITY_COMMON_QEMU_ARGS \
|
2019-04-24 19:06:16 +00:00
|
|
|
-device e1000 \
|
2020-05-06 15:40:06 +00:00
|
|
|
-kernel Kernel/Kernel \
|
2019-11-01 23:01:45 +00:00
|
|
|
-append "${SERENITY_KERNEL_CMDLINE}"
|
2019-03-13 02:26:01 +00:00
|
|
|
elif [ "$1" = "qtap" ]; then
|
2020-06-24 03:08:19 +00:00
|
|
|
# Meta/run.sh qtap: qemu with tap
|
2020-06-24 01:17:27 +00:00
|
|
|
sudo "$SERENITY_QEMU_BIN" \
|
2019-11-01 23:01:45 +00:00
|
|
|
$SERENITY_COMMON_QEMU_ARGS \
|
2019-11-04 12:03:33 +00:00
|
|
|
$SERENITY_KVM_ARG \
|
2019-11-05 17:56:13 +00:00
|
|
|
$SERENITY_PACKET_LOGGING_ARG \
|
2019-04-24 19:06:16 +00:00
|
|
|
-netdev tap,ifname=tap0,id=br0 \
|
|
|
|
-device e1000,netdev=br0 \
|
2020-05-06 15:40:06 +00:00
|
|
|
-kernel Kernel/Kernel \
|
2019-11-01 23:01:45 +00:00
|
|
|
-append "${SERENITY_KERNEL_CMDLINE}"
|
2019-06-04 12:16:30 +00:00
|
|
|
elif [ "$1" = "qgrub" ]; then
|
2020-06-24 03:08:19 +00:00
|
|
|
# Meta/run.sh qgrub: qemu with grub
|
2020-06-24 01:17:27 +00:00
|
|
|
"$SERENITY_QEMU_BIN" \
|
2019-11-01 23:01:45 +00:00
|
|
|
$SERENITY_COMMON_QEMU_ARGS \
|
2019-11-04 12:03:33 +00:00
|
|
|
$SERENITY_KVM_ARG \
|
2019-11-05 17:56:13 +00:00
|
|
|
$SERENITY_PACKET_LOGGING_ARG \
|
2019-09-09 07:19:43 +00:00
|
|
|
-netdev user,id=breh,hostfwd=tcp:127.0.0.1:8888-10.0.2.15:8888,hostfwd=tcp:127.0.0.1:8823-10.0.2.15:23 \
|
2019-11-01 23:01:45 +00:00
|
|
|
-device e1000,netdev=breh
|
2020-01-02 13:54:32 +00:00
|
|
|
elif [ "$1" = "q35_cmd" ]; then
|
2020-06-24 03:08:19 +00:00
|
|
|
# Meta/run.sh q35_cmd: qemu (q35 chipset) with SerenityOS with custom commandline
|
2020-06-24 01:24:10 +00:00
|
|
|
shift
|
|
|
|
SERENITY_KERNEL_CMDLINE="$*"
|
2020-01-02 13:54:32 +00:00
|
|
|
echo "Starting SerenityOS, Commandline: ${SERENITY_KERNEL_CMDLINE}"
|
2020-06-24 01:17:27 +00:00
|
|
|
"$SERENITY_QEMU_BIN" \
|
2020-01-02 13:54:32 +00:00
|
|
|
$SERENITY_COMMON_QEMU_Q35_ARGS \
|
2020-01-14 14:19:05 +00:00
|
|
|
$SERENITY_KVM_ARG \
|
|
|
|
-netdev user,id=breh,hostfwd=tcp:127.0.0.1:8888-10.0.2.15:8888,hostfwd=tcp:127.0.0.1:8823-10.0.2.15:23 \
|
|
|
|
-device e1000,netdev=breh \
|
2020-05-06 15:40:06 +00:00
|
|
|
-kernel Kernel/Kernel \
|
2020-01-02 13:54:32 +00:00
|
|
|
-append "${SERENITY_KERNEL_CMDLINE}"
|
2019-11-13 17:29:16 +00:00
|
|
|
elif [ "$1" = "qcmd" ]; then
|
2020-06-24 03:08:19 +00:00
|
|
|
# Meta/run.sh qcmd: qemu with SerenityOS with custom commandline
|
2020-06-24 01:24:10 +00:00
|
|
|
shift
|
|
|
|
SERENITY_KERNEL_CMDLINE="$*"
|
2019-11-13 17:29:16 +00:00
|
|
|
echo "Starting SerenityOS, Commandline: ${SERENITY_KERNEL_CMDLINE}"
|
2020-06-24 01:17:27 +00:00
|
|
|
"$SERENITY_QEMU_BIN" \
|
2019-11-01 23:01:45 +00:00
|
|
|
$SERENITY_COMMON_QEMU_ARGS \
|
2020-01-14 14:19:05 +00:00
|
|
|
$SERENITY_KVM_ARG \
|
|
|
|
-netdev user,id=breh,hostfwd=tcp:127.0.0.1:8888-10.0.2.15:8888,hostfwd=tcp:127.0.0.1:8823-10.0.2.15:23 \
|
|
|
|
-device e1000,netdev=breh \
|
2020-05-06 15:40:06 +00:00
|
|
|
-kernel Kernel/Kernel \
|
2019-11-13 17:29:16 +00:00
|
|
|
-append "${SERENITY_KERNEL_CMDLINE}"
|
2019-03-13 02:26:01 +00:00
|
|
|
else
|
2020-06-24 03:08:19 +00:00
|
|
|
# Meta/run.sh: qemu with user networking
|
2020-06-24 01:17:27 +00:00
|
|
|
"$SERENITY_QEMU_BIN" \
|
2019-11-01 23:01:45 +00:00
|
|
|
$SERENITY_COMMON_QEMU_ARGS \
|
2019-11-04 12:03:33 +00:00
|
|
|
$SERENITY_KVM_ARG \
|
2019-11-05 17:56:13 +00:00
|
|
|
$SERENITY_PACKET_LOGGING_ARG \
|
2020-05-10 21:03:39 +00:00
|
|
|
-netdev user,id=breh,hostfwd=tcp:127.0.0.1:8888-10.0.2.15:8888,hostfwd=tcp:127.0.0.1:8823-10.0.2.15:23,hostfwd=tcp:127.0.0.1:8000-10.0.2.15:8000,hostfwd=tcp:127.0.0.1:2222-10.0.2.15:22 \
|
2019-03-13 16:17:07 +00:00
|
|
|
-device e1000,netdev=breh \
|
2020-05-06 15:40:06 +00:00
|
|
|
-kernel Kernel/Kernel \
|
2019-11-01 23:01:45 +00:00
|
|
|
-append "${SERENITY_KERNEL_CMDLINE}"
|
2019-11-04 12:03:33 +00:00
|
|
|
fi
|