]> xenbits.xensource.com Git - libvirt.git/commitdiff
perf: Prevent enabling of already enabled perf event
authorNitesh Konkar <niteshkonkar.libvirt@gmail.com>
Tue, 24 Jan 2017 09:12:03 +0000 (14:42 +0530)
committerJohn Ferlan <jferlan@redhat.com>
Thu, 26 Jan 2017 20:13:58 +0000 (15:13 -0500)
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@linux.vnet.ibm.com>
src/util/virperf.c

index f64692bf39c49ec9edacbd40e8411ec3a898ebed..4493608a0f16e5e66119408905b5f50be8efb015 100644 (file)
@@ -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)) {