On 2016-09-08 15:53, Ralf Ramsauer wrote:
> diff --git a/tools/jailhouse-cell-stats b/tools/jailhouse-cell-stats
> index dd3270d..5e0e49c 100755
> --- a/tools/jailhouse-cell-stats
> +++ b/tools/jailhouse-cell-stats
> @@ -16,10 +16,12 @@ import datetime
> import os
> import sys
>
> -stats_dir = "/sys/devices/jailhouse/cells/%s/statistics"
> +cells_dir = "/sys/devices/jailhouse/cells/"
> +cell_dir = cells_dir + "%d/"
> +stats_dir = cell_dir + "statistics/"
>
>
> -def main(stdscr, cell, stats_names):
> +def main(stdscr, cell_id, cell_name, stats_names):
> try:
> curses.use_default_colors()
> curses.curs_set(0)
> @@ -33,7 +35,7 @@ def main(stdscr, cell, stats_names):
> now = datetime.datetime.now()
>
> for name in stats_names:
> - f = open((stats_dir + "/%s") % (cell, name), "r")
> + f = open((stats_dir + "/%s") % (cell_id, name), "r")
> value[name] = int(f.read())
>
> def sortkey(name):
> @@ -43,7 +45,7 @@ def main(stdscr, cell, stats_names):
> return (old_value[name] - value[name], -value[name], name)
>
> stdscr.erase()
> - stdscr.addstr(0, 0, "Statistics for %s cell" % cell)
> + stdscr.addstr(0, 0, "Statistics for %s cell" % cell_name)
> (height, width) = stdscr.getmaxyx()
> stdscr.hline(2, 0, " ", width, curses.A_REVERSE)
> stdscr.addstr(2, 0, "COUNTER", curses.A_REVERSE)
> @@ -89,24 +91,26 @@ if argc < 2 or argc > 3 or (not use_name and argc > 2):
> if sys.argv[1] in ("--help", "-h"):
> usage(0)
>
> +cell_id = -1
> try:
> if use_name:
> cell_name = sys.argv[2]
> + for id in os.listdir(cells_dir):
> + f = open((cell_dir + "name") % int(id), "r")
> + if f.read().rstrip() == cell_name:
> + cell_id = int(id)
> + break
> else:
> - cell_name = sys.argv[1]
> try:
> cell_id = int(sys.argv[1])
> - for cell in os.listdir("/sys/devices/jailhouse/cells"):
> - f = open("/sys/devices/jailhouse/cells/%s/id" % cell, "r")
> - if int(f.read()) == cell_id:
> - cell_name = cell
> - break
> + with open((cell_dir + "name") % cell_id, "r") as f:
> + cell_name = f.read().rstrip()
One more regression: The breaks "jailhouse cell stats NAME", i.e. the
case of leaving out --name while still providing a name string instead
of a numeric ID. --name is only required when a string could also be
interpreted as an ID.
I would have fixed this, but the changes are likely too invasive to the
original patch. Please send a tested v7 of this patch, and I will update
'next' then.
Thanks,
Jan
--
You received this message because you are subscribed to the Google Groups
"Jailhouse" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.