summaryrefslogtreecommitdiffstats
path: root/tools/guest-diag/pmap_va.sh
blob: e5bcef48487916d21afb9b92659035975396a5be (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#!/bin/bash
# pmap_va.sh <pid|name> <hex-va> [hex-va ...]
# Push guest_pmap.py to the running VM and translate the VAs of the named
# process through the guest's own pagemap (root in the guest).
set -u
cd "$(dirname "$0")/../.."

TARGET="$1"; shift
VAS="$*"

B64=$(base64 -w0 tools/guest-diag/guest_pmap.py)
timeout 30 ./scripts/vgpu_vm.py exec --timeout 25 \
    "echo '$B64' | base64 -d > /tmp/pmap.py" >/dev/null 2>&1

if ! [[ "$TARGET" =~ ^[0-9]+$ ]]; then
    PID=$(timeout 20 ./scripts/vgpu_vm.py exec --timeout 15 "pgrep -x $TARGET | head -1" 2>/dev/null | tail -1)
    [ -n "$PID" ] && TARGET="$PID"
fi
[ -n "$TARGET" ] || { echo "no pid found"; exit 1; }

timeout 60 ./scripts/vgpu_vm.py exec --timeout 55 "sudo python3 /tmp/pmap.py $TARGET $VAS" 2>/dev/null | grep -E '^VA='