#!/bin/sh

# Libvirt introspects the binary using -M none. In that case, don't try
# to init KVM, which will fail and be noisy if the host has kvm disabled
opts="-machine accel=kvm"
if echo "$@" | grep -q " -M none "; then
    opts=
fi

arch="$(uname -m)"
case "$arch" in
	i?86) arch="i386" ;;
	x86_64) arch="x86_64" ;;
	aarch64) arch=aarch64 ;;
	arm*) arch=arm ;;
	ppc64|ppc64le) arch=ppc64 ;;
	ppc) arch=ppc ;;
esac

exec /usr/bin/qemu-system-"$arch" $opts "$@"
