2018-10-16 12:01:38 +03:00
|
|
|
#!/bin/sh
|
2020-02-10 09:09:08 +03:00
|
|
|
# shellcheck disable=SC2086 # FIXME: fix these globing warnings
|
|
|
|
|
|
|
|
set -e
|
2018-10-16 12:01:38 +03:00
|
|
|
|
2020-06-24 05:47:20 +03:00
|
|
|
die() {
|
|
|
|
echo "die: $*"
|
|
|
|
exit 1
|
|
|
|
}
|
|
|
|
|
2019-12-22 17:55:52 +03:00
|
|
|
#SERENITY_PACKET_LOGGING_ARG="-object filter-dump,id=hue,netdev=breh,file=e1000.pcap"
|
2019-11-05 20:56:13 +03:00
|
|
|
|
2021-02-26 01:36:59 +03:00
|
|
|
[ -e /dev/kvm ] && [ -r /dev/kvm ] && [ -w /dev/kvm ] && SERENITY_VIRT_TECH_ARG="-enable-kvm"
|
2019-11-04 15:03:33 +03:00
|
|
|
|
2019-12-24 00:07:29 +03:00
|
|
|
[ -z "$SERENITY_BOCHS_BIN" ] && SERENITY_BOCHS_BIN="bochs"
|
|
|
|
|
2021-02-26 01:36:59 +03:00
|
|
|
# To support virtualization acceleration on mac
|
|
|
|
# we need to use 64-bit qemu
|
2021-03-08 02:19:37 +03:00
|
|
|
if [ "$(uname)" = "Darwin" ] && [ "$(uname -m)" = "x86_64" ]; then
|
2021-02-26 01:36:59 +03:00
|
|
|
|
|
|
|
[ -z "$SERENITY_QEMU_BIN" ] && SERENITY_QEMU_BIN="qemu-system-x86_64"
|
|
|
|
|
|
|
|
if $SERENITY_QEMU_BIN --accel help | grep -q hvf; then
|
|
|
|
SERENITY_VIRT_TECH_ARG="--accel hvf"
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
2021-03-06 19:43:53 +03:00
|
|
|
SERENITY_RUN="${SERENITY_RUN:-$1}"
|
2021-02-26 01:36:59 +03:00
|
|
|
|
2019-05-04 03:51:50 +03:00
|
|
|
[ -z "$SERENITY_QEMU_BIN" ] && SERENITY_QEMU_BIN="qemu-system-i386"
|
|
|
|
|
2019-06-16 15:05:07 +03:00
|
|
|
[ -z "$SERENITY_KERNEL_CMDLINE" ] && SERENITY_KERNEL_CMDLINE="hello"
|
2019-06-02 10:50:18 +03:00
|
|
|
|
2021-01-01 03:13:52 +03:00
|
|
|
[ -z "$SERENITY_RAM_SIZE" ] && SERENITY_RAM_SIZE=512M
|
2019-11-02 01:46:39 +03:00
|
|
|
|
2020-08-14 13:45:31 +03:00
|
|
|
[ -z "$SERENITY_QEMU_CPU" ] && SERENITY_QEMU_CPU="max"
|
|
|
|
|
2020-06-24 12:01:31 +03:00
|
|
|
[ -z "$SERENITY_DISK_IMAGE" ] && {
|
2021-03-06 19:43:53 +03:00
|
|
|
if [ "$SERENITY_RUN" = qgrub ]; then
|
2020-06-24 12:01:31 +03:00
|
|
|
SERENITY_DISK_IMAGE="grub_disk_image"
|
|
|
|
else
|
|
|
|
SERENITY_DISK_IMAGE="_disk_image"
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2019-11-02 02:01:45 +03:00
|
|
|
[ -z "$SERENITY_COMMON_QEMU_ARGS" ] && SERENITY_COMMON_QEMU_ARGS="
|
|
|
|
$SERENITY_EXTRA_QEMU_ARGS
|
|
|
|
-s -m $SERENITY_RAM_SIZE
|
2020-08-14 13:45:31 +03:00
|
|
|
-cpu $SERENITY_QEMU_CPU
|
2020-07-06 17:58:40 +03:00
|
|
|
-d guest_errors
|
2020-03-06 16:49:35 +03:00
|
|
|
-smp 2
|
2019-11-02 02:01:45 +03:00
|
|
|
-device VGA,vgamem_mb=64
|
2020-06-24 12:01:31 +03:00
|
|
|
-drive file=${SERENITY_DISK_IMAGE},format=raw,index=0,media=disk
|
2020-01-02 16:54:32 +03:00
|
|
|
-device ich9-ahci
|
2020-09-04 10:59:38 +03:00
|
|
|
-usb
|
2021-04-15 12:22:02 +03:00
|
|
|
-device virtio-serial
|
|
|
|
-chardev stdio,id=stdout,mux=on
|
|
|
|
-device virtconsole,chardev=stdout
|
|
|
|
-device isa-debugcon,chardev=stdout
|
2021-01-22 19:56:19 +03:00
|
|
|
-device virtio-rng-pci
|
2020-01-02 16:54:32 +03:00
|
|
|
-soundhw pcspk
|
2020-09-12 13:02:16 +03:00
|
|
|
-device sb16
|
2020-01-02 16:54:32 +03:00
|
|
|
"
|
|
|
|
|
|
|
|
[ -z "$SERENITY_COMMON_QEMU_Q35_ARGS" ] && SERENITY_COMMON_QEMU_Q35_ARGS="
|
|
|
|
$SERENITY_EXTRA_QEMU_ARGS
|
|
|
|
-s -m $SERENITY_RAM_SIZE
|
2020-08-14 13:45:31 +03:00
|
|
|
-cpu $SERENITY_QEMU_CPU
|
2020-01-02 16:54:32 +03:00
|
|
|
-machine q35
|
2020-07-06 17:58:40 +03:00
|
|
|
-d guest_errors
|
2020-03-06 16:49:35 +03:00
|
|
|
-smp 2
|
2020-01-02 16:54:32 +03:00
|
|
|
-device VGA,vgamem_mb=64
|
2020-06-24 12:01:31 +03:00
|
|
|
-drive file=${SERENITY_DISK_IMAGE},id=disk,if=none
|
2021-02-26 07:26:23 +03:00
|
|
|
-device ahci,id=ahci
|
|
|
|
-device ide-hd,bus=ahci.0,drive=disk,unit=0
|
2020-09-04 10:59:38 +03:00
|
|
|
-usb
|
2021-04-15 12:39:48 +03:00
|
|
|
-device virtio-serial
|
|
|
|
-chardev stdio,id=stdout,mux=on
|
|
|
|
-device virtconsole,chardev=stdout
|
|
|
|
-device isa-debugcon,chardev=stdout
|
2021-01-22 19:56:19 +03:00
|
|
|
-device virtio-rng-pci
|
2019-11-02 02:01:45 +03:00
|
|
|
-soundhw pcspk
|
2020-09-12 13:02:16 +03:00
|
|
|
-device sb16
|
2019-11-02 02:01:45 +03:00
|
|
|
"
|
|
|
|
|
2019-05-01 22:45:17 +03:00
|
|
|
export SDL_VIDEO_X11_DGAMOUSE=0
|
2019-03-27 15:02:29 +03:00
|
|
|
|
2020-06-24 05:47:20 +03:00
|
|
|
: "${SERENITY_BUILD:=.}"
|
|
|
|
cd -P -- "$SERENITY_BUILD" || die "Could not cd to \"$SERENITY_BUILD\""
|
|
|
|
|
2020-09-18 22:50:20 +03:00
|
|
|
if [ "$SERENITY_RUN" = "b" ]; then
|
2020-06-24 06:08:19 +03:00
|
|
|
# Meta/run.sh b: bochs
|
2020-06-24 05:47:20 +03:00
|
|
|
[ -z "$SERENITY_BOCHSRC" ] && {
|
2021-04-20 03:51:04 +03:00
|
|
|
# Make sure that SERENITY_SOURCE_DIR is set and not empty
|
|
|
|
[ -z "$SERENITY_SOURCE_DIR" ] && die 'SERENITY_SOURCE_DIR not set or empty'
|
|
|
|
SERENITY_BOCHSRC="$SERENITY_SOURCE_DIR/Meta/bochsrc"
|
2020-06-24 05:47:20 +03:00
|
|
|
}
|
|
|
|
"$SERENITY_BOCHS_BIN" -q -f "$SERENITY_BOCHSRC"
|
2020-09-18 22:50:20 +03:00
|
|
|
elif [ "$SERENITY_RUN" = "qn" ]; then
|
2020-06-24 06:08:19 +03:00
|
|
|
# Meta/run.sh qn: qemu without network
|
2020-06-24 04:17:27 +03:00
|
|
|
"$SERENITY_QEMU_BIN" \
|
2019-11-02 02:01:45 +03:00
|
|
|
$SERENITY_COMMON_QEMU_ARGS \
|
2019-04-24 22:06:16 +03:00
|
|
|
-device e1000 \
|
2020-05-06 18:40:06 +03:00
|
|
|
-kernel Kernel/Kernel \
|
2019-11-02 02:01:45 +03:00
|
|
|
-append "${SERENITY_KERNEL_CMDLINE}"
|
2020-09-18 22:50:20 +03:00
|
|
|
elif [ "$SERENITY_RUN" = "qtap" ]; then
|
2020-06-24 06:08:19 +03:00
|
|
|
# Meta/run.sh qtap: qemu with tap
|
2021-04-29 21:02:43 +03:00
|
|
|
sudo ip tuntap del dev tap0 mode tap || true
|
2021-04-27 01:36:23 +03:00
|
|
|
sudo ip tuntap add dev tap0 mode tap user "$(id -u)"
|
|
|
|
"$SERENITY_QEMU_BIN" \
|
2019-11-02 02:01:45 +03:00
|
|
|
$SERENITY_COMMON_QEMU_ARGS \
|
2021-02-26 01:36:59 +03:00
|
|
|
$SERENITY_VIRT_TECH_ARG \
|
2019-11-05 20:56:13 +03:00
|
|
|
$SERENITY_PACKET_LOGGING_ARG \
|
2019-04-24 22:06:16 +03:00
|
|
|
-netdev tap,ifname=tap0,id=br0 \
|
|
|
|
-device e1000,netdev=br0 \
|
2020-05-06 18:40:06 +03:00
|
|
|
-kernel Kernel/Kernel \
|
2019-11-02 02:01:45 +03:00
|
|
|
-append "${SERENITY_KERNEL_CMDLINE}"
|
2021-04-27 01:36:23 +03:00
|
|
|
sudo ip tuntap del dev tap0 mode tap
|
2020-09-18 22:50:20 +03:00
|
|
|
elif [ "$SERENITY_RUN" = "qgrub" ]; then
|
2020-06-24 06:08:19 +03:00
|
|
|
# Meta/run.sh qgrub: qemu with grub
|
2020-06-24 04:17:27 +03:00
|
|
|
"$SERENITY_QEMU_BIN" \
|
2019-11-02 02:01:45 +03:00
|
|
|
$SERENITY_COMMON_QEMU_ARGS \
|
2021-02-26 01:36:59 +03:00
|
|
|
$SERENITY_VIRT_TECH_ARG \
|
2019-11-05 20:56:13 +03:00
|
|
|
$SERENITY_PACKET_LOGGING_ARG \
|
2019-09-09 10:19:43 +03: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-02 02:01:45 +03:00
|
|
|
-device e1000,netdev=breh
|
2020-09-18 22:50:20 +03:00
|
|
|
elif [ "$SERENITY_RUN" = "q35_cmd" ]; then
|
2020-06-24 06:08:19 +03:00
|
|
|
# Meta/run.sh q35_cmd: qemu (q35 chipset) with SerenityOS with custom commandline
|
2020-06-24 04:24:10 +03:00
|
|
|
shift
|
|
|
|
SERENITY_KERNEL_CMDLINE="$*"
|
2020-01-02 16:54:32 +03:00
|
|
|
echo "Starting SerenityOS, Commandline: ${SERENITY_KERNEL_CMDLINE}"
|
2020-06-24 04:17:27 +03:00
|
|
|
"$SERENITY_QEMU_BIN" \
|
2020-01-02 16:54:32 +03:00
|
|
|
$SERENITY_COMMON_QEMU_Q35_ARGS \
|
2021-02-26 01:36:59 +03:00
|
|
|
$SERENITY_VIRT_TECH_ARG \
|
2020-01-14 17:19:05 +03: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 \
|
|
|
|
-device e1000,netdev=breh \
|
2020-05-06 18:40:06 +03:00
|
|
|
-kernel Kernel/Kernel \
|
2020-01-02 16:54:32 +03:00
|
|
|
-append "${SERENITY_KERNEL_CMDLINE}"
|
2020-09-18 22:50:20 +03:00
|
|
|
elif [ "$SERENITY_RUN" = "qcmd" ]; then
|
2020-06-24 06:08:19 +03:00
|
|
|
# Meta/run.sh qcmd: qemu with SerenityOS with custom commandline
|
2020-06-24 04:24:10 +03:00
|
|
|
shift
|
|
|
|
SERENITY_KERNEL_CMDLINE="$*"
|
2019-11-13 20:29:16 +03:00
|
|
|
echo "Starting SerenityOS, Commandline: ${SERENITY_KERNEL_CMDLINE}"
|
2020-06-24 04:17:27 +03:00
|
|
|
"$SERENITY_QEMU_BIN" \
|
2019-11-02 02:01:45 +03:00
|
|
|
$SERENITY_COMMON_QEMU_ARGS \
|
2021-02-26 01:36:59 +03:00
|
|
|
$SERENITY_VIRT_TECH_ARG \
|
2020-01-14 17:19:05 +03: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 \
|
|
|
|
-device e1000,netdev=breh \
|
2020-05-06 18:40:06 +03:00
|
|
|
-kernel Kernel/Kernel \
|
2019-11-13 20:29:16 +03:00
|
|
|
-append "${SERENITY_KERNEL_CMDLINE}"
|
2021-01-11 01:38:40 +03:00
|
|
|
elif [ "$SERENITY_RUN" = "ci" ]; then
|
|
|
|
# Meta/run.sh ci: qemu in text mode
|
|
|
|
echo "Running QEMU in CI"
|
|
|
|
"$SERENITY_QEMU_BIN" \
|
|
|
|
$SERENITY_EXTRA_QEMU_ARGS \
|
|
|
|
-s -m $SERENITY_RAM_SIZE \
|
|
|
|
-cpu $SERENITY_QEMU_CPU \
|
|
|
|
-d guest_errors \
|
|
|
|
-smp 2 \
|
|
|
|
-drive file=${SERENITY_DISK_IMAGE},format=raw,index=0,media=disk \
|
|
|
|
-device ich9-ahci \
|
|
|
|
-nographic \
|
|
|
|
-display none \
|
|
|
|
-debugcon file:debug.log \
|
|
|
|
-kernel Kernel/Kernel \
|
|
|
|
-append "${SERENITY_KERNEL_CMDLINE}"
|
2019-03-13 05:26:01 +03:00
|
|
|
else
|
2020-06-24 06:08:19 +03:00
|
|
|
# Meta/run.sh: qemu with user networking
|
2020-06-24 04:17:27 +03:00
|
|
|
"$SERENITY_QEMU_BIN" \
|
2019-11-02 02:01:45 +03:00
|
|
|
$SERENITY_COMMON_QEMU_ARGS \
|
2021-02-26 01:36:59 +03:00
|
|
|
$SERENITY_VIRT_TECH_ARG \
|
2019-11-05 20:56:13 +03:00
|
|
|
$SERENITY_PACKET_LOGGING_ARG \
|
2020-05-11 00:03:39 +03: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 19:17:07 +03:00
|
|
|
-device e1000,netdev=breh \
|
2020-05-06 18:40:06 +03:00
|
|
|
-kernel Kernel/Kernel \
|
2019-11-02 02:01:45 +03:00
|
|
|
-append "${SERENITY_KERNEL_CMDLINE}"
|
2019-11-04 15:03:33 +03:00
|
|
|
fi
|