loggingqemu

Redirect Qemu console to a file or the host terminal?


Background:

My system is an x86-based kernel and ramfs-based root filesystem. I have made the ramfs-based on the cpio archive (which will use boot=/dev/ram0 as the RAM device), and I am having some issues with the init. The whole intention is to optimise the ramfs to the minimum to fit in a really small system. I am trying to debug the problem in the init. I start QEMU in Ubuntu 12.10 (Quantal Quetzal) using the command:

qemu-system-x86_64 -kernel linux-3.9.2/arch/x86/boot/bzImage -serial stdio \
    -append "root=/dev/ram0 console=tty1"

And as expected the system goes to OOPS.

Question:

I would like to see the logs to investigate the reason for the crash, but I cannot navigate in the QEMU console using the Shift key and Page Up/Page Down. So I tried redirecting the output to the host terminal using curses by the command:

qemu-system-x86_64 -kernel linux-3.9.2/arch/x86/boot/bzImage -serial stdio \
    -append "root=/dev/ram0 console=tty1" -curses

But here again I am unable to navigate and find the problem.

P.S. If my system boots fine (using the correct rootfs) then I am able to navigate and see the messages.

How do I redirect the messages to the terminal or to a file?


Solution

  • Add the below command: console=ttyAMA0 console=ttyS0

    qemu-system-x86_64 -kernel linux-3.9.2/arch/x86/boot/bzImage -serial stdio \
        -append "root=/dev/ram0 console=ttyAMA0 console=ttyS0"
    

    Now all dmesg logs will be redirected to your console.

    One more thing: I observed from above command, where is your initial RAM disk? i.e - -initrd (initrdimage)

    To boot the system you need two images, 1) zImage or bZimage (in case of x86) 2) rootfs -root file system

    The missing component is rootfs in your case.