diff options
author | Luke Shumaker <lukeshu@lukeshu.com> | 2018-07-12 00:41:28 -0400 |
---|---|---|
committer | Luke Shumaker <lukeshu@lukeshu.com> | 2018-08-21 00:51:06 -0400 |
commit | 386c4d38702b2643c09d8db7d7851a39f8798406 (patch) | |
tree | 3295403d934ffeb6bcbd1837d90b090fc2c676e8 /systemd/system/qemu | |
parent | e3bb3556afb3a612a724095614fade0863a1a667 (diff) |
Add NUMA support and vCPU pinning
Diffstat (limited to 'systemd/system/qemu')
-rwxr-xr-x | systemd/system/qemu | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/systemd/system/qemu b/systemd/system/qemu index 475ec10..324154b 100755 --- a/systemd/system/qemu +++ b/systemd/system/qemu @@ -2,6 +2,8 @@ shopt -s lastpipe set -euE -o pipefail +declare -A vcpu2cpulist +numactl=() source "/etc/conf.d/qemu.d/$1" args+=( -name "$1",debug-threads=on @@ -11,7 +13,25 @@ args+=( -serial file:"/dev/stdout" -daemonize ) + { - qemu-system-"${system}" "${args[@]}" + numactl "${numactl[@]}" -- qemu-system-"${system}" "${args[@]}" + + if [[ ${#vcpu2cpulist[@]} -gt 0 ]]; then + declare -A vcpu2tid + while read -r line; do + if [[ $line != ?' CPU #'*:*thread_id=* ]]; then + continue + fi + vcpu=${line#?' CPU #'}; vcpu=${vcpu%%:*} + tid=${line#thread_id=}; tid=${tid%% *} + vcpu2tid[$vcpu]=$tid + done < <(socat STDIO UNIX-CONNECT:"/run/qemu-$1/monitor.sock" <<<'info cpus') + + for vcpu in "${!vcpu_pins[@]}"; do + taskset --cpu-list --pid -- "${vcpu2cpulist[@]}" "${vcpu2tid[$vcpu]}" + done + fi + systemd-notify --ready } | exec cat |