Skip to contentSkip to conversation

tools/kvm_stat: misc fixes

PATCH Superseded Stefan Raspl 2 participants 5 messages Nov 24, 2017 – Nov 29, 2017 KVM

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

cover tools/kvm_stat: misc fixes

Stefan Raspl (2):
tools/kvm_stat: fix command line option '-g' tools/kvm_stat: fix drilldown in events by guests mode

 tools/kvm/kvm_stat/kvm_stat | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)
Signature · 1 line
2.13.5
#1 lore raw

PATCH 1/2 tools/kvm_stat: fix command line option '-g'

Specifying a guest via '-g' 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.

---
 tools/kvm/kvm_stat/kvm_stat | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)
tools/kvm/kvm_stat/kvm_stat +6 -4
index 217cf6f95c36..884a74b8ca87 100755
@@ -950,7 +950,8 @@ class Tui(object):
             curses.nocbreak()
             curses.endwin()
 
-    def get_all_gnames(self):
+    @staticmethod
+    def get_all_gnames():
         """Returns a list of (pid, gname) tuples of all running guests"""
         res = []
         try:
@@ -963,7 +964,7 @@ class Tui(object):
             # perform a sanity check before calling the more expensive
             # function to possibly extract the guest name
             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()
 
         return res
@@ -984,7 +985,8 @@ class Tui(object):
         except Exception:
             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.
 
         Returns a list of potential pids, can be empty if no match found.
@@ -992,7 +994,7 @@ class Tui(object):
 
         """
         pids = []
-        for line in self.get_all_gnames():
+        for line in Tui.get_all_gnames():
             if gname == line[1]:
                 pids.append(int(line[0]))
 
Signature · 1 line
2.13.5
Tested-by on v1 1/2
#2 lore raw

Re: [PATCH v1 1/2] tools/kvm_stat: fix command line option '-g'

Quoted 5 lines · Stefan Raspl

Specifying a guest via '-g' results in an error:

   $ kvm_stat -g foo
   Usage: kvm_stat [options]
Quoted 7 lines

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.

Quoted 46 lines
---
 tools/kvm/kvm_stat/kvm_stat | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)
tools/kvm/kvm_stat/kvm_stat +6 -4
index 217cf6f95c36..884a74b8ca87 100755
@@ -950,7 +950,8 @@ class Tui(object):
             curses.nocbreak()
             curses.endwin()
 
-    def get_all_gnames(self):
+    @staticmethod
+    def get_all_gnames():
         """Returns a list of (pid, gname) tuples of all running guests"""
         res = []
         try:
@@ -963,7 +964,7 @@ class Tui(object):
             # perform a sanity check before calling the more expensive
             # function to possibly extract the guest name
             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()
 
         return res
@@ -984,7 +985,8 @@ class Tui(object):
         except Exception:
             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.
 
         Returns a list of potential pids, can be empty if no match found.
@@ -992,7 +994,7 @@ class Tui(object):
 
         """
         pids = []
-        for line in self.get_all_gnames():
+        for line in Tui.get_all_gnames():
             if gname == line[1]:
                 pids.append(int(line[0]))
 
#3 lore raw

Re: [PATCH v1 1/2] tools/kvm_stat: fix command line option '-g'

Quoted 11 lines · Christian Borntraeger
Quoted 8 lines · Stefan Raspl

Specifying a guest via '-g' 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

Quoted 6 lines
Quoted 4 lines

Reason is that Tui.get_pid_from_gname() is not static, as it is supposed to be.

Thx - I found some more issues, will do a V2 and include in there.

Ciao,
Stefan

#4 lore raw

PATCH 2/2 tools/kvm_stat: fix drilldown in events by guests mode

In reply to Stefan Raspl

When displaying debugfs events sorted by guests, an attempt to switch to reporting of stats for individual child trace events results in garbled output. Reason is that the update of the stats when toggling drilldown doesn't honor when events are displayed by guests.
To reproduce, run 'kvm_stat -d' and press 'b' followed by 'x'.

---
 tools/kvm/kvm_stat/kvm_stat | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/kvm/kvm_stat/kvm_stat +1 -1
index 884a74b8ca87..6347ad5d0d35 100755
@@ -1360,7 +1360,7 @@ class Tui(object):
                 if char == 'x':
                     self.update_drilldown()
                     # prevents display of current values on next refresh
-                    self.stats.get()
+                    self.stats.get(self._display_guests)
             except KeyboardInterrupt:
                 break
             except curses.error:
Signature · 1 line
2.13.5