summaryrefslogtreecommitdiffstats
path: root/tools/guest-diag/inject_counters.sh
diff options
context:
space:
mode:
Diffstat (limited to 'tools/guest-diag/inject_counters.sh')
-rwxr-xr-xtools/guest-diag/inject_counters.sh10
1 files changed, 9 insertions, 1 deletions
diff --git a/tools/guest-diag/inject_counters.sh b/tools/guest-diag/inject_counters.sh
index 8a56558..d1d004c 100755
--- a/tools/guest-diag/inject_counters.sh
+++ b/tools/guest-diag/inject_counters.sh
@@ -52,10 +52,18 @@ fi
b64=$(base64 -w0 "$HERE/sem_counters.py")
timeout 30 "$VMEXEC" exec "echo '$b64' | base64 -d > /tmp/sem_counters.py" >/dev/null
+# Only consider chan_dump lines produced after this script's own trigger:
+# dmesg keeps the previous client's dump lines (and handles) forever, and the
+# ring buffer wraps so a line-count baseline is not a stable cursor. Write a
+# unique marker to /dev/kmsg before each dump and parse only lines after it.
+DMESG_MARK="sema-inject-marker-$$-$(date +%s)"
+
all_grs() {
+ echo "$DMESG_MARK" | sudo tee /dev/kmsg >/dev/null
echo 1 | sudo tee "$PARAM/chan_dump" >/dev/null
sleep 1
- sudo dmesg | grep -o 'sema-chan-dump: h=0x[0-9a-f]* eng=0' \
+ sudo dmesg | awk -v m="$DMESG_MARK" 'index($0, m) { f = 1; next } f' \
+ | grep -o 'sema-chan-dump: h=0x[0-9a-f]* eng=0' \
| grep -o '0x[0-9a-f]*' | sort -u | paste -sd, || true
}