4

I'm doing get simple trace file from QEMU. I followed instructions docs/tracing.txt

with this command "qemu-system-x86_64 -m 2G -trace events=/tmp/events ../qemu/test.img"

i'd like to get just simple trace file. i've got trace-pid file, however, it dosen't have anything in it.

  1. Build with the 'simple' trace backend:

    ./configure --enable-trace-backends=simple make

  2. Create a file with the events you want to trace:

    echo bdrv_aio_readv > /tmp/events echo bdrv_aio_writev >> /tmp/events

  3. Run the virtual machine to produce a trace file:

    qemu -trace events=/tmp/events ... # your normal QEMU invocation

  4. Pretty-print the binary trace file:

    ./scripts/simpletrace.py trace-events trace-* # Override * with QEMU

i followd this instructions. please somebody give me some advise for this situation.

THANKS!

youngsun
  • 63
  • 7

2 Answers2

0

I got same problem by following the same document. https://fossies.org/linux/qemu/docs/tracing.txt got nothing because bdrv_aio_readv and bdrv_aio_writev was not enabled by default, at least the version I complied, was not enabled. you need to open trace-events under source directory, looking for some line without disabled, e.g. I using: echo "load_file" > /tmp/events Then start qemu, after a guest started, I run ./scripts/simpletrace.py trace-events trace-Pid I got

load_file 1474.156 pid=5249 name=kvmvapic.bin path=qemu-2.8.0-rc0/pc-bios/kvmvapic.bin
load_file 22437.571 pid=5249 name=vgabios-stdvga.bin path=qemu-2.8.0-rc0/pc-bios/vgabios-stdvga.bin
load_file 10034.465 pid=5249 name=efi-e1000.rom 

you can also add -monitor stdio to qemu command line, after it started, you can the following command in qemu CLI:

(qemu) info trace-events

load_file : state 1
vm_state_notify : state 1
balloon_event : state 0
cpu_out : state 0
cpu_in : state 0

1 means enabled events.

0

Modify the trace-events file in the source tree

As of v2.9.0 you also have to remove the disable from the lines you want to enable there, e.g.:

-disable exec_tb(void *tb, uintptr_t pc) "tb:%p pc=0x%"PRIxPTR
+exec_tb(void *tb, uintptr_t pc) "tb:%p pc=0x%"PRIxPTR

and recompile.

Here is a minimal fully automated runnable example that boots Linux and produces traces: https://github.com/cirosantilli/linux-kernel-module-cheat

For example, I used the traces to count how many boot instructions Linux has: https://github.com/cirosantilli/linux-kernel-module-cheat/blob/c7bbc6029af7f4fab0a23a380d1607df0b2a3701/count-boot-instructions.md

I have a lightly patched QEMU as a submodule, the key commit is: https://github.com/cirosantilli/qemu/commit/e583d175e4cdfb12b4812a259e45c679743b32ad

Ciro Santilli OurBigBook.com
  • 347,512
  • 102
  • 1,199
  • 985