Qemu: redirect serial port data to stdio or a file, read it in text editor

redirect serial port data to stdio
# qemu-system-i386 -m 64 -serial stdio -hda ./harddisk.img

redirect serial port data to a file
# qemu-system-i386 -m 64 -serial file:a.txt -hda ./harddisk.img

redirect serial port data to a file (another way)
# qemu-system-i386 -m 64 -serial stdio -hda ./harddisk.img | tee a.txt

Now, a.txt can't be opened in a text editor.
Because it contains 0x00 (NULL character) in place of '\n' (new line character).

So use the following command:
# cat a.txt | xargs -0 echo > b.txt

Now b.txt is an ascii file, and can be read by text editors.

No comments: