summaryrefslogtreecommitdiffstats
path: root/tools/guest-diag/pin_gr_stream.py
diff options
context:
space:
mode:
Diffstat (limited to 'tools/guest-diag/pin_gr_stream.py')
-rw-r--r--tools/guest-diag/pin_gr_stream.py36
1 files changed, 22 insertions, 14 deletions
diff --git a/tools/guest-diag/pin_gr_stream.py b/tools/guest-diag/pin_gr_stream.py
index d8b6b61..7f8e4b8 100644
--- a/tools/guest-diag/pin_gr_stream.py
+++ b/tools/guest-diag/pin_gr_stream.py
@@ -58,6 +58,8 @@ def _start_cmd():
with open(GUEST_SCRIPT) as f:
b64 = subprocess.run(["base64", "-w0"], stdin=f,
capture_output=True, text=True).stdout
+ prefixes = os.environ.get("CLIENT_PREFIXES", "cdt,va,victory")
+ vma_every = os.environ.get("STREAM_VMA_EVERY", "1")
return ("echo '%s' | base64 -d > /tmp/guest_pin_stream.py; "
"if [ -f /tmp/guest_pin_stream.pid ]; then "
"p=$(cat /tmp/guest_pin_stream.pid 2>/dev/null); "
@@ -65,10 +67,12 @@ def _start_cmd():
"/proc/$p/cmdline 2>/dev/null && sudo kill $p 2>/dev/null; "
"fi; "
"sudo rm -f /tmp/guest_pin_stream.pid; "
- "sudo setsid nohup python3 /tmp/guest_pin_stream.py %d %d %s %s %s "
+ "sudo setsid nohup env CLIENT_PREFIXES='%s' "
+ "STREAM_VMA_EVERY='%s' "
+ "python3 /tmp/guest_pin_stream.py %d %d %s %s %s "
">/tmp/guest_pin_stream.log 2>&1 & sleep 2; "
"sudo cat /tmp/guest_pin_stream.pid 2>/dev/null"
- % (b64, 2, PORT, LO, HI, PAMAX))
+ % (b64, prefixes, vma_every, 2, PORT, LO, HI, PAMAX))
def install_and_start():
@@ -189,18 +193,22 @@ def _flush(runs, seen):
"echo 'FAIL 0x%x 0x%x 0x%x'"
% (va, pa, n * 0x1000, PARAM, va, pa, n * 0x1000))
failed = set()
- try:
- r = subprocess.run(["sudo", "-n", "sh", "-c", "\n".join(script)],
- capture_output=True, text=True, timeout=60)
- for line in r.stdout.splitlines():
- m = re.match(r"FAIL (0x[0-9a-f]+) (0x[0-9a-f]+) (0x[0-9a-f]+)",
- line.strip())
- if m:
- failed.add((int(m.group(1), 16), int(m.group(2), 16),
- int(m.group(3), 16) // 0x1000))
- except Exception as e:
- log("batch inject failed: %s" % e)
- failed = set(todo)
+ CHUNK = 200
+ for start in range(0, len(script), CHUNK):
+ batch = script[start:start + CHUNK]
+ try:
+ r = subprocess.run(["sudo", "-n", "sh", "-c", "\n".join(batch)],
+ capture_output=True, text=True, timeout=60)
+ for line in r.stdout.splitlines():
+ m = re.match(r"FAIL (0x[0-9a-f]+) (0x[0-9a-f]+) (0x[0-9a-f]+)",
+ line.strip())
+ if m:
+ failed.add((int(m.group(1), 16), int(m.group(2), 16),
+ int(m.group(3), 16) // 0x1000))
+ except Exception as e:
+ log("batch inject failed: %s" % e)
+ for va, pa, n in todo[start:start + CHUNK]:
+ failed.add((va, pa, n))
pages = 0
for va, pa, n in todo: