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

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