[OpenBIOS] Grand Unified Tracing

Stefan Hajnoczi stefanha at gmail.com
Mon Aug 22 22:23:14 CEST 2011

On Mon, Aug 22, 2011 at 7:14 PM, Blue Swirl <blauwirbel at gmail.com> wrote:
> OpenBIOS uses traditional DPRINTFs for debugging. I was considering
> replacing those with tracepoints, which would output to serial device
> or whatever DPRINTFs are using currently. This would not be extremely
> useful by itself, except maybe that configuration for debugging would
> be concentrated to single 'trace-events' file, but this would not be a
> major improvement over current XML configuration.
> But developing this further, maybe OpenBIOS could also pass the
> tracepoint data back to QEMU? Then all tracepoint data would be
> synchronized, coherent and all gathered to single place.
> The implementation could be that fw_cfg would be used to pass
> simpletrace style data. An offset should be added to event IDs and
> data would then be output as usual. On OpenBIOS side, the
> implementation would be pretty similar to current QEMU tracepoints but
> in place of file output there would be fw_cfg output.
> Syntax for trace-events file should be augmented with include
> directive, so that QEMU knows also OpenBIOS tracepoints. I think the
> only change to simpletrace.py would be to parse this directive.
> Controlling OpenBIOS tracepoints from QEMU monitor would be cool too.
> Going even further, other targets like kernels could use something
> similar, probably not using fw_cfg though.
> What do you think?

Dhaval showed me a demo of unified host/guest Linux tracing last week.
 He is doing something similar except using a hypercall to pass a
string to the host kernel.  In his case kvm.ko handles the hypercall
and qemu is not involved.

One issue with QEMU tracing is that trace call sites are static.  You
need to compile in a trace_*() call, which means that there are two
choices for how to tunnel OpenBIOS trace events:

1. Define a tunnel trace event:
openbios_event(uint64_t event_id, uint64_t arg1, uint64_t arg2, ...)

QEMU only has one trace event to tunnel OpenBIOS trace events.  Then
the host is unable to pretty-print OpenBIOS traces automatically and
the max arguments becomes 6 - 1 (for the openbios_event tunnel event

2. Generate a switch statement to demultiplex trace events:
void hypercall(uint64_t event_id, uint64_t arg1, ...)
    /* This is auto-generated by tracetool */
    switch (event_id) {
        trace_openbios_foo(arg1, arg2, arg3);

With this approach the user can toggle trace events at runtime and it
works out much nicer.

Remember that QEMU tracing also supports DTrace (SystemTap) and LTTng
Userspace Tracer.  Simpletrace would be the interface between the
guest and the host for passing trace records.  In Dhaval's case we
were talking about passing binary Linux tracing events to the host and
quickly realized there are host/guest ABI compatibility issues to
consider.  For OpenBIOS debugging you may be able to get away with
demanding that the OpenBIOS is built for this particular QEMU binary
though :).


More information about the OpenBIOS mailing list