qemush/qemu/launchers/kvm

24 lines
493 B
Bash
Executable file

#!/usr/bin/env sh
# What processor architecture to use
arch=$QEMUSH_ARCH
[ -z "$arch" ] && arch=$(uname -m)
# How many CPU cores to use
nproc=$QEMUSH_NPROC
[ -z "$nproc" ] && nproc=$(($(nproc) / 2))
# How much RAM to use
ram=$QEMUSH_RAM
[ -z "$ram" ] && ram=$(($(free | grep '^Mem:\s' | awk '{ print $NF }') / 2))K
# Set the arguments
set -- "qemu-system-${arch}" \
-enable-kvm \
-M q35 \
-cpu host -smp "$nproc" \
-m "$ram" \
"$@"
# Start the machine
set -x
exec "$@"