summaryrefslogtreecommitdiffstats
path: root/tools/guest-diag/push_guest_tools.sh
blob: 607cce41dcf90d10fa90ba69eb75cc54c2316b7f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#!/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 file> <remote file>
    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

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"