[KVM-AUTOTEST PATCH 06/14] KVM test: kvm_vm.py: correct get_shared_meminfo()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



- 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 <mgoldish@xxxxxxxxxx>
---
 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

--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux