2024-03-09 23:28:50 +01:00
|
|
|
#!/usr/bin/env sh
|
2024-03-11 15:11:17 +01:00
|
|
|
# What processor architecture to use
|
2024-03-12 10:48:32 +01:00
|
|
|
[ -z "$QEMUSH_ARCH" ] && QEMUSH_ARCH=$(uname -m)
|
2024-03-11 15:11:17 +01:00
|
|
|
|
2024-03-12 10:49:09 +01:00
|
|
|
# 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
|
2024-03-12 10:48:32 +01:00
|
|
|
[ -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
|
2024-04-17 11:29:09 +02:00
|
|
|
[ -z "$QEMUSH_RAM" ] && QEMUSH_RAM=$(($(grep '^MemAvailable:\s' /proc/meminfo | awk '{ print $2 }') / 2))K
|
2023-12-13 12:41:28 +01:00
|
|
|
|
2024-03-12 10:49:09 +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
|
2024-03-12 10:48:32 +01:00
|
|
|
set -- "qemu-system-${QEMUSH_ARCH}" \
|
2024-03-09 23:28:50 +01:00
|
|
|
-enable-kvm \
|
2024-03-12 10:48:32 +01:00
|
|
|
-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 "$@"
|