Compare commits
3 commits
3514fa96ef
...
78fdd1c4a0
Author | SHA1 | Date | |
---|---|---|---|
78fdd1c4a0 | |||
428ceb7738 | |||
84722e404f |
1 changed files with 17 additions and 12 deletions
|
@ -1,25 +1,30 @@
|
|||
#!/usr/bin/env sh
|
||||
set -x
|
||||
|
||||
# What processor architecture to use
|
||||
arch=$QEMUSH_ARCH
|
||||
[ -z "$arch" ] && arch=$(uname -m)
|
||||
[ -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
|
||||
nproc=$QEMUSH_NPROC
|
||||
[ -z "$nproc" ] && nproc=$(($(nproc) / 2))
|
||||
[ -z "$QEMUSH_NPROC" ] && QEMUSH_NPROC=$(($(nproc) / 2))
|
||||
|
||||
# How much RAM to use
|
||||
ram=$QEMUSH_RAM
|
||||
[ -z "$ram" ] && ram=$(($(free | grep '^Mem:\s' | awk '{ print $NF }') / 2))K
|
||||
[ -z "$QEMUSH_RAM" ] && QEMUSH_RAM=$(($(free | grep '^Mem:\s' | awk '{ print $NF }') / 2))K
|
||||
|
||||
# Use selected QEMUSH_MACHINE type if set
|
||||
[ -n "$QEMUSH_MACHINE" ] && set -- -M "$QEMUSH_MACHINE" "$@"
|
||||
|
||||
# Set the arguments
|
||||
set -- "qemu-system-${arch}" \
|
||||
set -- "qemu-system-${QEMUSH_ARCH}" \
|
||||
-enable-kvm \
|
||||
-M q35 \
|
||||
-cpu host -smp "$nproc" \
|
||||
-m "$ram" \
|
||||
-cpu host -smp "$QEMUSH_NPROC" \
|
||||
-m "$QEMUSH_RAM" \
|
||||
"$@"
|
||||
|
||||
# Start the machine
|
||||
set -x
|
||||
exec "$@"
|
||||
|
|
Loading…
Reference in a new issue