public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/3] perf tools: Move code to generate filename for perf-kvm to function.
@ 2013-12-06 22:25 Dongsheng Yang
  2013-12-06 22:25 ` [PATCH 2/3] perf tools: Make perf kvm diff support --guestmount Dongsheng Yang
                   ` (2 more replies)
  0 siblings, 3 replies; 9+ messages in thread
From: Dongsheng Yang @ 2013-12-06 22:25 UTC (permalink / raw)
  To: acme; +Cc: linux-kernel, Dongsheng Yang

The code in builtin-kvm.c to generate filename for perf-kvm is useful
to other command such as builtin-diff.

This patch move the related code form builtin-kvm.c to util/util.c and
wrap them in a function named get_filename_for_perf_kvm.

Signed-off-by: Dongsheng Yang <yangds.fnst@cn.fujitsu.com>
---
 tools/perf/builtin-kvm.c |  7 +------
 tools/perf/util/util.c   | 14 ++++++++++++++
 tools/perf/util/util.h   |  2 ++
 3 files changed, 17 insertions(+), 6 deletions(-)

diff --git a/tools/perf/builtin-kvm.c b/tools/perf/builtin-kvm.c
index f8bf5f2..143ad99 100644
--- a/tools/perf/builtin-kvm.c
+++ b/tools/perf/builtin-kvm.c
@@ -1711,12 +1711,7 @@ int cmd_kvm(int argc, const char **argv, const char *prefix __maybe_unused)
 		perf_guest = 1;
 
 	if (!file_name) {
-		if (perf_host && !perf_guest)
-			file_name = strdup("perf.data.host");
-		else if (!perf_host && perf_guest)
-			file_name = strdup("perf.data.guest");
-		else
-			file_name = strdup("perf.data.kvm");
+		file_name = get_filename_for_perf_kvm();
 
 		if (!file_name) {
 			pr_err("Failed to allocate memory for filename\n");
diff --git a/tools/perf/util/util.c b/tools/perf/util/util.c
index bae8756..4a57609 100644
--- a/tools/perf/util/util.c
+++ b/tools/perf/util/util.c
@@ -482,3 +482,17 @@ int filename__read_str(const char *filename, char **buf, size_t *sizep)
 	close(fd);
 	return err;
 }
+
+const char *get_filename_for_perf_kvm(void)
+{
+	const char *filename;
+
+	if (perf_host && !perf_guest)
+		filename = strdup("perf.data.host");
+	else if (!perf_host && perf_guest)
+		filename = strdup("perf.data.guest");
+	else
+		filename = strdup("perf.data.kvm");
+
+	return filename;
+}
diff --git a/tools/perf/util/util.h b/tools/perf/util/util.h
index adb39f2..e6d8796 100644
--- a/tools/perf/util/util.h
+++ b/tools/perf/util/util.h
@@ -309,4 +309,6 @@ void free_srcline(char *srcline);
 
 int filename__read_int(const char *filename, int *value);
 int filename__read_str(const char *filename, char **buf, size_t *sizep);
+
+const char *get_filename_for_perf_kvm(void);
 #endif /* GIT_COMPAT_UTIL_H */
-- 
1.8.2.1


^ permalink raw reply related	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2013-12-11 11:06 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-12-06 22:25 [PATCH 1/3] perf tools: Move code to generate filename for perf-kvm to function Dongsheng Yang
2013-12-06 22:25 ` [PATCH 2/3] perf tools: Make perf kvm diff support --guestmount Dongsheng Yang
2013-12-11 11:05   ` [tip:perf/core] perf kvm: " tip-bot for Dongsheng Yang
2013-12-06 22:25 ` [PATCH 3/3] perf tools: Change the default filenames for perf kvm diff to perf.data.xxx and perf.data.xxx.old Dongsheng Yang
2013-12-11 16:21   ` [PATCH V2] " Dongsheng Yang
2013-12-11 16:30     ` [PATCH V3] " Dongsheng Yang
2013-12-11  3:38       ` David Ahern
2013-12-11 16:46         ` Dongsheng Yang
2013-12-11 11:05 ` [tip:perf/core] perf kvm: Move code to generate filename for perf-kvm to function tip-bot for Dongsheng Yang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox