#!/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 # How many CPU cores to use [ -z "$QEMUSH_NPROC" ] && QEMUSH_NPROC=$(($(nproc) / 2)) # How much RAM to use [ -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-${QEMUSH_ARCH}" \ -enable-kvm \ -cpu host -smp "$QEMUSH_NPROC" \ -m "$QEMUSH_RAM" \ "$@" # Start the machine set -x exec "$@"