[libvirt] [PATCH] Make use of PERF_COUNT_HW_REF_CPU_CYCLES conditional

Olaf Hering olaf at aepfle.de
Wed Mar 8 18:00:21 UTC 2017


On Fri, Dec 16, Daniel P. Berrange wrote:

> The PERF_COUNT_HW_REF_CPU_CYCLES constant is not available
> on all Linux distros libvirt targets, so its use must be
> made conditional. Other constant have existed long enough
> that we can assume they exist, as we don't support very
> old distros like RHEL-5 any more.

> +# ifdef PERF_COUNT_HW_REF_CPU_CYCLES

How can this fix the error?
This and PERF_COUNT_HW_STALLED_CYCLES_FRONTEND/BACKEND are part of an
'enum', which is ordinary code for cpp. Unfortunately this is correct
because the code is written in C, not CPP.

I will deal with the compile errors like that:

Index: libvirt-20170308T173307.d7dcea6/src/util/virperf.c
===================================================================
--- libvirt-20170308T173307.d7dcea6.orig/src/util/virperf.c
+++ libvirt-20170308T173307.d7dcea6/src/util/virperf.c
@@ -76,6 +76,12 @@ struct virPerfEventAttr {
     unsigned long long attrConfig;
 };
 
+#ifndef PERF_ATTR_SIZE_VER2
+#define PERF_COUNT_HW_STALLED_CYCLES_FRONTEND   7
+#define PERF_COUNT_HW_STALLED_CYCLES_BACKEND    8
+#define PERF_COUNT_HW_REF_CPU_CYCLES            9
+#endif
+
 static struct virPerfEventAttr attrs[] = {
     {.type = VIR_PERF_EVENT_CMT, .attrType = 0, .attrConfig = 1},
     {.type = VIR_PERF_EVENT_MBMT, .attrType = 0, .attrConfig = 2},


Olaf
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 195 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20170308/204e370d/attachment-0001.sig>


More information about the libvir-list mailing list