Setup QEMU Output to Serial Console and Automate Tests with Shell Scripts (2019)

https://news.ycombinator.com/rss Hits: 2
Summary

How to Setup QEMU Output to Console and Automate Using Shell Script SSH. Expect. Named pipes. Input/output to the host terminal. Early boot messages. Safe SkiesJoin Timothy Snyder鈥檚 fundraiser! 馃憞 Safe SkiesJoin Timothy Snyder鈥檚 fundraiser! The history professor is raising funds towards a situational alert system for Ukraine鈥檚 Air Defence Forces. Protect Ukrainian towns from terrorist attacks.Preface While struggling to automate QEMU guest (communicate and control with the shell scripts), I faced a lot of incomplete, partially working solutions around the Internet. Now, I've got a pretty decent collection of working recipes to tune up a QEMU guest, so I decided to organize all that stuff here, and it could be definitely useful for anyone else. Each scenario has been tested on the binaries, links on which I put below in the annex: Binaries used in the examples, so you could check it out on your own. Contents Input/output to the host terminal Early boot messages in the host terminal Input/output through a named pipe (file) Automate QEMU guest using expect tool Automate QEMU guest using ssh Binaries used in examples 1. Input/output to the host terminal -serial stdio qemu-system-x86_64 -serial stdio wheezy.qcow2 -serial stdio redirects the virtual serial port to the host's terminal input/output. You will see a welcome string after a successful boot. -nographic qemu-system-x86_64 -nographic wheezy.qcow2 -nographic does the same as "-serial stdio" and also hides a QEMU's graphical window. Cautions: You will not see any early boot logs in the host's console. To get them, see Early boot messages in the host terminal below. To exit the guest system without GUI, using stdio redirected to the terminal, login as a root (user: root, password: root) and shutdown the system (wait after that for a while):# Guest shutdown -h now 2. Early boot messages in the host terminal console=ttyS0 If you want to see early boot logs, you should pass console=ttyS0 parameter to a Linux kernel comma...

First seen: 2025-04-05 23:11

Last seen: 2025-04-06 00:11