[PATCH] util: Quiet the logging if perf file doesn't exist

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Commit id 'b00d7f29' shifted the opening of the /sys/devices/intel_cqm/type
file from event enable to perf event initialization. If the file did not
exist, then an error would be written to the domain log:

2016-09-06 20:51:21.677+0000: 7310: error : virFileReadAll:1360 : Failed to open file '/sys/devices/intel_cqm/type': No such file or directory

Since the error is now handled in virPerfEventEnable by checking if the
event_attr->attrType == 0 for CMT, MBML, and MBMT events - we can just
use the Quiet API in order to not log the error we're going to throw away.

Additionally, rather than using virReportSystemError, use virReportError
and VIR_ERR_ARGUMENT_UNSUPPORTED in order to signify that support isn't there
for that type of perf event - adjust the error message as well.

Signed-off-by: John Ferlan <jferlan@xxxxxxxxxx>
---
 src/util/virperf.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/src/util/virperf.c b/src/util/virperf.c
index cd66b05..a65a4bf 100644
--- a/src/util/virperf.c
+++ b/src/util/virperf.c
@@ -116,7 +116,7 @@ virPerfRdtAttrInit(void)
     char *tmp = NULL;
     unsigned int attr_type = 0;
 
-    if (virFileReadAll("/sys/devices/intel_cqm/type", 10, &buf) < 0)
+    if (virFileReadAllQuiet("/sys/devices/intel_cqm/type", 10, &buf) < 0)
         goto error;
 
     if ((tmp = strchr(buf, '\n')))
@@ -174,9 +174,9 @@ virPerfEventEnable(virPerfPtr perf,
     if (event_attr->attrType == 0 && (type == VIR_PERF_EVENT_CMT ||
                                        type == VIR_PERF_EVENT_MBMT ||
                                        type == VIR_PERF_EVENT_MBML)) {
-        virReportSystemError(errno,
-                             _("Unable to open perf event for %s"),
-                             virPerfEventTypeToString(event->type));
+        virReportError(VIR_ERR_ARGUMENT_UNSUPPORTED,
+                       _("unable to enable perf event for %s"),
+                       virPerfEventTypeToString(event->type));
         return -1;
     }
 
-- 
2.7.4

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]