summaryrefslogtreecommitdiff
path: root/qemu.in
diff options
context:
space:
mode:
authorLuke Shumaker <lukeshu@lukeshu.com>2018-08-23 20:07:28 -0400
committerLuke Shumaker <lukeshu@lukeshu.com>2018-08-23 20:07:28 -0400
commitd31a16c435e497f320ccfa880122dff963f151a7 (patch)
tree35d5c3423f3f77743f2e89dee17cff88a9511d2b /qemu.in
parent799e0edc196c4273b728b9f832d90dc79bbf8bbe (diff)
Organize in to an installable packagev20180714
Diffstat (limited to 'qemu.in')
-rwxr-xr-xqemu.in37
1 files changed, 37 insertions, 0 deletions
diff --git a/qemu.in b/qemu.in
new file mode 100755
index 0000000..566cacf
--- /dev/null
+++ b/qemu.in
@@ -0,0 +1,37 @@
+#!/usr/bin/env bash
+shopt -s lastpipe
+set -euE -o pipefail
+
+declare -A vcpu2cpulist
+numactl=()
+source "@pkgconfdir@/$1"
+args+=(
+ -name "$1",debug-threads=on
+ -pidfile "@runstatedir@/qemu-$1/pid"
+ -vnc unix:"@runstatedir@/qemu-$1/vnc.sock"
+ -monitor unix:"@runstatedir@/qemu-$1/monitor.sock",server,nowait
+ -serial file:"/dev/stdout"
+ -daemonize
+)
+
+{
+ numactl "${numactl[@]}" -- qemu-system-"${system}" "${args[@]}"
+
+ if [[ ${vcpu2cpulist+${#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:"@runstatedir@/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