All of lore.kernel.org
 help / color / mirror / Atom feed
From: Michael Goldish <mgoldish@redhat.com>
To: autotest@test.kernel.org, kvm@vger.kernel.org
Subject: [KVM-AUTOTEST PATCH 06/14] KVM test: kvm_vm.py: correct get_shared_meminfo()
Date: Sun, 13 Jun 2010 17:33:37 +0300	[thread overview]
Message-ID: <1276439625-32472-6-git-send-email-mgoldish@redhat.com> (raw)
In-Reply-To: <1276439625-32472-5-git-send-email-mgoldish@redhat.com>

- 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@redhat.com>
---
 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

  reply	other threads:[~2010-06-13 14:33 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-06-13 14:33 [KVM-AUTOTEST PATCH 01/14] KVM test: tests_base.cfg.sample: remove inline comments Michael Goldish
2010-06-13 14:33 ` [KVM-AUTOTEST PATCH 02/14] KVM test: tests_base.cfg.sample: style modifications Michael Goldish
2010-06-13 14:33   ` [KVM-AUTOTEST PATCH 03/14] KVM test: kvm_utils.py: warn about exceptions raised during unpickling of env Michael Goldish
2010-06-13 14:33     ` [KVM-AUTOTEST PATCH 04/14] KVM test: kvm_utils.py: remove unnecessary imports Michael Goldish
2010-06-13 14:33       ` [KVM-AUTOTEST PATCH 05/14] KVM test: kvm_vm.py: make get_pid() return the pid of the VM itself Michael Goldish
2010-06-13 14:33         ` Michael Goldish [this message]
2010-06-13 14:33           ` [KVM-AUTOTEST PATCH 07/14] KVM test: kvm_vm.py: correct add_smp() mistake in make_qemu_command() Michael Goldish
2010-06-13 14:33             ` [KVM-AUTOTEST PATCH 08/14] KVM test: kvm_vm.py: use shell quoting in make_qemu_command() where appropriate Michael Goldish
2010-06-13 14:33               ` [KVM-AUTOTEST PATCH 09/14] KVM test: remove reference to _screendump_thread at postprocessing Michael Goldish
2010-06-13 14:33                 ` [KVM-AUTOTEST PATCH 10/14] KVM test: kvm_subprocess.py: use sys.executable instead of hardcoded 'python' Michael Goldish
2010-06-13 14:33                   ` [KVM-AUTOTEST PATCH 11/14] KVM test: add kvm_monitor.py, an interface to QEMU monitors Michael Goldish
2010-06-13 14:33                     ` [KVM-AUTOTEST PATCH 12/14] KVM test: use new monitor interface Michael Goldish
2010-06-13 14:33                       ` [KVM-AUTOTEST PATCH 13/14] KVM test: kvm_monitor.py: add QMP interface Michael Goldish
2010-06-13 14:33                         ` [KVM-AUTOTEST PATCH 14/14] KVM test: migration: support QMP Michael Goldish
2010-06-14  2:39                         ` [Autotest] [KVM-AUTOTEST PATCH 13/14] KVM test: kvm_monitor.py: add QMP interface Amos Kong
2010-06-14  6:34                           ` Michael Goldish
2010-06-14  1:32                     ` [Autotest] [KVM-AUTOTEST PATCH 11/14] KVM test: add kvm_monitor.py, an interface to QEMU monitors Amos Kong
2010-06-14  5:59                       ` Michael Goldish

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1276439625-32472-6-git-send-email-mgoldish@redhat.com \
    --to=mgoldish@redhat.com \
    --cc=autotest@test.kernel.org \
    --cc=kvm@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.