#!/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/. 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 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"