make configurable default memory size and minimum disk size
This commit is contained in:
parent
68fb5be67a
commit
50d32d2cba
@ -21,13 +21,15 @@
|
|||||||
# shellcheck source=/usr/lib/libretools/messages.sh
|
# shellcheck source=/usr/lib/libretools/messages.sh
|
||||||
source "$(librelib messages)"
|
source "$(librelib messages)"
|
||||||
|
|
||||||
|
readonly DEF_RAM_MB=1000
|
||||||
|
|
||||||
|
|
||||||
usage() {
|
usage() {
|
||||||
print "USAGE: %s [-h] <img> [qemu-args ...]" "${0##*/}"
|
print "USAGE: %s [-h] <img> [qemu-args ...]" "${0##*/}"
|
||||||
prose "Determine the architecture of <img> and boot it using qemu. <img> is assumed
|
prose "Determine the architecture of <img> and boot it using qemu. <img> is assumed
|
||||||
to be a valid, raw-formatted parabola virtual machine image, ideally
|
to be a valid, raw-formatted parabola virtual machine image, ideally
|
||||||
created using pvmbootstrap. The started instance is assigned 1G of
|
created using pvmbootstrap. The started instance is assigned
|
||||||
RAM and one SMP core."
|
${DEF_RAM_MB}MB of RAM and one SMP core."
|
||||||
echo
|
echo
|
||||||
prose "When a graphical desktop environment is available, start the machine
|
prose "When a graphical desktop environment is available, start the machine
|
||||||
normally, otherwise append -nographic to the qemu options. This behavior
|
normally, otherwise append -nographic to the qemu options. This behavior
|
||||||
@ -129,13 +131,13 @@ pvm_guess_qemu_args() {
|
|||||||
local kernel_console
|
local kernel_console
|
||||||
case "$2" in
|
case "$2" in
|
||||||
i386|x86_64|ppc64)
|
i386|x86_64|ppc64)
|
||||||
qemu_args+=(-m 1G -hda "$1")
|
qemu_args+=(-m $DEF_RAM_MB -hda "$1")
|
||||||
# unmount the unneeded virtual drive early
|
# unmount the unneeded virtual drive early
|
||||||
pvm_umount ;;
|
pvm_umount ;;
|
||||||
arm)
|
arm)
|
||||||
kernel_console="console=tty0 console=ttyAMA0 "
|
kernel_console="console=tty0 console=ttyAMA0 "
|
||||||
qemu_args+=(-machine virt
|
qemu_args+=(-machine virt
|
||||||
-m 1G
|
-m $DEF_RAM_MB
|
||||||
-kernel "$workdir"/vmlinuz-linux-libre
|
-kernel "$workdir"/vmlinuz-linux-libre
|
||||||
-initrd "$workdir"/initramfs-linux-libre.img
|
-initrd "$workdir"/initramfs-linux-libre.img
|
||||||
-append "${kernel_console}rw root=/dev/vda3"
|
-append "${kernel_console}rw root=/dev/vda3"
|
||||||
@ -146,7 +148,7 @@ pvm_guess_qemu_args() {
|
|||||||
riscv64)
|
riscv64)
|
||||||
kernel_console=$( [ -z "$DISPLAY" ] && echo "console=ttyS0 " )
|
kernel_console=$( [ -z "$DISPLAY" ] && echo "console=ttyS0 " )
|
||||||
qemu_args+=(-machine virt
|
qemu_args+=(-machine virt
|
||||||
-m 1G
|
-m $DEF_RAM_MB
|
||||||
-kernel "$workdir"/bbl
|
-kernel "$workdir"/bbl
|
||||||
-append "${kernel_console}rw root=/dev/vda"
|
-append "${kernel_console}rw root=/dev/vda"
|
||||||
-drive "file=${loopdev}p3,format=raw,id=hd0"
|
-drive "file=${loopdev}p3,format=raw,id=hd0"
|
||||||
|
@ -52,7 +52,7 @@ usage() {
|
|||||||
echo " -M <mirror> Specify a different mirror from which to fetch packages"
|
echo " -M <mirror> Specify a different mirror from which to fetch packages"
|
||||||
echo " (default: $DEF_MIRROR)"
|
echo " (default: $DEF_MIRROR)"
|
||||||
echo " -O Bootstrap an openrc system instead of a systemd one"
|
echo " -O Bootstrap an openrc system instead of a systemd one"
|
||||||
echo " -s <img_size> Set the size (in GB) of the VM image (default: $DEF_IMG_GB)"
|
echo " -s <img_size> Set the size (in GB) of the VM image (minimum: $MIN_GB, default: $DEF_IMG_GB)"
|
||||||
echo
|
echo
|
||||||
echo "Pre-defined hooks:"
|
echo "Pre-defined hooks:"
|
||||||
echo " ethernet-dhcp: Configure and enable an ethernet device in the virtual"
|
echo " ethernet-dhcp: Configure and enable an ethernet device in the virtual"
|
||||||
@ -390,9 +390,10 @@ main() {
|
|||||||
|
|
||||||
local shiftlen=$(( OPTIND - 1 ))
|
local shiftlen=$(( OPTIND - 1 ))
|
||||||
shift $shiftlen
|
shift $shiftlen
|
||||||
if [ "$#" -ne 2 ]; then usage >&2; exit "$EXIT_INVALIDARGUMENT"; fi
|
|
||||||
local file="$1"
|
local file="$1"
|
||||||
local arch="$2"
|
local arch="$2"
|
||||||
|
[ "$#" -ne 2 ] && usage >&2 && exit "$EXIT_INVALIDARGUMENT"
|
||||||
|
[ "$ImgSizeGb" -lt $MIN_GB ] && usage >&2 && exit "$EXIT_INVALIDARGUMENT"
|
||||||
|
|
||||||
# determine if the target arch is supported
|
# determine if the target arch is supported
|
||||||
case "$arch" in
|
case "$arch" in
|
||||||
|
Loading…
Reference in New Issue
Block a user