summaryrefslogtreecommitdiffstats
path: root/userspace/cuda/570.144/scripts/fetch_from_guest.sh
diff options
context:
space:
mode:
authorArthur Hanson Rasmusson <arthur@vgpu.io>2026-09-23 07:05:45 -0400
committerArthur Hanson Rasmusson <arthur@vgpu.io>2026-09-23 07:05:45 -0400
commit54ca82d81bacb56197a607d0039ca6a015f5ac44 (patch)
tree355be543e9da05468c5c0003ff7ddb60944221ec /userspace/cuda/570.144/scripts/fetch_from_guest.sh
parent893318f45eff1a2b5f4d554297d08a9e987c2a52 (diff)
downloadopen-iov-54ca82d81bacb56197a607d0039ca6a015f5ac44.tar.gz
open-iov-54ca82d81bacb56197a607d0039ca6a015f5ac44.zip
userspace/cuda: libcuda analysis tree (debug-focused), guest ioctl tracer
Analysis tooling for debugging CUDA execution in Open-IOV guests: - userspace/cuda/570.144/: fetch a library from a running guest (nc), objdump helpers, crash ip -> file vaddr + symbol mapping, and Ghidra headless import/analysis/decompile scripts (project kept so single functions decompile in seconds). The purpose is debugging correctness and performance of CUDA in Open-IOV VMs (not a reimplementation); extracted binaries and decompiled output are gitignored. - tools/guest-diag/ioctl_trace.c: ptrace tracker for the NVIDIA driver ioctls of a child (libcuda issues raw syscalls, so LD_PRELOAD sees nothing). Decodes RM_ALLOC (class) and RM_CONTROL (cmd) arguments; this is how the cuCtxCreate crash sequence was captured. - tools/test/cuda_drv_test.c: unbuffered + per-call markers so a crash identifies the CUDA call it happened in.
Diffstat (limited to 'userspace/cuda/570.144/scripts/fetch_from_guest.sh')
-rwxr-xr-xuserspace/cuda/570.144/scripts/fetch_from_guest.sh57
1 files changed, 57 insertions, 0 deletions
diff --git a/userspace/cuda/570.144/scripts/fetch_from_guest.sh b/userspace/cuda/570.144/scripts/fetch_from_guest.sh
new file mode 100755
index 0000000..6ed24f1
--- /dev/null
+++ b/userspace/cuda/570.144/scripts/fetch_from_guest.sh
@@ -0,0 +1,57 @@
+#!/bin/bash
+# SPDX-License-Identifier: BSD-3-Clause
+#
+# fetch_from_guest.sh - copy a file out of a running Open-IOV guest.
+#
+# The guest agent is used to start a netcat transfer from the guest to the
+# host (QEMU user networking: the host is 10.0.2.2), which is much faster and
+# more robust than pushing tens of megabytes through the agent in base64
+# chunks.
+#
+# Usage: scripts/fetch_from_guest.sh <guest-path> [guest-bind-ip]
+# e.g. scripts/fetch_from_guest.sh \
+# /usr/lib/x86_64-linux-gnu/libcuda.so.570.144
+set -e
+
+HERE="$(cd "$(dirname "$0")" && pwd)"
+RUN="$(cd "$HERE/.." && pwd)/run"
+VMEXEC="$HERE/../../../scripts/vgpu_vm.py"
+PORT="${PORT:-47311}"
+
+GUEST_PATH="${1:?usage: $0 <guest-path> [guest-bind-ip]}"
+HOST_IP="${2:-10.0.2.2}"
+OUT="$RUN/$(basename "$GUEST_PATH")"
+
+mkdir -p "$RUN"
+
+# Guest-side md5 for verification
+GUEST_MD5=$("$VMEXEC" exec "md5sum '$GUEST_PATH'" 2>/dev/null | awk '{print $1}')
+[ -n "$GUEST_MD5" ] || { echo "cannot stat $GUEST_PATH in guest"; exit 1; }
+
+echo "[*] guest md5: $GUEST_MD5"
+echo "[*] listening on :$PORT -> $OUT"
+rm -f "$OUT"
+
+nc -l "$PORT" > "$OUT" &
+NCPID=$!
+sleep 1
+
+"$VMEXEC" exec "setsid sh -c 'nc $HOST_IP $PORT < $GUEST_PATH' >/dev/null 2>&1 &" >/dev/null 2>&1 || true
+
+# Wait for the transfer to settle (size stable for two checks)
+prev=0
+for _ in $(seq 1 60); do
+ sleep 2
+ cur=$(stat -c%s "$OUT" 2>/dev/null || echo 0)
+ [ "$cur" -gt 0 ] && [ "$cur" = "$prev" ] && break
+ prev=$cur
+done
+wait $NCPID 2>/dev/null || true
+
+HOST_MD5=$(md5sum "$OUT" | awk '{print $1}')
+echo "[*] host md5: $HOST_MD5"
+if [ "$GUEST_MD5" != "$HOST_MD5" ]; then
+ echo "[FAIL] md5 mismatch"
+ exit 1
+fi
+echo "[ok] $OUT ($(stat -c%s "$OUT") bytes)"