Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Redirect Qemu console to a file or the host terminal?

Tags:

logging

qemu

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?

like image 368
Prajosh Premdas Avatar asked Aug 07 '13 08:08

Prajosh Premdas


People also ask

How do I connect to QEMU console?

You can access the monitor console from QEMU window either by a keyboard shortcut—press Ctrl–Alt–2 (to return to QEMU, press Ctrl–Alt–1)—or alternatively by clicking View in the QEMU GUI window, then compatmonitor0. The most convenient way is to show the QEMU window tabs with View › Show Tabs.

What is QEMU console?

Qemu is a machine emulator that can run operating systems and programs for one machine on a different machine. Mostly it is not used as emulator but as virtualizer in collaboration with KVM kernel components. In that case it utilizes the virtualization technology of the hardware to virtualize guests.

How do I run QEMU monitor?

The monitor is accessed from within QEMU by holding down the Ctrl and Alt keys (or whatever the "mouse grab" keystrokes are), and pressing Ctrl-Alt-2 . Once in the monitor, Ctrl-Alt-1 switches back to the guest OS. Typing help or ? in the monitor brings up a list of all commands.


1 Answers

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.

like image 162
vinay hunachyal Avatar answered Nov 15 '22 06:11

vinay hunachyal