- Use open("filename") instead of os.popen("cat filename")
- Use self.get_pid() to obtain the PID
- Return the result as a float

Signed-off-by: Michael Goldish <[email protected]>
---
 client/tests/kvm/kvm_vm.py |    7 +++----
 1 files changed, 3 insertions(+), 4 deletions(-)

diff --git a/client/tests/kvm/kvm_vm.py b/client/tests/kvm/kvm_vm.py
index 9d3539f..f65d967 100755
--- a/client/tests/kvm/kvm_vm.py
+++ b/client/tests/kvm/kvm_vm.py
@@ -884,11 +884,10 @@ class VM:
             logging.error("Could not get shared memory info from dead VM.")
             return None
 
-        cmd = "cat /proc/%d/statm" % self.params.get('pid_' + self.name)
-        shm = int(os.popen(cmd).readline().split()[2])
+        filename = "/proc/%d/statm" % self.get_pid()
+        shm = int(open(filename).read().split()[2])
         # statm stores informations in pages, translate it to MB
-        shm = shm * 4 / 1024
-        return shm
+        return shm * 4.0 / 1024
 
 
     def remote_login(self, nic_index=0, timeout=10):
-- 
1.5.4.1

_______________________________________________
Autotest mailing list
[email protected]
http://test.kernel.org/cgi-bin/mailman/listinfo/autotest

Reply via email to