#!/bin/sh1# SPDX-License-Identifier: GPL-2.023CPUS_ONLINE=$(lscpu --online -p=cpu|grep -v -e '#')4#use last CPU for host. Why not the first?5#many devices tend to use cpu0 by default so6#it tends to be busier7HOST_AFFINITY=$(echo "${CPUS_ONLINE}"|tail -n 1)89#run command on all cpus10for cpu in $CPUS_ONLINE11do12#Don't run guest and host on same CPU13#It actually works ok if using signalling14if15(echo "$@" | grep -e "--sleep" > /dev/null) || \16test $HOST_AFFINITY '!=' $cpu17then18echo "GUEST AFFINITY $cpu"19"$@" --host-affinity $HOST_AFFINITY --guest-affinity $cpu20fi21done22echo "NO GUEST AFFINITY"23"$@" --host-affinity $HOST_AFFINITY24echo "NO AFFINITY"25"$@"262728