]> git.proxmox.com Git - mirror_qemu.git/blame - scripts/analyse-9p-simpletrace.py
Merge remote-tracking branch 'remotes/bonzini/tags/for-upstream' into staging
[mirror_qemu.git] / scripts / analyse-9p-simpletrace.py
CommitLineData
49a88ce3
HPB
1#!/usr/bin/env python
2# Pretty print 9p simpletrace log
3# Usage: ./analyse-9p-simpletrace <trace-events> <trace-pid>
4#
5# Author: Harsh Prateek Bora
f03868bd 6from __future__ import print_function
058a96ed 7import os
49a88ce3
HPB
8import simpletrace
9
058a96ed
HPB
10symbol_9p = {
11 6 : 'TLERROR',
12 7 : 'RLERROR',
13 8 : 'TSTATFS',
14 9 : 'RSTATFS',
15 12 : 'TLOPEN',
16 13 : 'RLOPEN',
17 14 : 'TLCREATE',
18 15 : 'RLCREATE',
19 16 : 'TSYMLINK',
20 17 : 'RSYMLINK',
21 18 : 'TMKNOD',
22 19 : 'RMKNOD',
23 20 : 'TRENAME',
24 21 : 'RRENAME',
25 22 : 'TREADLINK',
26 23 : 'RREADLINK',
27 24 : 'TGETATTR',
28 25 : 'RGETATTR',
29 26 : 'TSETATTR',
30 27 : 'RSETATTR',
31 30 : 'TXATTRWALK',
32 31 : 'RXATTRWALK',
33 32 : 'TXATTRCREATE',
34 33 : 'RXATTRCREATE',
35 40 : 'TREADDIR',
36 41 : 'RREADDIR',
37 50 : 'TFSYNC',
38 51 : 'RFSYNC',
39 52 : 'TLOCK',
40 53 : 'RLOCK',
41 54 : 'TGETLOCK',
42 55 : 'RGETLOCK',
43 70 : 'TLINK',
44 71 : 'RLINK',
45 72 : 'TMKDIR',
46 73 : 'RMKDIR',
47 74 : 'TRENAMEAT',
48 75 : 'RRENAMEAT',
49 76 : 'TUNLINKAT',
50 77 : 'RUNLINKAT',
51 100 : 'TVERSION',
52 101 : 'RVERSION',
53 102 : 'TAUTH',
54 103 : 'RAUTH',
55 104 : 'TATTACH',
56 105 : 'RATTACH',
57 106 : 'TERROR',
58 107 : 'RERROR',
59 108 : 'TFLUSH',
60 109 : 'RFLUSH',
61 110 : 'TWALK',
62 111 : 'RWALK',
63 112 : 'TOPEN',
64 113 : 'ROPEN',
65 114 : 'TCREATE',
66 115 : 'RCREATE',
67 116 : 'TREAD',
68 117 : 'RREAD',
69 118 : 'TWRITE',
70 119 : 'RWRITE',
71 120 : 'TCLUNK',
72 121 : 'RCLUNK',
73 122 : 'TREMOVE',
74 123 : 'RREMOVE',
75 124 : 'TSTAT',
76 125 : 'RSTAT',
77 126 : 'TWSTAT',
78 127 : 'RWSTAT'
79}
80
49a88ce3 81class VirtFSRequestTracker(simpletrace.Analyzer):
7999f7e1 82 def begin(self):
f03868bd 83 print("Pretty printing 9p simpletrace log ...")
49a88ce3 84
7999f7e1 85 def v9fs_rerror(self, tag, id, err):
f03868bd 86 print("RERROR (tag =", tag, ", id =", symbol_9p[id], ", err = \"", os.strerror(err), "\")")
49a88ce3
HPB
87
88 def v9fs_version(self, tag, id, msize, version):
f03868bd 89 print("TVERSION (tag =", tag, ", msize =", msize, ", version =", version, ")")
49a88ce3
HPB
90
91 def v9fs_version_return(self, tag, id, msize, version):
f03868bd 92 print("RVERSION (tag =", tag, ", msize =", msize, ", version =", version, ")")
49a88ce3
HPB
93
94 def v9fs_attach(self, tag, id, fid, afid, uname, aname):
f03868bd 95 print("TATTACH (tag =", tag, ", fid =", fid, ", afid =", afid, ", uname =", uname, ", aname =", aname, ")")
49a88ce3 96
7999f7e1 97 def v9fs_attach_return(self, tag, id, type, version, path):
f03868bd 98 print("RATTACH (tag =", tag, ", qid={type =", type, ", version =", version, ", path =", path, "})")
49a88ce3 99
7999f7e1 100 def v9fs_stat(self, tag, id, fid):
f03868bd 101 print("TSTAT (tag =", tag, ", fid =", fid, ")")
49a88ce3 102
7999f7e1 103 def v9fs_stat_return(self, tag, id, mode, atime, mtime, length):
f03868bd 104 print("RSTAT (tag =", tag, ", mode =", mode, ", atime =", atime, ", mtime =", mtime, ", length =", length, ")")
49a88ce3 105
7999f7e1 106 def v9fs_getattr(self, tag, id, fid, request_mask):
f03868bd 107 print("TGETATTR (tag =", tag, ", fid =", fid, ", request_mask =", hex(request_mask), ")")
49a88ce3 108
7999f7e1 109 def v9fs_getattr_return(self, tag, id, result_mask, mode, uid, gid):
f03868bd 110 print("RGETATTR (tag =", tag, ", result_mask =", hex(result_mask), ", mode =", oct(mode), ", uid =", uid, ", gid =", gid, ")")
49a88ce3 111
7999f7e1 112 def v9fs_walk(self, tag, id, fid, newfid, nwnames):
f03868bd 113 print("TWALK (tag =", tag, ", fid =", fid, ", newfid =", newfid, ", nwnames =", nwnames, ")")
49a88ce3 114
7999f7e1 115 def v9fs_walk_return(self, tag, id, nwnames, qids):
f03868bd 116 print("RWALK (tag =", tag, ", nwnames =", nwnames, ", qids =", hex(qids), ")")
49a88ce3 117
7999f7e1 118 def v9fs_open(self, tag, id, fid, mode):
f03868bd 119 print("TOPEN (tag =", tag, ", fid =", fid, ", mode =", oct(mode), ")")
49a88ce3 120
7999f7e1 121 def v9fs_open_return(self, tag, id, type, version, path, iounit):
f03868bd 122 print("ROPEN (tag =", tag, ", qid={type =", type, ", version =", version, ", path =", path, "}, iounit =", iounit, ")")
49a88ce3 123
7999f7e1 124 def v9fs_lcreate(self, tag, id, dfid, flags, mode, gid):
f03868bd 125 print("TLCREATE (tag =", tag, ", dfid =", dfid, ", flags =", oct(flags), ", mode =", oct(mode), ", gid =", gid, ")")
49a88ce3 126
7999f7e1 127 def v9fs_lcreate_return(self, tag, id, type, version, path, iounit):
f03868bd 128 print("RLCREATE (tag =", tag, ", qid={type =", type, ", version =", version, ", path =", path, "}, iounit =", iounit, ")")
49a88ce3 129
7999f7e1 130 def v9fs_fsync(self, tag, id, fid, datasync):
f03868bd 131 print("TFSYNC (tag =", tag, ", fid =", fid, ", datasync =", datasync, ")")
49a88ce3 132
7999f7e1 133 def v9fs_clunk(self, tag, id, fid):
f03868bd 134 print("TCLUNK (tag =", tag, ", fid =", fid, ")")
49a88ce3 135
7999f7e1 136 def v9fs_read(self, tag, id, fid, off, max_count):
f03868bd 137 print("TREAD (tag =", tag, ", fid =", fid, ", off =", off, ", max_count =", max_count, ")")
49a88ce3 138
7999f7e1 139 def v9fs_read_return(self, tag, id, count, err):
f03868bd 140 print("RREAD (tag =", tag, ", count =", count, ", err =", err, ")")
49a88ce3 141
7999f7e1 142 def v9fs_readdir(self, tag, id, fid, offset, max_count):
f03868bd 143 print("TREADDIR (tag =", tag, ", fid =", fid, ", offset =", offset, ", max_count =", max_count, ")")
49a88ce3 144
7999f7e1 145 def v9fs_readdir_return(self, tag, id, count, retval):
f03868bd 146 print("RREADDIR (tag =", tag, ", count =", count, ", retval =", retval, ")")
49a88ce3 147
7999f7e1 148 def v9fs_write(self, tag, id, fid, off, count, cnt):
f03868bd 149 print("TWRITE (tag =", tag, ", fid =", fid, ", off =", off, ", count =", count, ", cnt =", cnt, ")")
49a88ce3 150
7999f7e1 151 def v9fs_write_return(self, tag, id, total, err):
f03868bd 152 print("RWRITE (tag =", tag, ", total =", total, ", err =", err, ")")
49a88ce3 153
7999f7e1 154 def v9fs_create(self, tag, id, fid, name, perm, mode):
f03868bd 155 print("TCREATE (tag =", tag, ", fid =", fid, ", perm =", oct(perm), ", name =", name, ", mode =", oct(mode), ")")
49a88ce3 156
7999f7e1 157 def v9fs_create_return(self, tag, id, type, version, path, iounit):
f03868bd 158 print("RCREATE (tag =", tag, ", qid={type =", type, ", version =", version, ", path =", path, "}, iounit =", iounit, ")")
49a88ce3 159
7999f7e1 160 def v9fs_symlink(self, tag, id, fid, name, symname, gid):
f03868bd 161 print("TSYMLINK (tag =", tag, ", fid =", fid, ", name =", name, ", symname =", symname, ", gid =", gid, ")")
49a88ce3 162
7999f7e1 163 def v9fs_symlink_return(self, tag, id, type, version, path):
f03868bd 164 print("RSYMLINK (tag =", tag, ", qid={type =", type, ", version =", version, ", path =", path, "})")
49a88ce3 165
7999f7e1 166 def v9fs_flush(self, tag, id, flush_tag):
f03868bd 167 print("TFLUSH (tag =", tag, ", flush_tag =", flush_tag, ")")
49a88ce3 168
7999f7e1 169 def v9fs_link(self, tag, id, dfid, oldfid, name):
f03868bd 170 print("TLINK (tag =", tag, ", dfid =", dfid, ", oldfid =", oldfid, ", name =", name, ")")
49a88ce3 171
7999f7e1 172 def v9fs_remove(self, tag, id, fid):
f03868bd 173 print("TREMOVE (tag =", tag, ", fid =", fid, ")")
49a88ce3 174
7999f7e1 175 def v9fs_wstat(self, tag, id, fid, mode, atime, mtime):
f03868bd 176 print("TWSTAT (tag =", tag, ", fid =", fid, ", mode =", oct(mode), ", atime =", atime, "mtime =", mtime, ")")
49a88ce3 177
7999f7e1 178 def v9fs_mknod(self, tag, id, fid, mode, major, minor):
f03868bd 179 print("TMKNOD (tag =", tag, ", fid =", fid, ", mode =", oct(mode), ", major =", major, ", minor =", minor, ")")
49a88ce3 180
7999f7e1 181 def v9fs_lock(self, tag, id, fid, type, start, length):
f03868bd 182 print("TLOCK (tag =", tag, ", fid =", fid, "type =", type, ", start =", start, ", length =", length, ")")
49a88ce3 183
7999f7e1 184 def v9fs_lock_return(self, tag, id, status):
f03868bd 185 print("RLOCK (tag =", tag, ", status =", status, ")")
49a88ce3 186
7999f7e1 187 def v9fs_getlock(self, tag, id, fid, type, start, length):
f03868bd 188 print("TGETLOCK (tag =", tag, ", fid =", fid, "type =", type, ", start =", start, ", length =", length, ")")
49a88ce3 189
7999f7e1 190 def v9fs_getlock_return(self, tag, id, type, start, length, proc_id):
f03868bd 191 print("RGETLOCK (tag =", tag, "type =", type, ", start =", start, ", length =", length, ", proc_id =", proc_id, ")")
49a88ce3 192
7999f7e1 193 def v9fs_mkdir(self, tag, id, fid, name, mode, gid):
f03868bd 194 print("TMKDIR (tag =", tag, ", fid =", fid, ", name =", name, ", mode =", mode, ", gid =", gid, ")")
49a88ce3 195
7999f7e1 196 def v9fs_mkdir_return(self, tag, id, type, version, path, err):
f03868bd 197 print("RMKDIR (tag =", tag, ", qid={type =", type, ", version =", version, ", path =", path, "}, err =", err, ")")
49a88ce3 198
7999f7e1 199 def v9fs_xattrwalk(self, tag, id, fid, newfid, name):
f03868bd 200 print("TXATTRWALK (tag =", tag, ", fid =", fid, ", newfid =", newfid, ", xattr name =", name, ")")
49a88ce3 201
7999f7e1 202 def v9fs_xattrwalk_return(self, tag, id, size):
f03868bd 203 print("RXATTRWALK (tag =", tag, ", xattrsize =", size, ")")
49a88ce3 204
7999f7e1 205 def v9fs_xattrcreate(self, tag, id, fid, name, size, flags):
f03868bd 206 print("TXATTRCREATE (tag =", tag, ", fid =", fid, ", name =", name, ", xattrsize =", size, ", flags =", flags, ")")
49a88ce3 207
7999f7e1 208 def v9fs_readlink(self, tag, id, fid):
f03868bd 209 print("TREADLINK (tag =", tag, ", fid =", fid, ")")
49a88ce3 210
7999f7e1 211 def v9fs_readlink_return(self, tag, id, target):
f03868bd 212 print("RREADLINK (tag =", tag, ", target =", target, ")")
49a88ce3
HPB
213
214simpletrace.run(VirtFSRequestTracker())