From 26ac16f3ce68961a2b90469b284ad6c07bdd6320 Mon Sep 17 00:00:00 2001 From: Nitesh Konkar Date: Tue, 24 Jan 2017 14:42:03 +0530 Subject: [PATCH] perf: Prevent enabling of already enabled perf event Currently, on every --enable perf_event command, a new event->fd is created and counting of perf event counter starts from zero and previous event->fd is lost. This patch prevents this behaviour. Signed-off-by: Nitesh Konkar --- src/util/virperf.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/util/virperf.c b/src/util/virperf.c index f64692bf39..4493608a0f 100644 --- a/src/util/virperf.c +++ b/src/util/virperf.c @@ -198,6 +198,9 @@ virPerfEventEnable(virPerfPtr perf, if (!event || !event_attr) return -1; + if (event->enabled) + return 0; + if (event_attr->attrType == 0 && (type == VIR_PERF_EVENT_CMT || type == VIR_PERF_EVENT_MBMT || type == VIR_PERF_EVENT_MBML)) {