blob: 4064d5812f5ac2564c00684987df996c841e48da (
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
|
#!/bin/bash
# SPDX-License-Identifier: BSD-3-Clause
# Copyright (c) 2026 Open-IOV contributors
# push_gl_tools.sh - push the guest-side GL/GZDoom harness binaries and scripts
# into the running guest's /tmp and chmod +x them. Uses the established QGA
# guest-exec + base64 mechanism from push_guest_tools.sh (scripts/vgpu_vm.py).
#
# Usage:
# bash tools/guest-diag/push_gl_tools.sh # fixed list below
# bash tools/guest-diag/push_gl_tools.sh FILE... # arbitrary host files
# bash tools/guest-diag/push_gl_tools.sh --dry-run # list only, no push
#
# Destination is /tmp/<basename>. The guest's /tmp is wiped on boot; run this
# after every VM start. It does NOT run the pushed programs.
set -u
HERE="$(cd "$(dirname "$0")" && pwd)"
VMEXEC="$HERE/../../scripts/vgpu_vm.py"
BUILD="$HERE/build"
DEST_DIR="${DEST_DIR:-/tmp}"
DRY_RUN=0
if [ "${1:-}" = "--dry-run" ]; then
DRY_RUN=1
shift
fi
FIXED=(
"$BUILD/gl_frames"
"$BUILD/gz_pbuf.so"
"$BUILD/sdl_cap.so"
"$BUILD/test_tri"
"$HERE/guest_mode.sh"
"$HERE/gzf2_video.py"
"$HERE/gzdoom_pbuf_run.sh"
)
if [ "$#" -gt 0 ]; then
FILES=("$@")
else
FILES=("${FIXED[@]}")
fi
if [ ! -x "$VMEXEC" ] && [ ! -f "$VMEXEC" ]; then
echo "push_gl_tools: vgpu_vm.py not found: $VMEXEC" >&2
exit 2
fi
push_b64() { # push_b64 <local file> <remote file>
local src="$1" dst="$2" b64
b64=$(base64 -w0 "$src")
if [ "$DRY_RUN" = "1" ]; then
echo "PUSH-DRY $src -> $dst ($(stat -c%s "$src") bytes)"
return 0
fi
if ! sudo "$VMEXEC" exec --timeout 120 \
"echo '$b64' | base64 -d > '$dst' && chmod +x '$dst'" \
>/dev/null 2>&1; then
echo "PUSH-FAIL $src -> $dst" >&2
return 1
fi
echo "PUSHED $src -> $dst"
}
rc=0
for f in "${FILES[@]}"; do
if [ ! -f "$f" ]; then
echo "PUSH-SKIP missing $f" >&2
rc=1
continue
fi
push_b64 "$f" "$DEST_DIR/$(basename "$f")" || rc=1
done
exit "$rc"
|