summaryrefslogtreecommitdiffstats
path: root/scripts/launch_qemu_direct.sh
diff options
context:
space:
mode:
authorArthur Hanson Rasmusson <arthur@vgpu.io>2026-09-29 08:53:11 -0400
committerArthur Hanson Rasmusson <arthur@vgpu.io>2026-09-29 08:53:11 -0400
commit26fce4914011914bb1e2ee520fe62e790326877e (patch)
tree1151ba10251bbad9cd127abdf8a5ecf39b2d2947 /scripts/launch_qemu_direct.sh
parent64bcfd6fd72546a2758d664bea39354604babcda (diff)
downloadopen-iov-26fce4914011914bb1e2ee520fe62e790326877e.tar.gz
open-iov-26fce4914011914bb1e2ee520fe62e790326877e.zip
tools: durable guest counter enumeration/injection and VA reader
The counter enumeration/injection workflow lived in the guest's /tmp and was lost on every restart. Make it durable under tools/guest-diag: - sem_counters.py: translate a process's per-channel u32 completion counters (16-byte stride in the /dev/nvidiactl counter page) to guest PAs through /proc/<pid>/pagemap; --pairs emits handle,va,pa triples. - sem_slots.py: read/write the counter slots via /proc/<pid>/mem (fallback for the host counter publish). - read_va.py: hex dump a process VA (UVM sysmem GPU VAs are usually valid CPU VAs in the owning process); --u32 for method streams. - inject_counters.sh: host-side one-shot: push the tool, take the GR handles from the live chan_dump, enumerate, then register each counter with sema_counter and pin its VA with sema_map_add. - push_guest_tools.sh: push the new tools after every VM start. - launch_qemu_direct.sh: parameterized mdev UUID/paths instead of a stale hardcoded one; committed so it survives checkouts.
Diffstat (limited to 'scripts/launch_qemu_direct.sh')
-rwxr-xr-xscripts/launch_qemu_direct.sh55
1 files changed, 55 insertions, 0 deletions
diff --git a/scripts/launch_qemu_direct.sh b/scripts/launch_qemu_direct.sh
new file mode 100755
index 0000000..25e628c
--- /dev/null
+++ b/scripts/launch_qemu_direct.sh
@@ -0,0 +1,55 @@
+#!/bin/bash
+# launch_qemu_direct.sh - launch the vGPU VM without , with a serial
+# socket, QMP socket and guest agent socket that tools/guest-diag scripts
+# expect. The mdev UUID is taken from $1 or MDEV_UUID, else the first
+# existing /sys/bus/mdev/devices entry.
+#
+# Usage: sudo scripts/launch_qemu_direct.sh [mdev-uuid]
+set -euo pipefail
+
+MDEV_UUID="${1:-${MDEV_UUID:-}}"
+if [ -z "$MDEV_UUID" ]; then
+ MDEV_UUID=$(ls /sys/bus/mdev/devices/ 2>/dev/null | head -1)
+fi
+if [ -z "$MDEV_UUID" ]; then
+ echo "ERROR: no mdev device (create one first)" >&2
+ exit 1
+fi
+MDEV_PATH="/sys/bus/mdev/devices/${MDEV_UUID}"
+DISK="${DISK:-/home/rmcore/.local/libvf.io/kernel/linux.qcow2}"
+SERIAL_SOCK="${SERIAL_SOCK:-/tmp/qemu-serial.sock}"
+QMP_SOCK="${QMP_SOCK:-/tmp/qemu-qmp-direct.sock}"
+GUEST_AGENT_SOCK="${GUEST_AGENT_SOCK:-/tmp/qemu-guest-agent-direct.sock}"
+
+rm -f "$SERIAL_SOCK" "$QMP_SOCK" "$GUEST_AGENT_SOCK"
+
+exec qemu-system-x86_64 \
+ -no-hpet \
+ -mem-prealloc \
+ -qmp "unix:${QMP_SOCK},server,nowait" \
+ -chardev "socket,path=${GUEST_AGENT_SOCK},server=on,wait=off,id=qga0" \
+ -device virtio-serial-pci \
+ -device virtserialport,chardev=qga0,name=org.qemu.guest_agent.0 \
+ -serial "unix:${SERIAL_SOCK},server,nowait" \
+ -gdb tcp::1234 \
+ -nographic \
+ -vga none \
+ -device ivshmem-plain,id=shmem0,memdev=ivshmem_kvmfr \
+ -object memory-backend-file,id=ivshmem_kvmfr,mem-path=/dev/shm/kvmfr-direct,size=128M,share=yes \
+ -device ivshmem-plain,id=shmem1,memdev=ivshmem_kvmsr \
+ -object memory-backend-file,id=ivshmem_kvmsr,mem-path=/dev/shm/kvmsr-direct,size=2M,share=yes \
+ -uuid 90288662-2b76-49a4-83a5-7eb1e8ec22ed \
+ -machine pc-q35-4.2,accel=kvm,usb=off,vmport=off,dump-guest-core=off \
+ -cpu host,ss=on,vmx=on,pcid=on,hypervisor=on,arat=on,tsc-adjust=on,umip=on,md-clear=on,stibp=on,arch-capabilities=on,ssbd=on,xsaveopt=on,pdpe1gb=on,ibpb=on,amd-stibp=on,amd-ssbd=on,skip-l1dfl-vmentry=on,pschange-mc-no=on,hv-vapic,hv-time,hv-spinlocks=0x1fff,hv-vendor-id=null,kvm=on,topoext=on \
+ -rtc clock=host,base=localtime \
+ -m "${RAM:-4096}" \
+ -smp cores=4,threads=1,sockets=1 \
+ -hda "${DISK}" \
+ --enable-kvm \
+ -device vfio-pci,sysfsdev="${MDEV_PATH}",display=off \
+ -device rtl8139,netdev=net0 \
+ -netdev user,id=net0,hostfwd=tcp::2222-:22 \
+ -net user \
+ -net nic \
+ -device vhost-vsock-pci,guest-cid="${VSOCK_CID:-97844}" \
+ -display none