qemush/qemu/launchers/kvm

31 lines
727 B
Text
Raw Permalink Normal View History

2024-03-09 23:28:50 +01:00
#!/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
2024-03-09 23:28:50 +01:00
# How many CPU cores to use
[ -z "$QEMUSH_NPROC" ] && QEMUSH_NPROC=$(($(nproc) / 2))
2023-12-13 12:41:28 +01:00
2024-03-09 23:28:50 +01:00
# How much RAM to use
[ -z "$QEMUSH_RAM" ] && QEMUSH_RAM=$(($(free | grep '^Mem:\s' | awk '{ print $NF }') / 2))K
2023-12-13 12:41:28 +01:00
# Use selected QEMUSH_MACHINE type if set
[ -n "$QEMUSH_MACHINE" ] && set -- -M "$QEMUSH_MACHINE" "$@"
2024-03-09 23:28:50 +01:00
# Set the arguments
set -- "qemu-system-${QEMUSH_ARCH}" \
2024-03-09 23:28:50 +01:00
-enable-kvm \
-cpu host -smp "$QEMUSH_NPROC" \
-m "$QEMUSH_RAM" \
2024-03-09 23:28:50 +01:00
"$@"
2023-12-13 12:41:28 +01:00
2024-03-09 23:28:50 +01:00
# Start the machine
2024-03-12 10:47:46 +01:00
set -x
2024-03-09 23:28:50 +01:00
exec "$@"