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