#!/bin/bash # push_guest_tools.sh - (re)build the guest-side diagnostic binaries from the # sources kept in this directory. The guest's /tmp is wiped on boot, so run # this after every VM start; the sources here are the persistent copies. # # Usage: tools/guest-diag/push_guest_tools.sh # (env: VM="vgpu-linux" is not needed; scripts/vgpu_vm.py talks to the # running VM's guest agent socket) set -e HERE="$(cd "$(dirname "$0")" && pwd)" VMEXEC="$HERE/../../scripts/vgpu_vm.py" REPO="$HERE/../.." push_b64() { # push_b64 local b64 b64=$(base64 -w0 "$1") "$VMEXEC" exec "echo '$b64' | base64 -d > '$2'" >/dev/null 2>&1 } echo "[*] pushing sources..." push_b64 "$HERE/ptrace_ioctl.c" /tmp/ptio.c push_b64 "$HERE/guest_engines.c" /tmp/ge.c push_b64 "$HERE/rmq_probe.c" /tmp/rmqp.c push_b64 "$HERE/ioctl_trace.c" /tmp/iot.c push_b64 "$REPO/tools/test/cuda_drv_test.c" /tmp/cdt.c push_b64 "$HERE/dumpctx.py" /tmp/dumpctx.py push_b64 "$HERE/trkinfo.py" /tmp/trkinfo.py push_b64 "$HERE/bp999.py" /tmp/bp999.py push_b64 "$HERE/ctx999.py" /tmp/ctx999.py push_b64 "$HERE/scanerr.py" /tmp/scanerr.py push_b64 "$HERE/sem_counters.py" /tmp/sem_counters.py push_b64 "$HERE/sem_slots.py" /tmp/sem_slots.py push_b64 "$HERE/read_va.py" /tmp/read_va.py push_b64 "$HERE/guest_pmap.py" /tmp/guest_pmap.py push_b64 "$HERE/guest_pmap_win.py" /tmp/guest_pmap_win.py push_b64 "$HERE/guest_pin_stream.py" /tmp/guest_pin_stream.py push_b64 "$HERE/track_waits.sh" /tmp/track_waits.sh push_b64 "$HERE/guest_kprobes.sh" /tmp/kprobes.sh echo "[*] compiling in guest..." "$VMEXEC" exec "gcc -O1 -w -o /tmp/ptio /tmp/ptio.c && \ gcc -O1 -w -o /tmp/ge /tmp/ge.c && \ gcc -O1 -w -o /tmp/rmqp /tmp/rmqp.c && \ gcc -O1 -w -o /tmp/iot /tmp/iot.c && \ gcc -O1 -o /tmp/cdt /tmp/cdt.c -ldl && echo BUILD_OK"