I would like to be able to both interact with the system via the command line, but also get the output to a file at the same time.

If I do:

qemu-sysem-x86_64 -serial stdio |& tee file

then it mostly works, but I would like to avoid any Bash operations and let QEMU do the heavy lifting for me. For example, I'm using Python, and it is not so simple to implement a reliable tee there.

If I do:

qemu-sysem-x86_64 -serial file:myfile

It redirects to the file and I can't give any input.

Is there a way to "combine" both file: and stdio to a single -serial?

Multiple -serial entries just create multiple serial ports instead of modifying a single one.

I'm also interested if it works with telnet as in:

-serial tcp::1234,server,nowait



Recently, I ran into the exactly same problem and found a solution:

According to QEMU 3.1.0 documentation, you can use a chardev with options stdio and logfile and redirect your serial into it.

qemu-system-x86_64 -chardev stdio,id=char0,logfile=serial.log,signal=off \
  -serial chardev:char0

Moreover, if you use mux=on option within chardev, you can redirect a monitor (mon), another serial or other interfaces supporting chardev backend into it simultaneously:

qemu-system-x86_64 -chardev stdio,id=char0,mux=on,logfile=serial.log,signal=off \
  -serial chardev:char0 -mon chardev=char0

See the example in the doc. link above.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.