From 31116639d6a9f9fd731502150207371b892dc4e6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20Van=C4=9Bk?= Date: Tue, 22 Oct 2019 16:29:03 +0200 Subject: [PATCH] xenstat.plugin: check xenstat_vbd_error presence (#7103) The xenstat_vbd_error function is going to be part of the xen 4.13 release. The workaround here is to check if the function is already present in configuration phase and set vbd_m->error always to 0 if xenstat_vbd_error does not exist. --- collectors/xenstat.plugin/xenstat_plugin.c | 4 ++++ configure.ac | 16 ++++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/collectors/xenstat.plugin/xenstat_plugin.c b/collectors/xenstat.plugin/xenstat_plugin.c index 873b818041..fadd218c55 100644 --- a/collectors/xenstat.plugin/xenstat_plugin.c +++ b/collectors/xenstat.plugin/xenstat_plugin.c @@ -333,7 +333,11 @@ static int vbd_metrics_collect(struct domain_metrics *d, xenstat_domain *domain) return 1; } +#ifdef HAVE_XENSTAT_VBD_ERROR vbd_m->error = xenstat_vbd_error(vbd); +#else + vbd_m->error = 0; +#endif vbd_m->oo_reqs = xenstat_vbd_oo_reqs(vbd); vbd_m->rd_reqs = xenstat_vbd_rd_reqs(vbd); vbd_m->wr_reqs = xenstat_vbd_wr_reqs(vbd); diff --git a/configure.ac b/configure.ac index ea91a72991..35147b0e92 100644 --- a/configure.ac +++ b/configure.ac @@ -748,6 +748,22 @@ fi AC_MSG_RESULT([${enable_plugin_xenstat}]) AM_CONDITIONAL([ENABLE_PLUGIN_XENSTAT], [test "${enable_plugin_xenstat}" = "yes"]) +if test "${enable_plugin_xenstat}" == "yes"; then + AC_MSG_CHECKING([for xenstat_vbd_error in -lxenstat]) + AC_TRY_LINK( + [ #include ], + [ + xenstat_vbd * vbd; + int out = xenstat_vbd_error(vbd); + ], + [ + have_xenstat_vbd_error=yes + AC_DEFINE([HAVE_XENSTAT_VBD_ERROR], [1], [xenstat_vbd_error usability]) + ], + [ have_xenstat_vbd_error=no ] + ) + AC_MSG_RESULT([${have_xenstat_vbd_error}]) +fi # ----------------------------------------------------------------------------- # perf.plugin