]> xenbits.xensource.com Git - libvirt.git/commitdiff
util: Quiet the logging if perf file doesn't exist
authorJohn Ferlan <jferlan@redhat.com>
Tue, 6 Sep 2016 21:20:30 +0000 (17:20 -0400)
committerJohn Ferlan <jferlan@redhat.com>
Mon, 12 Sep 2016 10:53:48 +0000 (06:53 -0400)
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.

src/util/virperf.c

index cd66b05ad424a2a6395a146a0a62e0ccb859d3da..a65a4bfefa5759951489b323ef94c678272e32a8 100644 (file)
@@ -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;
     }