30 lines
742 B
Bash
Executable file
30 lines
742 B
Bash
Executable file
#!/usr/bin/env sh
|
|
# What processor architecture to use
|
|
[ -z "$QEMUSH_ARCH" ] && QEMUSH_ARCH=$(uname -m)
|
|
|
|
# What machine type to use
|
|
[ -z "$QEMUSH_MACHINE" ] && case "$QEMUSH_ARCH" in
|
|
x86_64)
|
|
QEMUSH_MACHINE=q35
|
|
;;
|
|
esac
|
|
|
|
# How many CPU cores to use
|
|
[ -z "$QEMUSH_NPROC" ] && QEMUSH_NPROC=$(($(nproc) / 2))
|
|
|
|
# How much RAM to use
|
|
[ -z "$QEMUSH_RAM" ] && QEMUSH_RAM=$(($(grep '^MemAvailable:\s' /proc/meminfo | awk '{ print $2 }') / 2))K
|
|
|
|
# Use selected QEMUSH_MACHINE type if set
|
|
[ -n "$QEMUSH_MACHINE" ] && set -- -M "$QEMUSH_MACHINE" "$@"
|
|
|
|
# Set the arguments
|
|
set -- "qemu-system-${QEMUSH_ARCH}" \
|
|
-enable-kvm \
|
|
-cpu host -smp "$QEMUSH_NPROC" \
|
|
-m "$QEMUSH_RAM" \
|
|
"$@"
|
|
|
|
# Start the machine
|
|
set -x
|
|
exec "$@"
|