On Tue, Oct 19, 2010 at 03:29:51PM +0100, Richard W.M. Jones wrote: > On Tue, Oct 19, 2010 at 03:59:36PM +0200, Jan Kiszka wrote: > > Once we have "-trace events=...", defining the list of active > > tracepoints before starting qemu will be trivial (e.g. via a config > > file). Of course, this requires that all tracepoints are built-in... > > Sorry that I've not been following this very closely, but does this > sort of thing allow tracing reads and writes to block devices? Am I > right in thinking that if a tracepoint existed in the right place, one > could get a log file from that which could be post-processed in > another tool? > > cf: > http://rwmj.wordpress.com/2010/10/05/visualizing-reads-writes-and-alignment/#content
Definitely, here is the commit that added bdrv_aio_writev/bdrv_aio_readv tracing. bdrv_aio_multiwrite has been traced for a while. http://patchwork.ozlabs.org/patch/66843/ As an example, I use the following script to find all write requests that touch a given region. This is very useful for debugging image corruptions given a trace file: The usage is: find_overlapping_io.py <bs> <sector_num> <nb_sectors> where bs is the block driver state pointer, sector_num is the starting sector address, and nb_sectors is the number of sectors. #!/usr/bin/env python import sys def trace_filter(fobj, event, keys): for line in fobj: fields = line.strip().split() if fields[0] != event: continue attrs = dict([(k, v) for k, v in (x.split('=') for x in fields[2:])]) match = True for k, v in keys.iteritems(): if k not in attrs: match = False break if attrs[k] != v: match = False break if match: yield attrs def intersection(a_sector_num, a_nb_sectors, b_sector_num, b_nb_sectors): return not (a_sector_num + a_nb_sectors <= b_sector_num or \ b_sector_num + b_nb_sectors <= a_sector_num) bs, sector_num, nb_sectors = sys.argv[1:] sector_num = int(sector_num, 0) nb_sectors = int(nb_sectors, 0) for req in trace_filter(sys.stdin, 'bdrv_aio_writev', {'bs': bs}): if intersection(sector_num, nb_sectors, int(req['sector_num'], 0), int(req['nb_sectors'], 0)): print req Stefan