DF-5297 / moncmd.py
#!/usr/bin/env python3 # moncmd.py - send commands to the QEMU monitor, print results (short ops only) import socket, sys, time def run(cmds, wait=1.0): s = socket.socket(socket.AF_UNIX) s.connect("boot-mon.sock") time.sleep(0.3); s.recv(65536) for c in cmds: s.sendall((c + "\n").encode()); time.sleep(wait) s.setblocking(False); out = b"" try: while True: out += s.recv(65536) except Exception: pass s.setblocking(True) txt = out.decode(errors="replace").replace("\x1b[K", "").replace("\x1b[D", "").replace("\r", "") print(">>", c, "::", txt[-220:].strip()[-180:], flush=True) s.close() if __name__ == "__main__": run(sys.argv[1:]) |