Commit 19e8e54f authored by Stefan Raspl's avatar Stefan Raspl Committed by Paolo Bonzini

tools/kvm_stat: fix command line option '-g'

Specifying a guest via '-g foo' always results in an error:
  $ kvm_stat -g foo
  Usage: kvm_stat [options]

  kvm_stat: error: Error while searching for guest "foo", use "-p" to
  specify a pid instead

Reason is that Tui.get_pid_from_gname() is not static, as it is supposed
to be.
Signed-off-by: default avatarStefan Raspl <raspl@linux.vnet.ibm.com>
Tested-by: default avatarChristian Borntraeger <borntraeger@de.ibm.com>
Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
parent 5663d8f9
...@@ -950,7 +950,8 @@ class Tui(object): ...@@ -950,7 +950,8 @@ class Tui(object):
curses.nocbreak() curses.nocbreak()
curses.endwin() curses.endwin()
def get_all_gnames(self): @staticmethod
def get_all_gnames():
"""Returns a list of (pid, gname) tuples of all running guests""" """Returns a list of (pid, gname) tuples of all running guests"""
res = [] res = []
try: try:
...@@ -963,7 +964,7 @@ class Tui(object): ...@@ -963,7 +964,7 @@ class Tui(object):
# perform a sanity check before calling the more expensive # perform a sanity check before calling the more expensive
# function to possibly extract the guest name # function to possibly extract the guest name
if ' -name ' in line[1]: if ' -name ' in line[1]:
res.append((line[0], self.get_gname_from_pid(line[0]))) res.append((line[0], Tui.get_gname_from_pid(line[0])))
child.stdout.close() child.stdout.close()
return res return res
...@@ -984,7 +985,8 @@ class Tui(object): ...@@ -984,7 +985,8 @@ class Tui(object):
except Exception: except Exception:
self.screen.addstr(row + 1, 2, 'Not available') self.screen.addstr(row + 1, 2, 'Not available')
def get_pid_from_gname(self, gname): @staticmethod
def get_pid_from_gname(gname):
"""Fuzzy function to convert guest name to QEMU process pid. """Fuzzy function to convert guest name to QEMU process pid.
Returns a list of potential pids, can be empty if no match found. Returns a list of potential pids, can be empty if no match found.
...@@ -992,7 +994,7 @@ class Tui(object): ...@@ -992,7 +994,7 @@ class Tui(object):
""" """
pids = [] pids = []
for line in self.get_all_gnames(): for line in Tui.get_all_gnames():
if gname == line[1]: if gname == line[1]:
pids.append(int(line[0])) pids.append(int(line[0]))
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment