[virt-tools-list] [vhostmd 2/3] Remove support for libxenstat

Jim Fehlig jfehlig at suse.com
Wed Jun 6 21:22:30 UTC 2018


Old, crufty code that no longer compiles and should be
removed from the sources. libvirt or custom "actions"
should be used to gather metrics.

Signed-off-by: Jim Fehlig <jfehlig at suse.com>
---
 configure.ac          |  12 -----
 include/metric.h      |   4 --
 vhostmd/Makefile.am   |   5 --
 vhostmd/vhostmd.c     |   6 ---
 vhostmd/xen-metrics.c | 123 --------------------------------------------------
 5 files changed, 150 deletions(-)

diff --git a/configure.ac b/configure.ac
index 65e463a..09ba60f 100644
--- a/configure.ac
+++ b/configure.ac
@@ -39,18 +39,6 @@ AC_ARG_ENABLE([debug],
          CFLAGS="$CFLAGS $DEBUG_CFLAGS"
   ])
 
-# Add a configure argument to support using xen library, libxenstat 
-AC_ARG_ENABLE([libxenstat],
-[  --enable-libxenstat     enable libxenstat usage],
-  [case "${enableval}" in
-   yes) libxenstat=true 
-        CFLAGS="$CFLAGS -DLIBXENSTAT"
-        ;;
-   no) libxenstat=false ;;
-   *) AC_MSG_ERROR(bad value ${enableval} for --enable-libxenstat) ;;
-  esac],[AC_CHECK_HEADER(xenstat.h, libxenstat=true, libxenstat=false)])
-AM_CONDITIONAL(LIBXENSTAT, test x$libxenstat = xtrue)
-
 PKG_CHECK_MODULES([LIBVIRT], [libvirt])
 
 # Configure argument to support using xenstore
diff --git a/include/metric.h b/include/metric.h
index 6c8432e..cc82366 100644
--- a/include/metric.h
+++ b/include/metric.h
@@ -71,10 +71,6 @@ int metric_value_get(metric *def);
 
 int metric_xml(metric *m, vu_buffer *buf);
 
-#ifdef LIBXENSTAT
-int xen_metrics(metric **user_metrics);
-#endif
-
 #ifdef WITH_XENSTORE
 int metrics_xenstore_update(char *buffer, int *ids, int num_vms);
 #endif
diff --git a/vhostmd/Makefile.am b/vhostmd/Makefile.am
index 659a0ce..3585970 100644
--- a/vhostmd/Makefile.am
+++ b/vhostmd/Makefile.am
@@ -12,11 +12,6 @@ vhostmd_SOURCES += xenstore-update.c
 vhostmd_LDADD += -lxenstore
 endif
 
-if LIBXENSTAT
-vhostmd_SOURCES += xen-metrics.c
-vhostmd_LDADD += ../xenstat/libxenstat/src/libxenstat.a
-endif
-
 valgrind:
 	$(MAKE) CHECKER='valgrind --quiet --leak-check=full --suppressions=$(srcdir)/.valgrind.supp' tests
 
diff --git a/vhostmd/vhostmd.c b/vhostmd/vhostmd.c
index e2e91f6..7f04705 100644
--- a/vhostmd/vhostmd.c
+++ b/vhostmd/vhostmd.c
@@ -1077,12 +1077,6 @@ int main(int argc, char *argv[])
       goto out;
    }
 
-#ifdef LIBXENSTAT
-   if (xen_metrics(&metrics)) {
-      vu_log(VHOSTMD_ERR, "Unable to load xen specific metrics, ignoring");
-   }
-#endif
-      
    if ((mdisk_fd = metrics_disk_create()) < 0) {
       vu_log(VHOSTMD_ERR, "Failed to create metrics disk %s", mdisk_path);
       goto out;
diff --git a/vhostmd/xen-metrics.c b/vhostmd/xen-metrics.c
deleted file mode 100644
index 94f7dea..0000000
--- a/vhostmd/xen-metrics.c
+++ /dev/null
@@ -1,123 +0,0 @@
-/*
- * Copyright (C) 2008 Novell, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
- *
- * Author: Pat Campbell <plc at novell.com>
- */
-
-#include <config.h>
-
-#include <stdio.h>
-#include <stdarg.h>
-#include <stdlib.h>
-#include <string.h>
-#include <strings.h>
-
-#include "util.h"
-#include "metric.h"
-
-#include "xenstat.h"
-
-static xenstat_handle *xhandle = NULL;
-static xenstat_node *cur_node = NULL;
-
-int node_tot_mem(void *vp) {
-	metric *m = vp;
-
-	cur_node = xenstat_get_node(xhandle, XENSTAT_ALL);
-	if (cur_node == NULL) {
-		vu_log(VHOSTMD_WARN, "Failed to retrieve statistics from libxenstat\n");
-		return -1;
-	}
-	m->value.r32 = xenstat_node_tot_mem(cur_node);
-	xenstat_free_node(cur_node);
-	return 0;
-}
-
-int func_str_test(void *vp) {
-	metric *m = vp;
-	int len = 0;
-	char value[] = "func_str_test";
-
-	if (m->value.str) {
-		len = strlen(m->value.str);
-		m->value.str[0] = '\0';
-		if (strlen(value) > len)
-			m->value.str = realloc(m->value.str, strlen(value) + 1);
-	}
-	else
-		m->value.str = calloc(1, strlen(value) + 1);
-	if (m->value.str == NULL)
-		goto out;
-	sprintf(m->value.str, "%s", value);
-out:
-	return 0;
-}
-
-
-metric m[] = {
-	{   "test",
-		NULL,
-		M_STRING,
-		METRIC_CONTEXT_HOST,
-		func_str_test,
-		0,
-		NULL
-	},
-	{   "node_tot_mem",
-		NULL,
-		M_REAL32,
-		METRIC_CONTEXT_HOST,
-		node_tot_mem,
-		0,
-		NULL
-	},
-	{   "pages paged out",
-		"vmstat -s |grep \"pages paged out\" | awk '{print $1}'",
-		M_UINT32,
-		METRIC_CONTEXT_HOST,
-		NULL,
-		0,
-		NULL
-	}
-};
-
-
-int xen_metrics(metric **user_metrics) {
-	int i;
-	metric *mdef;
-	metric *metrics = *user_metrics;
-
-	xhandle = xenstat_init();
-	if (xhandle == NULL) {
-		vu_log(VHOSTMD_WARN, "Failed to initialize xenstat library\n");
-		return -1;
-	}
-
-	for (i = 0; i < sizeof(m)/sizeof(metric); i++) {
-		mdef = calloc(sizeof(metric), 1);
-		if (mdef) {
-			memcpy(mdef,&m[i], sizeof(metric));
-			mdef->next = metrics;
-			metrics = mdef;
-		}
-		else {
-			vu_log(VHOSTMD_WARN, "Unable to allocate metric node, ignoring ...");
-		}
-	}
-	*user_metrics = metrics;
-	return 0;
-}
-- 
2.16.3




More information about the virt-tools-list mailing list