summaryrefslogtreecommitdiffstats
path: root/tools/guest-diag/vmcycle.sh
diff options
context:
space:
mode:
authorArthur Hanson Rasmusson <arthur@vgpu.io>2026-09-23 00:51:55 -0400
committerArthur Hanson Rasmusson <arthur@vgpu.io>2026-09-23 00:51:55 -0400
commit7897fe79ba6a00cc59b7a357903ecfc70480ce97 (patch)
tree394a47a5d22b2d6072e19c92e9ced1e667817788 /tools/guest-diag/vmcycle.sh
parent7aef82a5112ee72ee2fc5a430db072085933e927 (diff)
downloadopen-iov-7897fe79ba6a00cc59b7a357903ecfc70480ce97.tar.gz
open-iov-7897fe79ba6a00cc59b7a357903ecfc70480ce97.zip
tools: add guest-diag (ptrace ioctl tracer, vmcycle, root-port QEMU cmdline)
The ptrace tracer resolves the current CUDA blocker: libcuda issues raw syscall instructions, so LD_PRELOAD shims and ltrace see nothing; following the child with PTRACE_SYSCALL + PTRACE_GET_SYSCALL_INFO does. It found UVM_REGISTER_GPU (ioctl 0x25) returning rmStatus=0x56 NV_ERR_NOT_SUPPORTED, with inputs identical to the working host run (rmCtrlFd=-1, hClient=0, hSmcPartRef=0). Also dumps NV_ESC_RM_CONTROL cmd/status and RM alloc/free statuses (all zero) and the UVM ioctl set (guest stops after 0x27,0x1,0x25,0x2 vs 141 ioctls on the host). launch_qemu_rootport.sh is the working QEMU command line with the pcie-root-port fix (see its header + the handoff PART 4); vmcycle.sh drives the module/mdev/VM reload cycle around it.
Diffstat (limited to 'tools/guest-diag/vmcycle.sh')
-rwxr-xr-xtools/guest-diag/vmcycle.sh36
1 files changed, 36 insertions, 0 deletions
diff --git a/tools/guest-diag/vmcycle.sh b/tools/guest-diag/vmcycle.sh
new file mode 100755
index 0000000..08eb4ea
--- /dev/null
+++ b/tools/guest-diag/vmcycle.sh
@@ -0,0 +1,36 @@
+#!/bin/bash
+# vmcycle.sh - reload cycle for the emulated vGPU stack:
+# stop QEMU -> remove mdevs -> rmmod/insmod open-iov-vfio.ko -> create a
+# fresh mdev -> patch its UUID into the QEMU launch script -> relaunch.
+#
+# Usage: tools/guest-diag/vmcycle.sh
+# Env: QEMU_SCRIPT (default: ./launch_qemu_rootport.sh next to this script)
+# MDEV_PARENT (default: 0000:01:00.0)
+# MDEV_TYPE (default: nvidia-nvidia-vgpu-turing)
+set -e
+
+HERE="$(cd "$(dirname "$0")" && pwd)"
+QEMU_SCRIPT="${QEMU_SCRIPT:-$HERE/launch_qemu_rootport.sh}"
+MODULE="${MODULE:-$HERE/../../kernel/open-iov-vfio.ko}"
+MDEV_PARENT="${MDEV_PARENT:-0000:01:00.0}"
+MDEV_TYPE="${MDEV_TYPE:-nvidia-nvidia-vgpu-turing}"
+
+pkill -f qemu-system-x86_64 2>/dev/null || true
+sleep 4
+for m in /sys/bus/mdev/devices/*; do
+ [ -d "$m" ] && echo 1 | sudo tee "$m/remove" >/dev/null
+done
+sudo rmmod open_iov_vfio 2>/dev/null || true
+sudo insmod "$MODULE"
+U=$(uuidgen)
+echo "$U" | sudo tee "/sys/class/mdev_bus/$MDEV_PARENT/mdev_supported_types/$MDEV_TYPE/create" >/dev/null
+sed -i "s|/sys/bus/mdev/devices/[0-9a-f-]*|/sys/bus/mdev/devices/$U|" "$QEMU_SCRIPT"
+mkdir -p /tmp/sockets/e726ba0b-204f-4ec9-91da-983ed7f41d06
+rm -f /tmp/qemu-guest-agent.sock /tmp/qemu-qmp.sock
+(setsid nohup "$QEMU_SCRIPT" > /tmp/opencode-qemu.log 2>&1 &)
+sleep 6
+if pgrep -f qemu-system-x86_64 >/dev/null; then
+ echo "VM up (mdev $U)"
+else
+ echo "VM FAILED"; tail -3 /tmp/opencode-qemu.log; exit 1
+fi