Skip to content

Instantly share code, notes, and snippets.

@a3f
Created May 17, 2026 20:01
Show Gist options
  • Select an option

  • Save a3f/898bfa892daa21ac0380334f34f64781 to your computer and use it in GitHub Desktop.

Select an option

Save a3f/898bfa892daa21ac0380334f34f64781 to your computer and use it in GitHub Desktop.
Start QEMU interactively from a labgrid env YAML
#!/usr/bin/env python3
"""Start QEMU interactively from a labgrid env YAML
Usage:
qemu-interactive.py <env.yaml> [extra qemu args]
"""
import subprocess
import sys
from labgrid import Environment
qemu = Environment(config_file=sys.argv[1]).get_target("main").get_driver("QEMUDriver")
cmd = qemu.get_qemu_base_args() + sys.argv[2:]
cmd += ["-serial", "mon:stdio", "-trace", "file=/dev/null"]
cmd += sys.argv[2:]
with open("/dev/tty", "r+b", buffering=0) as tty:
sys.exit(subprocess.run(cmd, stdin=tty, stdout=tty, stderr=tty).returncode)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment