diff options
Diffstat (limited to 'scripts/qemuimage-testlib-pythonhelper')
-rwxr-xr-x | scripts/qemuimage-testlib-pythonhelper | 66 |
1 files changed, 0 insertions, 66 deletions
diff --git a/scripts/qemuimage-testlib-pythonhelper b/scripts/qemuimage-testlib-pythonhelper deleted file mode 100755 index 6435dd8f18..0000000000 --- a/scripts/qemuimage-testlib-pythonhelper +++ /dev/null | |||
@@ -1,66 +0,0 @@ | |||
1 | #!/usr/bin/env python | ||
2 | |||
3 | import optparse | ||
4 | import subprocess | ||
5 | import sys | ||
6 | import os | ||
7 | |||
8 | parser = optparse.OptionParser( | ||
9 | usage = """ | ||
10 | %prog [options] | ||
11 | """) | ||
12 | |||
13 | parser.add_option("-q", "--findqemu", | ||
14 | help = "find a qemu beneath the process <pid>", | ||
15 | action="store", dest="findqemu") | ||
16 | |||
17 | options, args = parser.parse_args(sys.argv) | ||
18 | |||
19 | if options.findqemu: | ||
20 | # | ||
21 | # Walk the process tree from the process specified looking for a qemu-system. Return its pid. | ||
22 | # | ||
23 | ps = subprocess.Popen(['ps', 'axww', '-o', 'pid,ppid,command'], stdout=subprocess.PIPE).communicate()[0] | ||
24 | processes = ps.split('\n') | ||
25 | nfields = len(processes[0].split()) - 1 | ||
26 | pids = {} | ||
27 | commands = {} | ||
28 | for row in processes[1:]: | ||
29 | data = row.split(None, nfields) | ||
30 | if len(data) != 3: | ||
31 | continue | ||
32 | if data[1] not in pids: | ||
33 | pids[data[1]] = [] | ||
34 | pids[data[1]].append(data[0]) | ||
35 | commands[data[0]] = data[2] | ||
36 | |||
37 | if options.findqemu not in pids: | ||
38 | sys.stderr.write("No children found matching %s" % options.findqemu) | ||
39 | sys.exit(1) | ||
40 | |||
41 | parents = [] | ||
42 | newparents = pids[options.findqemu] | ||
43 | while newparents: | ||
44 | next = [] | ||
45 | for p in newparents: | ||
46 | if p in pids: | ||
47 | for n in pids[p]: | ||
48 | if n not in parents and n not in next: | ||
49 | next.append(n) | ||
50 | |||
51 | if p not in parents: | ||
52 | parents.append(p) | ||
53 | newparents = next | ||
54 | #print "Children matching %s:" % str(parents) | ||
55 | for p in parents: | ||
56 | # Need to be careful here since runqemu-internal runs "ldd qemu-system-xxxx" | ||
57 | # Also, old versions of ldd (2.11) run "LD_XXXX qemu-system-xxxx" | ||
58 | basecmd = commands[p].split()[0] | ||
59 | basecmd = os.path.basename(basecmd) | ||
60 | if "qemu-system" in basecmd and "192.168" in commands[p]: | ||
61 | print p | ||
62 | sys.exit(0) | ||
63 | sys.exit(1) | ||
64 | else: | ||
65 | parser.print_help() | ||
66 | |||