* [PATCH] Add a new profiler to autotest, kvm_stat
@ 2010-01-09 23:59 Lucas Meneghel Rodrigues
2010-01-10 6:35 ` Avi Kivity
0 siblings, 1 reply; 2+ messages in thread
From: Lucas Meneghel Rodrigues @ 2010-01-09 23:59 UTC (permalink / raw)
To: autotest; +Cc: kvm, mtosatti, Lucas Meneghel Rodrigues
In order to get kvm stats during the kvm tests execution,
a new profiler was created, kvm_stat. It's a simple profiler
that keeps an instance of the kvm_stat program running
during the test's execution, writing results on the profiling
directory.
Signed-off-by: Lucas Meneghel Rodrigues <lmr@redhat.com>
---
client/profilers/kvm_stat/kvm_stat.py | 61 +++++++++++++++++++++++++++++++++
1 files changed, 61 insertions(+), 0 deletions(-)
create mode 100644 client/profilers/kvm_stat/__init__.py
create mode 100644 client/profilers/kvm_stat/kvm_stat.py
diff --git a/client/profilers/kvm_stat/__init__.py b/client/profilers/kvm_stat/__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/client/profilers/kvm_stat/kvm_stat.py b/client/profilers/kvm_stat/kvm_stat.py
new file mode 100644
index 0000000..b2c0b32
--- /dev/null
+++ b/client/profilers/kvm_stat/kvm_stat.py
@@ -0,0 +1,61 @@
+"""
+kvm_stat prints statistics generated by the kvm module.
+It depends on debugfs. If no debugfs is mounted, the profiler
+will try to mount it so it's possible to proceed.
+
+@copyright: Red Hat 2010
+@author: Lucas Meneghel Rodrigues (lmr@redhat.com)
+"""
+import time, os, subprocess, commands
+from autotest_lib.client.bin import utils, profiler, os_dep
+
+
+class kvm_stat(profiler.profiler):
+ """
+ kvm_stat based profiler. Consists on executing kvm_stat -l during a given
+ test execution, redirecting its output to a file on the profile dir.
+ """
+ version = 1
+ def initialize(self):
+ """
+ Gets path of kvm_stat and verifies if debugfs needs to be mounted.
+ """
+ self.stat_path = os_dep.command('kvm_stat')
+ (ret, output) = commands.getstatusoutput("%s --batch" % self.stat_path)
+ if ret != 0:
+ if 'debugfs' in output:
+ utils.system('mount -t debugfs debugfs /sys/kernel/debug')
+ else:
+ raise error.AutotestError('kvm_stat failed due to an '
+ 'unknown reason: %s' % output)
+
+
+ def start(self, test):
+ """
+ Starts kvm_stat subprocess.
+
+ @param test: Autotest test on which this profiler will operate on.
+ """
+ cmd = "%s -l" % self.stat_path
+ logfile = open(os.path.join(test.profdir, "kvm_stat"), 'w')
+ p = subprocess.Popen(cmd, shell=True, stdout=logfile,
+ stderr=subprocess.STDOUT)
+ self.pid = p.pid
+
+
+ def stop(self, test):
+ """
+ Stops profiler execution by sending a SIGTERM to kvm_stat process.
+
+ @param test: Autotest test on which this profiler will operate on.
+ """
+ os.kill(self.pid, 15)
+
+
+ def report(self, test):
+ """
+ Report function. Does nothing as there's no postprocesing needed.
+
+ @param test: Autotest test on which this profiler will operate on.
+ """
+ return None
--
1.6.5.2
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] Add a new profiler to autotest, kvm_stat
2010-01-09 23:59 [PATCH] Add a new profiler to autotest, kvm_stat Lucas Meneghel Rodrigues
@ 2010-01-10 6:35 ` Avi Kivity
0 siblings, 0 replies; 2+ messages in thread
From: Avi Kivity @ 2010-01-10 6:35 UTC (permalink / raw)
To: Lucas Meneghel Rodrigues; +Cc: autotest, kvm, mtosatti
On 01/10/2010 01:59 AM, Lucas Meneghel Rodrigues wrote:
> In order to get kvm stats during the kvm tests execution,
> a new profiler was created, kvm_stat. It's a simple profiler
> that keeps an instance of the kvm_stat program running
> during the test's execution, writing results on the profiling
> directory.
>
>
It would be better to access debugfs directly, and even better to use
the perf facilities; eventually kvm_stat will be removed in their favour.
--
I have a truly marvellous patch that fixes the bug which this
signature is too narrow to contain.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2010-01-10 6:36 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-01-09 23:59 [PATCH] Add a new profiler to autotest, kvm_stat Lucas Meneghel Rodrigues
2010-01-10 6:35 ` Avi Kivity
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).