[libvirt] [PATCH] perf: Prevent enabling of already enabled perf event

Nitesh Konkar niteshkonkar.libvirt at gmail.com
Tue Jan 24 09:12:03 UTC 2017


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 <nitkon12 at linux.vnet.ibm.com>
---
 src/util/virperf.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/src/util/virperf.c b/src/util/virperf.c
index 788b817..57c2081 100644
--- a/src/util/virperf.c
+++ b/src/util/virperf.c
@@ -230,6 +230,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)) {
-- 
1.9.3




More information about the libvir-list mailing list