Blame SOURCES/kvm-tools-kvm_stat-fix-command-line-option-g.patch

4a2fec
From 283aa25f757053d99515887348cdc49e873e577c Mon Sep 17 00:00:00 2001
4a2fec
From: David Hildenbrand <david@redhat.com>
4a2fec
Date: Mon, 8 Jan 2018 21:26:31 +0100
4a2fec
Subject: [PATCH 01/12] tools/kvm_stat: fix command line option '-g'
4a2fec
4a2fec
RH-Author: David Hildenbrand <david@redhat.com>
4a2fec
Message-id: <20180108212631.29046-1-david@redhat.com>
4a2fec
Patchwork-id: 78528
4a2fec
O-Subject: [RHEL-7.5 qemu-kvm-rhev PATCH] tools/kvm_stat: fix command line option '-g'
4a2fec
Bugzilla: 1529676
4a2fec
RH-Acked-by: Thomas Huth <thuth@redhat.com>
4a2fec
RH-Acked-by: Cornelia Huck <cohuck@redhat.com>
4a2fec
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
4a2fec
4a2fec
commit 19e8e54f4309eaa438237aa1973fe40c331903d4 (HEAD)
4a2fec
Author: Stefan Raspl <stefan.raspl@de.ibm.com>
4a2fec
Date:   Mon Dec 11 12:25:19 2017 +0100
4a2fec
4a2fec
    tools/kvm_stat: fix command line option '-g'
4a2fec
4a2fec
    Specifying a guest via '-g foo' always results in an error:
4a2fec
      $ kvm_stat -g foo
4a2fec
      Usage: kvm_stat [options]
4a2fec
4a2fec
      kvm_stat: error: Error while searching for guest "foo", use "-p" to
4a2fec
      specify a pid instead
4a2fec
4a2fec
    Reason is that Tui.get_pid_from_gname() is not static, as it is supposed
4a2fec
    to be.
4a2fec
4a2fec
    Signed-off-by: Stefan Raspl <raspl@linux.vnet.ibm.com>
4a2fec
    Tested-by: Christian Borntraeger <borntraeger@de.ibm.com>
4a2fec
    Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
4a2fec
4a2fec
Signed-off-by: David Hildenbrand <david@redhat.com>
4a2fec
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
4a2fec
---
4a2fec
 scripts/kvm/kvm_stat | 10 ++++++----
4a2fec
 1 file changed, 6 insertions(+), 4 deletions(-)
4a2fec
4a2fec
diff --git a/scripts/kvm/kvm_stat b/scripts/kvm/kvm_stat
4a2fec
index 32283d8..c74a9a0 100755
4a2fec
--- a/scripts/kvm/kvm_stat
4a2fec
+++ b/scripts/kvm/kvm_stat
4a2fec
@@ -946,7 +946,8 @@ class Tui(object):
4a2fec
             curses.nocbreak()
4a2fec
             curses.endwin()
4a2fec
 
4a2fec
-    def get_all_gnames(self):
4a2fec
+    @staticmethod
4a2fec
+    def get_all_gnames():
4a2fec
         """Returns a list of (pid, gname) tuples of all running guests"""
4a2fec
         res = []
4a2fec
         try:
4a2fec
@@ -959,7 +960,7 @@ class Tui(object):
4a2fec
             # perform a sanity check before calling the more expensive
4a2fec
             # function to possibly extract the guest name
4a2fec
             if ' -name ' in line[1]:
4a2fec
-                res.append((line[0], self.get_gname_from_pid(line[0])))
4a2fec
+                res.append((line[0], Tui.get_gname_from_pid(line[0])))
4a2fec
         child.stdout.close()
4a2fec
 
4a2fec
         return res
4a2fec
@@ -980,7 +981,8 @@ class Tui(object):
4a2fec
         except Exception:
4a2fec
             self.screen.addstr(row + 1, 2, 'Not available')
4a2fec
 
4a2fec
-    def get_pid_from_gname(self, gname):
4a2fec
+    @staticmethod
4a2fec
+    def get_pid_from_gname(gname):
4a2fec
         """Fuzzy function to convert guest name to QEMU process pid.
4a2fec
 
4a2fec
         Returns a list of potential pids, can be empty if no match found.
4a2fec
@@ -988,7 +990,7 @@ class Tui(object):
4a2fec
 
4a2fec
         """
4a2fec
         pids = []
4a2fec
-        for line in self.get_all_gnames():
4a2fec
+        for line in Tui.get_all_gnames():
4a2fec
             if gname == line[1]:
4a2fec
                 pids.append(int(line[0]))
4a2fec
 
4a2fec
-- 
4a2fec
1.8.3.1
4a2fec