Skip to content

Commit

Permalink
Merge pull request #50 from Ultramarine-Linux/pr/41-qemu-scripts
Browse files Browse the repository at this point in the history
Rewrite QEMU scripts
  • Loading branch information
madonuko authored Oct 4, 2024
2 parents 9cd0647 + 93eb7d4 commit ad4ec90
Show file tree
Hide file tree
Showing 3 changed files with 82 additions and 82 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
katsu-work/
.DS_Store
.DS_Store
*.env*
80 changes: 80 additions & 0 deletions qemu.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
#!/bin/bash

set -x

# This script is used to aid in testing Katsu builds. It will help you quickly set up a QEMU VM test environment so
# you can manually test builds. This script shouldn't be used in prod and is meant for development only.

# USAGE
# ./qemu.sh [qemu-disk|qemu-iso]
# If no argument is provided, qemu-disk is used by default


# Variables for test environment

# load .env if it exists
if [ -f .env ]; then
source .env
fi

# default values for QEMU
: ${QEMU_MEM:="4G"}
: ${QEMU_CPU:="4"}
: ${QEMU_BOOT:="uefi"}

TEST_HOME=$(pwd)/.test
KATSU_WORK=$(pwd)/katsu-work

# Get testing mode from second argument

if [ -z "$1" ]; then
SCRIPT_MODE="qemu-disk"
else
SCRIPT_MODE=$1
fi

function find_iso {
iso_path=$(find $KATSU_WORK -name "*.iso" | head -n 1)
if [ -z "$iso_path" ]; then
echo "No ISO found in $KATSU_WORK"
exit 1
fi
echo $iso_path
}


# Quickly get the absolute path of a file

function abs_path {
echo $(realpath $1)
}

KATSU_IMG_PATH="$KATSU_WORK/image/katsu.img"


if [ "$SCRIPT_MODE" = "qemu-disk" ]; then
QEMU_ARGS="-drive file="$KATSU_IMG_PATH",format=raw,if=virtio"
else
QEMU_ARGS="-cdrom $(find_iso)"
fi

# if QEMU_BOOT = "uefi" then add UEFI firmware
if [ "$QEMU_BOOT" = "uefi" ]; then
QEMU_ARGS+=" -bios /usr/share/OVMF/OVMF_CODE.fd"
fi


# Run QEMU


function setup_test_home {
mkdir -p $TEST_HOME
mkdir -p $KATSU_WORK
}

qemu-kvm \
-machine type=q35,accel=kvm \
-cpu host \
-m $QEMU_MEM \
-smp $QEMU_CPU \
$QEMU_ARGS
81 changes: 0 additions & 81 deletions test.fish

This file was deleted.

0 comments on commit ad4ec90

Please sign in to comment.