« Previous | Next » 

Revision 59da6684


Added by Stefan Hajnoczi about 10 years ago

simpletrace: Make simpletrace.py a Python module

The simpletrace.py script pretty-prints a binary trace file. Most of
the code can be reused by trace file analysis scripts, so turn it into a

Here is an example script that uses the new simpletrace module:

#!/usr/bin/env python
  1. Print virtqueue elements that were never returned to the guest.
import simpletrace
class VirtqueueRequestTracker(simpletrace.Analyzer):
def init(self):
self.elems = set()
def virtqueue_pop(self, vq, elem, in_num, out_num):
def virtqueue_fill(self, vq, elem, length, idx):
def end(self):
for elem in self.elems:
print hex(elem)

The simpletrace API is based around the Analyzer class. Users implement
an analyzer subclass and add methods for trace events they want to
process. A catchall() method is invoked for trace events which do not
have dedicated methods. Finally, there are also begin() and end()
methods like in sed that can be used to perform setup or print
statistics at the end.

A binary trace file is processed either with:

simpletrace.run(analyzer) # uses command-line args

or with:


Signed-off-by: Stefan Hajnoczi <>
Signed-off-by: Aurelien Jarno <>


  • added
  • modified
  • copied
  • renamed
  • deleted

View differences