diff options
Diffstat (limited to 'scripts')
| -rwxr-xr-x | scripts/analyse-9p-simpletrace.py | 75 | ||||
| -rw-r--r-- | scripts/qapi-commands.py | 30 | ||||
| -rw-r--r-- | scripts/qapi-types.py | 27 | ||||
| -rw-r--r-- | scripts/qapi-visit.py | 27 |
4 files changed, 148 insertions, 11 deletions
diff --git a/scripts/analyse-9p-simpletrace.py b/scripts/analyse-9p-simpletrace.py index b6d58fde96..3c3dee4337 100755 --- a/scripts/analyse-9p-simpletrace.py +++ b/scripts/analyse-9p-simpletrace.py @@ -3,15 +3,86 @@ # Usage: ./analyse-9p-simpletrace <trace-events> <trace-pid> # # Author: Harsh Prateek Bora - +import os import simpletrace +symbol_9p = { + 6 : 'TLERROR', + 7 : 'RLERROR', + 8 : 'TSTATFS', + 9 : 'RSTATFS', + 12 : 'TLOPEN', + 13 : 'RLOPEN', + 14 : 'TLCREATE', + 15 : 'RLCREATE', + 16 : 'TSYMLINK', + 17 : 'RSYMLINK', + 18 : 'TMKNOD', + 19 : 'RMKNOD', + 20 : 'TRENAME', + 21 : 'RRENAME', + 22 : 'TREADLINK', + 23 : 'RREADLINK', + 24 : 'TGETATTR', + 25 : 'RGETATTR', + 26 : 'TSETATTR', + 27 : 'RSETATTR', + 30 : 'TXATTRWALK', + 31 : 'RXATTRWALK', + 32 : 'TXATTRCREATE', + 33 : 'RXATTRCREATE', + 40 : 'TREADDIR', + 41 : 'RREADDIR', + 50 : 'TFSYNC', + 51 : 'RFSYNC', + 52 : 'TLOCK', + 53 : 'RLOCK', + 54 : 'TGETLOCK', + 55 : 'RGETLOCK', + 70 : 'TLINK', + 71 : 'RLINK', + 72 : 'TMKDIR', + 73 : 'RMKDIR', + 74 : 'TRENAMEAT', + 75 : 'RRENAMEAT', + 76 : 'TUNLINKAT', + 77 : 'RUNLINKAT', + 100 : 'TVERSION', + 101 : 'RVERSION', + 102 : 'TAUTH', + 103 : 'RAUTH', + 104 : 'TATTACH', + 105 : 'RATTACH', + 106 : 'TERROR', + 107 : 'RERROR', + 108 : 'TFLUSH', + 109 : 'RFLUSH', + 110 : 'TWALK', + 111 : 'RWALK', + 112 : 'TOPEN', + 113 : 'ROPEN', + 114 : 'TCREATE', + 115 : 'RCREATE', + 116 : 'TREAD', + 117 : 'RREAD', + 118 : 'TWRITE', + 119 : 'RWRITE', + 120 : 'TCLUNK', + 121 : 'RCLUNK', + 122 : 'TREMOVE', + 123 : 'RREMOVE', + 124 : 'TSTAT', + 125 : 'RSTAT', + 126 : 'TWSTAT', + 127 : 'RWSTAT' +} + class VirtFSRequestTracker(simpletrace.Analyzer): def begin(self): print "Pretty printing 9p simpletrace log ..." def v9fs_rerror(self, tag, id, err): - print "RERROR (tag =", tag, ", id =", id, ",err =", err, ")" + print "RERROR (tag =", tag, ", id =", symbol_9p[id], ", err = \"", os.strerror(err), "\")" def v9fs_version(self, tag, id, msize, version): print "TVERSION (tag =", tag, ", msize =", msize, ", version =", version, ")" diff --git a/scripts/qapi-commands.py b/scripts/qapi-commands.py index 54d1f5d659..bd7b207122 100644 --- a/scripts/qapi-commands.py +++ b/scripts/qapi-commands.py @@ -372,7 +372,9 @@ def gen_command_def_prologue(prefix="", proxy=False): try: - opts, args = getopt.gnu_getopt(sys.argv[1:], "p:o:m", ["prefix=", "output-dir=", "type=", "middle"]) + opts, args = getopt.gnu_getopt(sys.argv[1:], "chp:o:m", + ["source", "header", "prefix=", + "output-dir=", "type=", "middle"]) except getopt.GetoptError, err: print str(err) sys.exit(1) @@ -384,6 +386,9 @@ c_file = 'qmp-marshal.c' h_file = 'qmp-commands.h' middle_mode = False +do_c = False +do_h = False + for o, a in opts: if o in ("-p", "--prefix"): prefix = a @@ -393,10 +398,29 @@ for o, a in opts: dispatch_type = a elif o in ("-m", "--middle"): middle_mode = True + elif o in ("-c", "--source"): + do_h = True + elif o in ("-h", "--header"): + do_c = True + +if not do_c and not do_h: + do_c = True + do_h = True c_file = output_dir + prefix + c_file h_file = output_dir + prefix + h_file +def maybe_open(really, name, opt): + class Null(object): + def write(self, str): + pass + def read(self): + return '' + if really: + return open(name, opt) + else: + return Null() + try: os.makedirs(output_dir) except os.error, e: @@ -408,8 +432,8 @@ commands = filter(lambda expr: expr.has_key('command'), exprs) commands = filter(lambda expr: not expr.has_key('gen'), commands) if dispatch_type == "sync": - fdecl = open(h_file, 'w') - fdef = open(c_file, 'w') + fdecl = maybe_open(do_h, h_file, 'w') + fdef = maybe_open(do_c, c_file, 'w') ret = gen_command_decl_prologue(header=basename(h_file), guard=guardname(h_file), prefix=prefix) fdecl.write(ret) ret = gen_command_def_prologue(prefix=prefix) diff --git a/scripts/qapi-types.py b/scripts/qapi-types.py index 267cb49b13..ae644bc06f 100644 --- a/scripts/qapi-types.py +++ b/scripts/qapi-types.py @@ -163,7 +163,8 @@ void qapi_free_%(type)s(%(c_type)s obj) try: - opts, args = getopt.gnu_getopt(sys.argv[1:], "p:o:", ["prefix=", "output-dir="]) + opts, args = getopt.gnu_getopt(sys.argv[1:], "chp:o:", + ["source", "header", "prefix=", "output-dir="]) except getopt.GetoptError, err: print str(err) sys.exit(1) @@ -173,11 +174,22 @@ prefix = "" c_file = 'qapi-types.c' h_file = 'qapi-types.h' +do_c = False +do_h = False + for o, a in opts: if o in ("-p", "--prefix"): prefix = a elif o in ("-o", "--output-dir"): output_dir = a + "/" + elif o in ("-c", "--source"): + do_h = True + elif o in ("-h", "--header"): + do_c = True + +if not do_c and not do_h: + do_c = True + do_h = True c_file = output_dir + prefix + c_file h_file = output_dir + prefix + h_file @@ -188,8 +200,17 @@ except os.error, e: if e.errno != errno.EEXIST: raise -fdef = open(c_file, 'w') -fdecl = open(h_file, 'w') +def maybe_open(really, name, opt): + class Null(object): + def write(self, str): + pass + def read(self): + return '' + if really: + return open(name, opt) + +fdef = maybe_open(do_c, c_file, 'w') +fdecl = maybe_open(do_h, h_file, 'w') fdef.write(mcgen(''' /* AUTOMATICALLY GENERATED, DO NOT MODIFY */ diff --git a/scripts/qapi-visit.py b/scripts/qapi-visit.py index 62de83d0f0..e9d0584c78 100644 --- a/scripts/qapi-visit.py +++ b/scripts/qapi-visit.py @@ -139,7 +139,8 @@ void visit_type_%(name)s(Visitor *m, %(name)s * obj, const char *name, Error **e name=name) try: - opts, args = getopt.gnu_getopt(sys.argv[1:], "p:o:", ["prefix=", "output-dir="]) + opts, args = getopt.gnu_getopt(sys.argv[1:], "chp:o:", + ["source", "header", "prefix=", "output-dir="]) except getopt.GetoptError, err: print str(err) sys.exit(1) @@ -149,11 +150,22 @@ prefix = "" c_file = 'qapi-visit.c' h_file = 'qapi-visit.h' +do_c = False +do_h = False + for o, a in opts: if o in ("-p", "--prefix"): prefix = a elif o in ("-o", "--output-dir"): output_dir = a + "/" + elif o in ("-c", "--source"): + do_h = True + elif o in ("-h", "--header"): + do_c = True + +if not do_c and not do_h: + do_c = True + do_h = True c_file = output_dir + prefix + c_file h_file = output_dir + prefix + h_file @@ -164,8 +176,17 @@ except os.error, e: if e.errno != errno.EEXIST: raise -fdef = open(c_file, 'w') -fdecl = open(h_file, 'w') +def maybe_open(really, name, opt): + class Null(object): + def write(self, str): + pass + def read(self): + return '' + if really: + return open(name, opt) + +fdef = maybe_open(do_c, c_file, 'w') +fdecl = maybe_open(do_h, h_file, 'w') fdef.write(mcgen(''' /* THIS FILE IS AUTOMATICALLY GENERATED, DO NOT MODIFY */ |