summaryrefslogtreecommitdiffstats
path: root/tools/guest-diag/gl_verify.sh
diff options
context:
space:
mode:
Diffstat (limited to 'tools/guest-diag/gl_verify.sh')
-rw-r--r--tools/guest-diag/gl_verify.sh30
1 files changed, 30 insertions, 0 deletions
diff --git a/tools/guest-diag/gl_verify.sh b/tools/guest-diag/gl_verify.sh
new file mode 100644
index 0000000..edfaab2
--- /dev/null
+++ b/tools/guest-diag/gl_verify.sh
@@ -0,0 +1,30 @@
+#!/bin/bash
+# SPDX-License-Identifier: BSD-3-Clause
+# Copyright (c) 2026 Open-IOV contributors
+# gl_verify.sh - host-side: (re)start X in the running guest, verify xdpyinfo +
+# glxinfo -B + shared nvClip modeNum. Prints a compact summary.
+#
+# Usage: bash tools/guest-diag/gl_verify.sh [--no-restart]
+# --no-restart : check the current X without killing/restarting it.
+set -u
+
+HERE="$(cd "$(dirname "$0")" && pwd)"
+VMEXEC=(sudo python3 "$HERE/../../scripts/vgpu_vm.py")
+RESTART=1
+[ "${1:-}" = "--no-restart" ] && RESTART=0
+
+gx() { "${VMEXEC[@]}" exec --timeout "${1:-45}" "$2" 2>&1 | tail -n "${3:-40}"; }
+
+if [ "$RESTART" = "1" ]; then
+ # The DDX ScreenInit is a per-start lottery ("GPU exception"): retry up to 3x.
+ for try in 1 2 3; do
+ gx 30 "pkill -f '[X]org :0' 2>/dev/null; sleep 1; systemctl reset-failed xorg0 2>/dev/null; systemd-run --unit=xorg0 --collect --setenv=HOME=/root /usr/bin/Xorg :0 -config /etc/X11/xorg.conf >/dev/null 2>&1; echo XSTART-ISSUED" >/dev/null
+ sleep 8
+ ok=$(gx 20 "timeout 12 env DISPLAY=:0 xdpyinfo >/dev/null 2>&1 && echo XDPYINFO-OK || echo X-DEAD" 3 | tail -1)
+ echo "try $try: $ok"
+ [ "$ok" = "XDPYINFO-OK" ] && break
+ sleep 4
+ done
+fi
+
+gx 40 "pgrep -c Xorg || echo NO_XORG; timeout 15 env DISPLAY=:0 xdpyinfo >/dev/null 2>&1 && echo XDPYINFO-OK || echo X-HUNG; timeout 20 env DISPLAY=:0 glxinfo -B 2>&1 | grep -E 'direct rendering|OpenGL (renderer|version|core profile version)'; timeout 20 env DISPLAY=:0 glxinfo -B >/dev/null 2>&1 && echo GLXINFO-OK || echo GLX-HUNG; bash /tmp/guest_mode.sh 2>/dev/null || echo NO_MODENUM_SCRIPT" 60