import vhostmd-0.5-18.el8
This commit is contained in:
commit
6846dd3d32
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
SOURCES/vhostmd-0.5.tar.bz2
|
||||
1
.vhostmd.metadata
Normal file
1
.vhostmd.metadata
Normal file
@ -0,0 +1 @@
|
||||
b2512846366f6b6881bd19cd450ad994b05860e0 SOURCES/vhostmd-0.5.tar.bz2
|
||||
@ -0,0 +1,40 @@
|
||||
From 8684995d87e08fadd44e1814e810c770a1f60273 Mon Sep 17 00:00:00 2001
|
||||
From: "Richard W.M. Jones" <rjones@redhat.com>
|
||||
Date: Mon, 5 Mar 2012 14:48:08 +0000
|
||||
Subject: [PATCH 01/17] Security: Set supplemental groups correctly when
|
||||
dropping privileges.
|
||||
|
||||
https://bugzilla.redhat.com/show_bug.cgi?id=741289
|
||||
|
||||
(Thanks to Steve Grubb for finding the bug and suggesting a fix)
|
||||
---
|
||||
vhostmd/vhostmd.c | 6 ++++++
|
||||
1 file changed, 6 insertions(+)
|
||||
|
||||
diff --git a/vhostmd/vhostmd.c b/vhostmd/vhostmd.c
|
||||
index 21763af..90ba76d 100644
|
||||
--- a/vhostmd/vhostmd.c
|
||||
+++ b/vhostmd/vhostmd.c
|
||||
@@ -34,6 +34,7 @@
|
||||
#include <getopt.h>
|
||||
#include <signal.h>
|
||||
#include <pwd.h>
|
||||
+#include <grp.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/wait.h>
|
||||
@@ -1115,6 +1116,11 @@ int main(int argc, char *argv[])
|
||||
goto out;
|
||||
}
|
||||
|
||||
+ if (initgroups (user, pw->pw_gid) == -1) {
|
||||
+ vu_log (VHOSTMD_ERR, "initgroups: %m");
|
||||
+ goto out;
|
||||
+ }
|
||||
+
|
||||
if (setuid (pw->pw_uid) == -1) {
|
||||
vu_log (VHOSTMD_ERR, "setuid: %d: %m", pw->pw_uid);
|
||||
goto out;
|
||||
--
|
||||
2.19.0.rc0
|
||||
|
||||
@ -0,0 +1,29 @@
|
||||
From efba4feaef25ea7efc9e35cfa6e92b69784aa88f Mon Sep 17 00:00:00 2001
|
||||
From: "Richard W.M. Jones" <rjones@redhat.com>
|
||||
Date: Thu, 10 May 2012 10:14:50 +0100
|
||||
Subject: [PATCH 02/17] libmetrics: Return error indication up through
|
||||
get_metric.
|
||||
|
||||
If private function 'get_mdef' returns an error, then the error is not
|
||||
propagated back to the user because it gets lost in 'get_metric'. Fix
|
||||
this by initializing 'ret' correctly.
|
||||
---
|
||||
libmetrics/libmetrics.c | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/libmetrics/libmetrics.c b/libmetrics/libmetrics.c
|
||||
index d049458..6d5c26f 100644
|
||||
--- a/libmetrics/libmetrics.c
|
||||
+++ b/libmetrics/libmetrics.c
|
||||
@@ -571,7 +571,7 @@ int get_metric(const char *metric_name, metric **mdef, metric_context context)
|
||||
metric *lmdef;
|
||||
uint32_t sum;
|
||||
int extra_len = 0;
|
||||
- int ret = 0;
|
||||
+ int ret = -1;
|
||||
|
||||
*mdef = NULL;
|
||||
|
||||
--
|
||||
2.19.0.rc0
|
||||
|
||||
51
SOURCES/0003-Make-Xen-Libraries-really-optional.patch
Normal file
51
SOURCES/0003-Make-Xen-Libraries-really-optional.patch
Normal file
@ -0,0 +1,51 @@
|
||||
From 8fd4d847277bb9a7e53f8bb3f3f935004d8e5cc4 Mon Sep 17 00:00:00 2001
|
||||
From: Eduardo Otubo <eduardo.otubo@gmail.com>
|
||||
Date: Thu, 2 Aug 2012 19:42:00 -0300
|
||||
Subject: [PATCH 03/17] Make Xen Libraries really optional
|
||||
|
||||
The default behavior in the configure script was to make with_xenstore
|
||||
set to 'true', which caused the compilation to break in my case because
|
||||
I don't have xen libraries, therefore, xs.h
|
||||
|
||||
Now the default behavior is set according to its existence or not. Same
|
||||
thing for xenstat and xenctrl.
|
||||
|
||||
Signed-off-by: Eduardo Otubo <eduardo.otubo@gmail.com>
|
||||
---
|
||||
configure.ac | 6 +++---
|
||||
1 file changed, 3 insertions(+), 3 deletions(-)
|
||||
|
||||
diff --git a/configure.ac b/configure.ac
|
||||
index ee9c446..fb4309b 100644
|
||||
--- a/configure.ac
|
||||
+++ b/configure.ac
|
||||
@@ -48,7 +48,7 @@ AC_ARG_ENABLE([libxenstat],
|
||||
;;
|
||||
no) libxenstat=false ;;
|
||||
*) AC_MSG_ERROR(bad value ${enableval} for --enable-libxenstat) ;;
|
||||
- esac],[libxenstat=false])
|
||||
+ esac],[AC_CHECK_HEADER(xenstat.h, libxenstat=true, libxenstat=false)])
|
||||
AM_CONDITIONAL(LIBXENSTAT, test x$libxenstat = xtrue)
|
||||
|
||||
# Configure argument to support using xenctrl library for vm enumeration
|
||||
@@ -60,7 +60,7 @@ AC_ARG_ENABLE([xenctrl],
|
||||
;;
|
||||
no) xenctrl=false ;;
|
||||
*) AC_MSG_ERROR(bad value ${enableval} for --enable-xenctrl) ;;
|
||||
- esac],[xenctrl=false])
|
||||
+ esac],[AC_CHECK_HEADER(xenctrl.h, xenctrl=true, xenctrl=false,)])
|
||||
AM_CONDITIONAL(XENCTRL, test x$xenctrl = xtrue)
|
||||
|
||||
libvirt=false
|
||||
@@ -79,7 +79,7 @@ AC_ARG_WITH([xenstore],
|
||||
yes) with_xenstore=true;;
|
||||
no) with_xenstore=false;;
|
||||
*) AC_MSG_ERROR(bad value ${withval} for --with-xenstore) ;;
|
||||
- esac],[with_xenstore=true])
|
||||
+ esac],[AC_CHECK_HEADER(xs.h, with_xenstore=true)])
|
||||
AM_CONDITIONAL(WITH_XENSTORE, test x$with_xenstore = xtrue)
|
||||
|
||||
AC_OUTPUT(vhostmd/Makefile
|
||||
--
|
||||
2.19.0.rc0
|
||||
|
||||
34
SOURCES/0004-Add-contact-info-to-README.patch
Normal file
34
SOURCES/0004-Add-contact-info-to-README.patch
Normal file
@ -0,0 +1,34 @@
|
||||
From 7a2936ec4e6bd5a47ef8ac4f4b889c70b8a78e9b Mon Sep 17 00:00:00 2001
|
||||
From: Jim Fehlig <jfehlig@suse.com>
|
||||
Date: Wed, 9 Mar 2016 18:40:56 -0700
|
||||
Subject: [PATCH 04/17] Add contact info to README
|
||||
|
||||
Extended README with contact info (virt-tools-list) for
|
||||
comments, suggestions, and patches.
|
||||
---
|
||||
README | 9 +++++++++
|
||||
1 file changed, 9 insertions(+)
|
||||
|
||||
diff --git a/README b/README
|
||||
index 2755e4f..788ffe4 100644
|
||||
--- a/README
|
||||
+++ b/README
|
||||
@@ -15,6 +15,15 @@ surfaced read-only to virtual machines using tools provided by the host's
|
||||
virtualization platform.
|
||||
|
||||
|
||||
+Contact
|
||||
+-------
|
||||
+
|
||||
+All comments / suggestions / patches should be directed to the
|
||||
+virt-tools-list mailing list:
|
||||
+
|
||||
+ http://www.redhat.com/mailman/listinfo/virt-tools-list
|
||||
+
|
||||
+
|
||||
Usage
|
||||
-----
|
||||
|
||||
--
|
||||
2.19.0.rc0
|
||||
|
||||
@ -0,0 +1,41 @@
|
||||
From 972ac212abcf0eacd7039b3a5987bd9ae2083607 Mon Sep 17 00:00:00 2001
|
||||
From: "Richard W.M. Jones" <rjones@redhat.com>
|
||||
Date: Wed, 22 Feb 2017 11:39:59 +0000
|
||||
Subject: [PATCH 05/17] Fix name and location of the vhostmd.conf file.
|
||||
|
||||
Thanks: Xianghua Chen
|
||||
Bug: https://bugzilla.redhat.com/show_bug.cgi?id=1359593
|
||||
---
|
||||
README | 2 +-
|
||||
docs/man/vhostmd.8 | 2 +-
|
||||
2 files changed, 2 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/README b/README
|
||||
index 788ffe4..cb23226 100644
|
||||
--- a/README
|
||||
+++ b/README
|
||||
@@ -32,7 +32,7 @@ vhostmd [options]
|
||||
Options:
|
||||
-v | --verbose Verbose messages
|
||||
-d | --no-daemonize Process will not daemonize
|
||||
- -f | --config <file> Configuration file (/etc/vhostmd.xml default)
|
||||
+ -f | --config <file> Configuration file (/etc/vhostmd/vhostmd.conf default)
|
||||
-p | --pid-file <file> PID file (/var/run/vhostmd.pid default)
|
||||
|
||||
|
||||
diff --git a/docs/man/vhostmd.8 b/docs/man/vhostmd.8
|
||||
index dfcb301..2c73adc 100644
|
||||
--- a/docs/man/vhostmd.8
|
||||
+++ b/docs/man/vhostmd.8
|
||||
@@ -32,7 +32,7 @@ Drop root privileges and run as the named non-root user.
|
||||
Specify an alternate path for vhostmd to record its process-id in. Normally /var/run/vhostmd.pid
|
||||
.TP
|
||||
.B \-f, --config <file>
|
||||
-Specify a different configuration file. Normally /etc/vhostmd.xml
|
||||
+Specify a different configuration file. Normally /etc/vhostmd/vhostmd.conf
|
||||
.SH CONFIG FILE
|
||||
At startup, vhostmd reads
|
||||
.I /etc/vhostmd/vhostmd.conf,
|
||||
--
|
||||
2.19.0.rc0
|
||||
|
||||
25
SOURCES/0006-fix-typo-in-vhostmd.init-virutalization.patch
Normal file
25
SOURCES/0006-fix-typo-in-vhostmd.init-virutalization.patch
Normal file
@ -0,0 +1,25 @@
|
||||
From 3e4df5dd16c59a804373564602aa045b0599aa82 Mon Sep 17 00:00:00 2001
|
||||
From: Johannes Kastl <kastl@b1-systems.de>
|
||||
Date: Sun, 6 May 2018 16:23:05 +0200
|
||||
Subject: [PATCH 06/17] fix typo in vhostmd.init: virutalization
|
||||
|
||||
---
|
||||
vhostmd.init | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/vhostmd.init b/vhostmd.init
|
||||
index 71f9ab8..23d7874 100644
|
||||
--- a/vhostmd.init
|
||||
+++ b/vhostmd.init
|
||||
@@ -11,7 +11,7 @@
|
||||
# Required-Stop: $remote_fs $null
|
||||
# Should-Stop: $null
|
||||
# Default-Stop: 0 1 2 4 6
|
||||
-# Short-Description: daemon for collecting virutalization host metrics
|
||||
+# Short-Description: daemon for collecting virtualization host metrics
|
||||
# Description: This is a daemon for collecting virtualization host
|
||||
# metrics and writing them to a file-backed disk.
|
||||
### END INIT INFO
|
||||
--
|
||||
2.19.0.rc0
|
||||
|
||||
61
SOURCES/0007-Modernize-build-files.patch
Normal file
61
SOURCES/0007-Modernize-build-files.patch
Normal file
@ -0,0 +1,61 @@
|
||||
From 498bace866c16842d677a00b1df8ab62e0724d55 Mon Sep 17 00:00:00 2001
|
||||
From: Jim Fehlig <jfehlig@suse.com>
|
||||
Date: Thu, 27 Apr 2017 09:36:28 -0600
|
||||
Subject: [PATCH 07/17] Modernize build files
|
||||
|
||||
Some of the constructs used in the configure script and Makefiles
|
||||
are a bit outdated, e.g. use of '$(mkinstalldirs)' instead of
|
||||
'$(MKDIR_P)'. Change these old constructs to their modern counterparts.
|
||||
|
||||
Signed-off-by: Jim Fehlig <jfehlig@suse.com>
|
||||
---
|
||||
Makefile.am | 15 +++++++--------
|
||||
configure.ac | 2 +-
|
||||
2 files changed, 8 insertions(+), 9 deletions(-)
|
||||
|
||||
diff --git a/Makefile.am b/Makefile.am
|
||||
index e11963a..8234d98 100644
|
||||
--- a/Makefile.am
|
||||
+++ b/Makefile.am
|
||||
@@ -8,11 +8,10 @@ EXTRA_DIST = $(doc_DATA) vhostmd.init vhostmd.spec autogen.sh
|
||||
AUTOMAKE_OPTIONS=dist-bzip2
|
||||
|
||||
install-data-local:
|
||||
- $(mkinstalldirs) $(DESTDIR)/etc/vhostmd
|
||||
- $(mkinstalldirs) $(DESTDIR)/etc/init.d
|
||||
- $(mkinstalldirs) $(DESTDIR)/usr/sbin
|
||||
- -@INSTALL@ -m 0644 $(srcdir)/vhostmd.xml $(DESTDIR)/etc/vhostmd/vhostmd.conf
|
||||
- -@INSTALL@ -m 0644 $(srcdir)/vhostmd.dtd $(DESTDIR)/etc/vhostmd
|
||||
- -@INSTALL@ -m 0644 $(srcdir)/metric.dtd $(DESTDIR)/etc/vhostmd
|
||||
- -@INSTALL@ -m 0755 $(srcdir)/vhostmd.init $(DESTDIR)/etc/init.d/vhostmd
|
||||
-
|
||||
+ $(MKDIR_P) $(DESTDIR)/etc/vhostmd
|
||||
+ $(MKDIR_P) $(DESTDIR)/etc/init.d
|
||||
+ $(MKDIR_P) $(DESTDIR)/usr/sbin
|
||||
+ $(INSTALL_DATA) $(srcdir)/vhostmd.xml $(DESTDIR)/etc/vhostmd/vhostmd.conf
|
||||
+ $(INSTALL_DATA) $(srcdir)/vhostmd.dtd $(DESTDIR)/etc/vhostmd
|
||||
+ $(INSTALL_DATA) $(srcdir)/metric.dtd $(DESTDIR)/etc/vhostmd
|
||||
+ $(INSTALL_SCRIPT) $(srcdir)/vhostmd.init $(DESTDIR)/etc/init.d/vhostmd
|
||||
diff --git a/configure.ac b/configure.ac
|
||||
index fb4309b..27c8488 100644
|
||||
--- a/configure.ac
|
||||
+++ b/configure.ac
|
||||
@@ -4,6 +4,7 @@ AC_CONFIG_SRCDIR(vhostmd/vhostmd.c)
|
||||
AC_CONFIG_HEADERS([config.h])
|
||||
|
||||
AC_GNU_SOURCE
|
||||
+AM_INIT_AUTOMAKE
|
||||
|
||||
AC_PROG_LIBTOOL
|
||||
|
||||
@@ -21,7 +22,6 @@ AC_SUBST(topdir)
|
||||
|
||||
AC_CONFIG_FILES([Makefile])
|
||||
|
||||
-AM_INIT_AUTOMAKE
|
||||
|
||||
# Checks for programs.
|
||||
AM_PROG_CC_C_O
|
||||
--
|
||||
2.19.0.rc0
|
||||
|
||||
128
SOURCES/0008-Add-systemd-service-file.patch
Normal file
128
SOURCES/0008-Add-systemd-service-file.patch
Normal file
@ -0,0 +1,128 @@
|
||||
From d12766463a9de3b8490e6a552db83bf7d4853896 Mon Sep 17 00:00:00 2001
|
||||
From: Jim Fehlig <jfehlig@suse.com>
|
||||
Date: Thu, 27 Apr 2017 09:52:02 -0600
|
||||
Subject: [PATCH 08/17] Add systemd service file
|
||||
|
||||
vhostmd is long overdue for a systemd service file. Add one, and
|
||||
while at it support specifying the type of init system in the
|
||||
configure script.
|
||||
|
||||
Signed-off-by: Jim Fehlig <jfehlig@suse.com>
|
||||
---
|
||||
Makefile.am | 36 +++++++++++++++++++++++++++++++++---
|
||||
configure.ac | 24 +++++++++++++++++++++++-
|
||||
vhostmd.service | 14 ++++++++++++++
|
||||
3 files changed, 70 insertions(+), 4 deletions(-)
|
||||
create mode 100644 vhostmd.service
|
||||
|
||||
diff --git a/Makefile.am b/Makefile.am
|
||||
index 8234d98..4f8af15 100644
|
||||
--- a/Makefile.am
|
||||
+++ b/Makefile.am
|
||||
@@ -7,11 +7,41 @@ EXTRA_DIST = $(doc_DATA) vhostmd.init vhostmd.spec autogen.sh
|
||||
|
||||
AUTOMAKE_OPTIONS=dist-bzip2
|
||||
|
||||
-install-data-local:
|
||||
+install-data-local: install-init-systemv install-init-systemd
|
||||
$(MKDIR_P) $(DESTDIR)/etc/vhostmd
|
||||
- $(MKDIR_P) $(DESTDIR)/etc/init.d
|
||||
- $(MKDIR_P) $(DESTDIR)/usr/sbin
|
||||
$(INSTALL_DATA) $(srcdir)/vhostmd.xml $(DESTDIR)/etc/vhostmd/vhostmd.conf
|
||||
$(INSTALL_DATA) $(srcdir)/vhostmd.dtd $(DESTDIR)/etc/vhostmd
|
||||
$(INSTALL_DATA) $(srcdir)/metric.dtd $(DESTDIR)/etc/vhostmd
|
||||
+
|
||||
+uninstall-local: uninstall-init-systemv uninstall-init-systemd
|
||||
+ rm -f $(DESTDIR)/etc/vhostmd/vhostmd.conf
|
||||
+ rm -f $(DESTDIR)/etc/vhostmd/vhostmd.dtd
|
||||
+ rm -f $(DESTDIR)/etc/vhostmd/metric.dtd
|
||||
+ rmdir $(DESTDIR)/etc/vhostmd || :
|
||||
+
|
||||
+if INIT_SCRIPT_SYSTEMV
|
||||
+install-init-systemv: $(srcdir)/vhostmd.init
|
||||
+ $(MKDIR_P) $(DESTDIR)$(sysconfdir)/init.d
|
||||
$(INSTALL_SCRIPT) $(srcdir)/vhostmd.init $(DESTDIR)/etc/init.d/vhostmd
|
||||
+
|
||||
+uninstall-init-systemv:
|
||||
+ rm -f $(DESTDIR)$(sysconfdir)/init.d/vhostmd
|
||||
+ rmdir $(DESTDIR)$(sysconfdir)/init.d || :
|
||||
+else ! INIT_SCRIPT_SYSTEMV
|
||||
+install-init-systemv:
|
||||
+uninstall-init-systemv:
|
||||
+endif ! INIT_SCRIPT_SYSTEMV
|
||||
+
|
||||
+if INIT_SCRIPT_SYSTEMD
|
||||
+SYSTEMD_UNIT_DIR = $(prefix)/lib/systemd/system
|
||||
+install-init-systemd: $(srcdir)/vhostmd.service
|
||||
+ $(MKDIR_P) $(DESTDIR)$(SYSTEMD_UNIT_DIR)
|
||||
+ $(INSTALL_DATA) $(srcdir)/vhostmd.service $(DESTDIR)$(SYSTEMD_UNIT_DIR)/vhostmd.service
|
||||
+
|
||||
+uninstall-init-systemd:
|
||||
+ rm -f $(DESTDIR)$(SYSTEMD_UNIT_DIR)/vhostmd.service
|
||||
+ rmdir $(DESTDIR)$(SYSTEMD_UNIT_DIR) || :
|
||||
+else ! INIT_SCRIPT_SYSTEMD
|
||||
+install-init-systemd:
|
||||
+uninstall-init-systemd:
|
||||
+endif ! INIT_SCRIPT_SYSTEMD
|
||||
diff --git a/configure.ac b/configure.ac
|
||||
index 27c8488..b0a07c7 100644
|
||||
--- a/configure.ac
|
||||
+++ b/configure.ac
|
||||
@@ -1,4 +1,4 @@
|
||||
-AC_INIT(Virtual Host Metrics Daemon, 0.5, jfehlig@novell.com, vhostmd)
|
||||
+AC_INIT(Virtual Host Metrics Daemon, 0.5, jfehlig@suse.com, vhostmd)
|
||||
|
||||
AC_CONFIG_SRCDIR(vhostmd/vhostmd.c)
|
||||
AC_CONFIG_HEADERS([config.h])
|
||||
@@ -82,6 +82,28 @@ AC_ARG_WITH([xenstore],
|
||||
esac],[AC_CHECK_HEADER(xs.h, with_xenstore=true)])
|
||||
AM_CONDITIONAL(WITH_XENSTORE, test x$with_xenstore = xtrue)
|
||||
|
||||
+# Configure argument to support type of init system
|
||||
+AC_ARG_WITH([init_script],
|
||||
+ [AS_HELP_STRING([--with-init-script],
|
||||
+ [Type of init script to install: systemv, systemd, check @<:@default=check@:>@])],
|
||||
+ [],
|
||||
+ [with_init_script=check])
|
||||
+init_systemv=no
|
||||
+init_systemd=no
|
||||
+if test "$with_init_script" = check && type systemctl >/dev/null 2>&1; then
|
||||
+ init_systemd=yes
|
||||
+else
|
||||
+ init_systemv=yes
|
||||
+fi
|
||||
+case "${with_init_script}" in
|
||||
+ systemv) init_systemv=yes;;
|
||||
+ systemd) init_systemd=yes;;
|
||||
+ check) ;;
|
||||
+ *) AC_MSG_ERROR([Unknown initscript type $with_init_script]);;
|
||||
+esac
|
||||
+AM_CONDITIONAL([INIT_SCRIPT_SYSTEMV], test "$init_systemv" = "yes")
|
||||
+AM_CONDITIONAL([INIT_SCRIPT_SYSTEMD], test "$init_systemd" = "yes")
|
||||
+
|
||||
AC_OUTPUT(vhostmd/Makefile
|
||||
include/Makefile
|
||||
libmetrics/Makefile
|
||||
diff --git a/vhostmd.service b/vhostmd.service
|
||||
new file mode 100644
|
||||
index 0000000..9d50523
|
||||
--- /dev/null
|
||||
+++ b/vhostmd.service
|
||||
@@ -0,0 +1,14 @@
|
||||
+[Unit]
|
||||
+Description=Daemon for collecting virutalization host metrics
|
||||
+After=libvirtd.service
|
||||
+Documentation=man:vhostmd(8)
|
||||
+
|
||||
+[Service]
|
||||
+Type=forking
|
||||
+ExecStart=/usr/sbin/vhostmd
|
||||
+ExecReload=/bin/kill -HUP $MAINPID
|
||||
+KillMode=process
|
||||
+Restart=on-failure
|
||||
+
|
||||
+[Install]
|
||||
+WantedBy=multi-user.target
|
||||
--
|
||||
2.19.0.rc0
|
||||
|
||||
311
SOURCES/0009-Remove-xenctrl-support.patch
Normal file
311
SOURCES/0009-Remove-xenctrl-support.patch
Normal file
@ -0,0 +1,311 @@
|
||||
From 3dd984f7299d1364d6e7a902776e1fcfd83d6370 Mon Sep 17 00:00:00 2001
|
||||
From: Jim Fehlig <jfehlig@suse.com>
|
||||
Date: Wed, 6 Jun 2018 14:40:33 -0600
|
||||
Subject: [PATCH 09/17] Remove xenctrl support
|
||||
|
||||
The xenctrl interface has changed over the years, causing
|
||||
the associated code in vhostmd to no longer compile. Instead
|
||||
of trying to get this low-level xen interface working again,
|
||||
simply remove it from vhostmd. libvirt or custom "actions"
|
||||
should be used to gather metrics.
|
||||
|
||||
Signed-off-by: Jim Fehlig <jfehlig@suse.com>
|
||||
---
|
||||
configure.ac | 21 +-----
|
||||
include/util.h | 2 -
|
||||
vhostmd/Makefile.am | 17 +----
|
||||
vhostmd/metric.c | 5 --
|
||||
vhostmd/vhostmd.c | 4 --
|
||||
vhostmd/xenctrl-util.c | 148 -----------------------------------------
|
||||
6 files changed, 4 insertions(+), 193 deletions(-)
|
||||
delete mode 100644 vhostmd/xenctrl-util.c
|
||||
|
||||
diff --git a/configure.ac b/configure.ac
|
||||
index b0a07c7..2e88bfd 100644
|
||||
--- a/configure.ac
|
||||
+++ b/configure.ac
|
||||
@@ -51,26 +51,7 @@ AC_ARG_ENABLE([libxenstat],
|
||||
esac],[AC_CHECK_HEADER(xenstat.h, libxenstat=true, libxenstat=false)])
|
||||
AM_CONDITIONAL(LIBXENSTAT, test x$libxenstat = xtrue)
|
||||
|
||||
-# Configure argument to support using xenctrl library for vm enumeration
|
||||
-AC_ARG_ENABLE([xenctrl],
|
||||
-[ --enable-xenctrl use xenctrl specific vm enumeration instead of libvirt],
|
||||
- [case "${enableval}" in
|
||||
- yes) xenctrl=true
|
||||
- CFLAGS="$CFLAGS -DXENCTRL"
|
||||
- ;;
|
||||
- no) xenctrl=false ;;
|
||||
- *) AC_MSG_ERROR(bad value ${enableval} for --enable-xenctrl) ;;
|
||||
- esac],[AC_CHECK_HEADER(xenctrl.h, xenctrl=true, xenctrl=false,)])
|
||||
-AM_CONDITIONAL(XENCTRL, test x$xenctrl = xtrue)
|
||||
-
|
||||
-libvirt=false
|
||||
-AM_CONDITIONAL(LIBVIRT, test x$libvirt = xtrue)
|
||||
-# Default to libvirt for vm enumeration if no other enabled
|
||||
-if test "x$xenctrl" = "xfalse"; then
|
||||
- libvirt=true
|
||||
- PKG_CHECK_MODULES([LIBVIRT], [libvirt])
|
||||
- AM_CONDITIONAL(LIBVIRT, test x$libvirt = xtrue)
|
||||
-fi
|
||||
+PKG_CHECK_MODULES([LIBVIRT], [libvirt])
|
||||
|
||||
# Configure argument to support using xenstore
|
||||
AC_ARG_WITH([xenstore],
|
||||
diff --git a/include/util.h b/include/util.h
|
||||
index 6045665..3a21e09 100644
|
||||
--- a/include/util.h
|
||||
+++ b/include/util.h
|
||||
@@ -53,12 +53,10 @@ typedef struct _vu_vm
|
||||
} vu_vm;
|
||||
|
||||
|
||||
-#ifndef XENCTRL
|
||||
/* The libvirt URI to connect to (-c argument on the command line). If
|
||||
* not set, this will be NULL.
|
||||
*/
|
||||
extern const char *libvirt_uri;
|
||||
-#endif
|
||||
|
||||
/*
|
||||
* Init logging interface. If running as daemon messages
|
||||
diff --git a/vhostmd/Makefile.am b/vhostmd/Makefile.am
|
||||
index 3801882..659a0ce 100644
|
||||
--- a/vhostmd/Makefile.am
|
||||
+++ b/vhostmd/Makefile.am
|
||||
@@ -3,26 +3,15 @@ INCLUDES = \
|
||||
-I../include
|
||||
|
||||
sbin_PROGRAMS = vhostmd
|
||||
-vhostmd_SOURCES = vhostmd.c util.c metric.c
|
||||
-vhostmd_CFLAGS = $(LIBXML_CFLAGS)
|
||||
-vhostmd_LDADD = -lm $(LIBXML_LIBS)
|
||||
+vhostmd_SOURCES = vhostmd.c util.c metric.c virt-util.c
|
||||
+vhostmd_CFLAGS = $(LIBXML_CFLAGS) $(LIBVIRT_CFLAGS)
|
||||
+vhostmd_LDADD = -lm $(LIBXML_LIBS) $(LIBVIRT_LIBS)
|
||||
|
||||
if WITH_XENSTORE
|
||||
vhostmd_SOURCES += xenstore-update.c
|
||||
vhostmd_LDADD += -lxenstore
|
||||
endif
|
||||
|
||||
-if XENCTRL
|
||||
-vhostmd_SOURCES += xenctrl-util.c
|
||||
-vhostmd_LDADD += -lxenctrl -lxenstore
|
||||
-endif
|
||||
-
|
||||
-if LIBVIRT
|
||||
-vhostmd_SOURCES += virt-util.c
|
||||
-vhostmd_LDADD += $(LIBVIRT_LIBS)
|
||||
-vhostmd_CFLAGS += $(LIBVIRT_CFLAGS)
|
||||
-endif
|
||||
-
|
||||
if LIBXENSTAT
|
||||
vhostmd_SOURCES += xen-metrics.c
|
||||
vhostmd_LDADD += ../xenstat/libxenstat/src/libxenstat.a
|
||||
diff --git a/vhostmd/metric.c b/vhostmd/metric.c
|
||||
index 3fdf4f6..84b1678 100644
|
||||
--- a/vhostmd/metric.c
|
||||
+++ b/vhostmd/metric.c
|
||||
@@ -71,10 +71,6 @@ static int metric_action_subst(metric *m, char **action)
|
||||
return -1;
|
||||
}
|
||||
|
||||
-#ifdef XENCTRL
|
||||
- temp = replace (temp, "CONNECT", "");
|
||||
- if (temp == NULL) return -1;
|
||||
-#else /* LIBVIRT used instead */
|
||||
if (libvirt_uri) {
|
||||
temp = replace (temp, "CONNECT", "--connect '%s'", libvirt_uri);
|
||||
if (temp == NULL) return -1;
|
||||
@@ -82,7 +78,6 @@ static int metric_action_subst(metric *m, char **action)
|
||||
temp = replace (temp, "CONNECT", "");
|
||||
if (temp == NULL) return -1;
|
||||
}
|
||||
-#endif
|
||||
|
||||
if (m->ctx == METRIC_CONTEXT_VM) {
|
||||
temp = replace (temp, "NAME", "%s", m->vm->name);
|
||||
diff --git a/vhostmd/vhostmd.c b/vhostmd/vhostmd.c
|
||||
index 90ba76d..e2e91f6 100644
|
||||
--- a/vhostmd/vhostmd.c
|
||||
+++ b/vhostmd/vhostmd.c
|
||||
@@ -979,9 +979,7 @@ int main(int argc, char *argv[])
|
||||
{ "config", required_argument, NULL, 'f'},
|
||||
{ "pid-file", required_argument, NULL, 'p'},
|
||||
{ "user", required_argument, NULL, 'u'},
|
||||
-#ifndef XENCTRL
|
||||
{ "connect", required_argument, NULL, 'c'},
|
||||
-#endif
|
||||
{ "help", no_argument, NULL, '?' },
|
||||
{0, 0, 0, 0}
|
||||
};
|
||||
@@ -1014,11 +1012,9 @@ int main(int argc, char *argv[])
|
||||
case 'u':
|
||||
user = optarg;
|
||||
break;
|
||||
-#ifndef XENCTRL
|
||||
case 'c':
|
||||
libvirt_uri = optarg;
|
||||
break;
|
||||
-#endif
|
||||
case '?':
|
||||
usage(argv[0]);
|
||||
return 2;
|
||||
diff --git a/vhostmd/xenctrl-util.c b/vhostmd/xenctrl-util.c
|
||||
deleted file mode 100644
|
||||
index 7c78ca4..0000000
|
||||
--- a/vhostmd/xenctrl-util.c
|
||||
+++ /dev/null
|
||||
@@ -1,148 +0,0 @@
|
||||
-/*
|
||||
- * Copyright (C) 2009 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@novell.com>
|
||||
- *
|
||||
- * Preliminary, this could be done better
|
||||
- */
|
||||
-
|
||||
-#include <config.h>
|
||||
-
|
||||
-#include <stdio.h>
|
||||
-#include <string.h>
|
||||
-#include <xenctrl.h>
|
||||
-#include <xs.h>
|
||||
-
|
||||
-#include "util.h"
|
||||
-
|
||||
-#define MAX_DOMS 1024
|
||||
-static int xc_handle = -1;
|
||||
-static xc_dominfo_t info[MAX_DOMS];
|
||||
-
|
||||
-int vu_num_vms(void)
|
||||
-{
|
||||
- uint32_t first_dom = 0;
|
||||
- int max_doms = MAX_DOMS, nr_doms = 0;
|
||||
-
|
||||
- if (xc_handle == -1)
|
||||
- xc_handle = xc_interface_open();
|
||||
-
|
||||
- if (xc_handle == -1)
|
||||
- return -1;
|
||||
-
|
||||
- nr_doms = xc_domain_getinfo(xc_handle, first_dom, max_doms, info);
|
||||
-
|
||||
- return(nr_doms);
|
||||
-}
|
||||
-
|
||||
-int vu_get_vms(int *ids, int max_ids)
|
||||
-{
|
||||
- uint32_t first_dom = 0;
|
||||
- int max_doms = MAX_DOMS, nr_doms = 0, i;
|
||||
-
|
||||
- if (xc_handle == -1)
|
||||
- xc_handle = xc_interface_open();
|
||||
-
|
||||
- if (xc_handle == -1)
|
||||
- return -1;
|
||||
-
|
||||
- nr_doms = xc_domain_getinfo(xc_handle, first_dom, max_doms, info);
|
||||
- if (nr_doms < 0) {
|
||||
- goto out;
|
||||
- }
|
||||
-
|
||||
- if (max_ids < nr_doms)
|
||||
- nr_doms = max_ids;
|
||||
- for (i = 0; i < nr_doms; i++)
|
||||
- ids[i] = (int)info[i].domid;
|
||||
-
|
||||
-out:
|
||||
- return nr_doms;
|
||||
-}
|
||||
-
|
||||
-vu_vm *vu_get_vm(int id)
|
||||
-{
|
||||
- vu_vm *vm = NULL;
|
||||
- char *path = NULL, *buf = NULL;
|
||||
- char *name = NULL;
|
||||
- char *uuid = NULL;
|
||||
- struct xs_handle *xsh = NULL;
|
||||
- unsigned len;
|
||||
- char *cp;
|
||||
-
|
||||
- vm = calloc(1, sizeof(vu_vm));
|
||||
- if (vm == NULL)
|
||||
- return NULL;
|
||||
-
|
||||
- vm->id = id;
|
||||
-
|
||||
- xsh = xs_daemon_open();
|
||||
- if (xsh == NULL)
|
||||
- goto error;
|
||||
-
|
||||
- path = xs_get_domain_path(xsh, id);
|
||||
- if (path == NULL) {
|
||||
- goto error;
|
||||
- }
|
||||
-
|
||||
- asprintf(&buf, "%s/vm", path);
|
||||
- uuid = xs_read(xsh, XBT_NULL, buf, &len);
|
||||
- if (uuid == NULL) {
|
||||
- goto error;
|
||||
- }
|
||||
- cp = strrchr(uuid, '/');
|
||||
- memmove(uuid, cp+1, strlen(cp));
|
||||
- vm->uuid = strdup(uuid);
|
||||
- free(buf);
|
||||
-
|
||||
- asprintf(&buf, "%s/name", path);
|
||||
- name = xs_read(xsh, XBT_NULL, buf, &len);
|
||||
- if (name)
|
||||
- vm->name = strdup(name);
|
||||
-
|
||||
- goto out;
|
||||
-
|
||||
-error:
|
||||
- if (vm) free(vm);
|
||||
- vm = NULL;
|
||||
-
|
||||
-out:
|
||||
- if (buf) free(buf);
|
||||
- if (path) free(path);
|
||||
- if (name) free(name);
|
||||
- if (uuid) free(uuid);
|
||||
- if (xsh) xs_daemon_close(xsh);
|
||||
-
|
||||
- return vm;
|
||||
-}
|
||||
-
|
||||
-void vu_vm_free(vu_vm *vm)
|
||||
-{
|
||||
- if (vm) {
|
||||
- free(vm->name);
|
||||
- free(vm->uuid);
|
||||
- free(vm);
|
||||
- }
|
||||
-}
|
||||
-
|
||||
-void vu_vm_connect_close()
|
||||
-{
|
||||
- if (xc_handle != -1)
|
||||
- xc_interface_close(xc_handle);
|
||||
- xc_handle = -1;
|
||||
-}
|
||||
-
|
||||
--
|
||||
2.19.0.rc0
|
||||
|
||||
222
SOURCES/0010-Remove-support-for-libxenstat.patch
Normal file
222
SOURCES/0010-Remove-support-for-libxenstat.patch
Normal file
@ -0,0 +1,222 @@
|
||||
From 1586cf7722d8ca45e4e4fff67be1ae0567e6d4b8 Mon Sep 17 00:00:00 2001
|
||||
From: Jim Fehlig <jfehlig@suse.com>
|
||||
Date: Wed, 6 Jun 2018 14:52:29 -0600
|
||||
Subject: [PATCH 10/17] Remove support for libxenstat
|
||||
|
||||
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@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(-)
|
||||
delete mode 100644 vhostmd/xen-metrics.c
|
||||
|
||||
diff --git a/configure.ac b/configure.ac
|
||||
index 2e88bfd..830c47f 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@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.19.0.rc0
|
||||
|
||||
58
SOURCES/0011-Fix-compilation-with-xenstore.patch
Normal file
58
SOURCES/0011-Fix-compilation-with-xenstore.patch
Normal file
@ -0,0 +1,58 @@
|
||||
From 66967ef343c40d91918384540f9868b43c90c433 Mon Sep 17 00:00:00 2001
|
||||
From: Jim Fehlig <jfehlig@suse.com>
|
||||
Date: Wed, 6 Jun 2018 14:58:00 -0600
|
||||
Subject: [PATCH 11/17] Fix compilation with xenstore
|
||||
|
||||
The xenstore transport is worth keeping, so update it to
|
||||
work with "modern" Xen. By modern I mean something like 4.4
|
||||
or newer.
|
||||
|
||||
Signed-off-by: Jim Fehlig <jfehlig@suse.com>
|
||||
---
|
||||
configure.ac | 2 +-
|
||||
libmetrics/libmetrics.c | 2 +-
|
||||
vhostmd/xenstore-update.c | 2 +-
|
||||
3 files changed, 3 insertions(+), 3 deletions(-)
|
||||
|
||||
diff --git a/configure.ac b/configure.ac
|
||||
index 830c47f..c6b660e 100644
|
||||
--- a/configure.ac
|
||||
+++ b/configure.ac
|
||||
@@ -48,7 +48,7 @@ AC_ARG_WITH([xenstore],
|
||||
yes) with_xenstore=true;;
|
||||
no) with_xenstore=false;;
|
||||
*) AC_MSG_ERROR(bad value ${withval} for --with-xenstore) ;;
|
||||
- esac],[AC_CHECK_HEADER(xs.h, with_xenstore=true)])
|
||||
+ esac],[AC_CHECK_HEADER(xenstore.h, with_xenstore=true)])
|
||||
AM_CONDITIONAL(WITH_XENSTORE, test x$with_xenstore = xtrue)
|
||||
|
||||
# Configure argument to support type of init system
|
||||
diff --git a/libmetrics/libmetrics.c b/libmetrics/libmetrics.c
|
||||
index 6d5c26f..81f4d1a 100644
|
||||
--- a/libmetrics/libmetrics.c
|
||||
+++ b/libmetrics/libmetrics.c
|
||||
@@ -31,7 +31,7 @@
|
||||
#include <arpa/inet.h>
|
||||
#include <libxml/xpath.h>
|
||||
#ifdef WITH_XENSTORE
|
||||
-#include <xs.h>
|
||||
+#include <xenstore.h>
|
||||
#endif
|
||||
|
||||
#include "libmetrics.h"
|
||||
diff --git a/vhostmd/xenstore-update.c b/vhostmd/xenstore-update.c
|
||||
index f157f60..20fbde1 100644
|
||||
--- a/vhostmd/xenstore-update.c
|
||||
+++ b/vhostmd/xenstore-update.c
|
||||
@@ -28,7 +28,7 @@
|
||||
#include <errno.h>
|
||||
#include <libxml/parser.h>
|
||||
#include <libxml/xpath.h>
|
||||
-#include <xs.h>
|
||||
+#include <xenstore.h>
|
||||
|
||||
#include "util.h"
|
||||
#include "metric.h"
|
||||
--
|
||||
2.19.0.rc0
|
||||
|
||||
24
SOURCES/0012-Fix-typo-in-systemd-service-file.patch
Normal file
24
SOURCES/0012-Fix-typo-in-systemd-service-file.patch
Normal file
@ -0,0 +1,24 @@
|
||||
From b015f73b742db6285d8201e87387a7217e89dbfd Mon Sep 17 00:00:00 2001
|
||||
From: Jim Fehlig <jfehlig@suse.com>
|
||||
Date: Mon, 11 Jun 2018 15:25:58 -0600
|
||||
Subject: [PATCH 12/17] Fix typo in systemd service file
|
||||
|
||||
Signed-off-by: Jim Fehlig <jfehlig@suse.com>
|
||||
---
|
||||
vhostmd.service | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/vhostmd.service b/vhostmd.service
|
||||
index 9d50523..576dabd 100644
|
||||
--- a/vhostmd.service
|
||||
+++ b/vhostmd.service
|
||||
@@ -1,5 +1,5 @@
|
||||
[Unit]
|
||||
-Description=Daemon for collecting virutalization host metrics
|
||||
+Description=Daemon for collecting virtualization host metrics
|
||||
After=libvirtd.service
|
||||
Documentation=man:vhostmd(8)
|
||||
|
||||
--
|
||||
2.19.0.rc0
|
||||
|
||||
70
SOURCES/0013-Fix-help-option.patch
Normal file
70
SOURCES/0013-Fix-help-option.patch
Normal file
@ -0,0 +1,70 @@
|
||||
From 302e49730f862a10b3b5b58905d803d27853f7d6 Mon Sep 17 00:00:00 2001
|
||||
From: Jim Fehlig <jfehlig@suse.com>
|
||||
Date: Wed, 20 Jun 2018 16:39:20 -0600
|
||||
Subject: [PATCH 13/17] Fix help option
|
||||
|
||||
Fix the short option for help, add help to the help output, and
|
||||
add help to the vhostmd man page.
|
||||
|
||||
Signed-off-by: Jim Fehlig <jfehlig@suse.com>
|
||||
---
|
||||
docs/man/vhostmd.8 | 3 +++
|
||||
vhostmd/vhostmd.c | 7 ++++---
|
||||
2 files changed, 7 insertions(+), 3 deletions(-)
|
||||
|
||||
diff --git a/docs/man/vhostmd.8 b/docs/man/vhostmd.8
|
||||
index 2c73adc..ed82432 100644
|
||||
--- a/docs/man/vhostmd.8
|
||||
+++ b/docs/man/vhostmd.8
|
||||
@@ -13,6 +13,9 @@ provides a "metrics communication channel" between a host and its hosted virtual
|
||||
vhostmd will periodically write metrics to a disk. The metrics to write, how often, and where to write them are all adjustable via the /etc/vhostmd/vhostmd.conf configuration file. The disk can then be surfaced read-only to virtual machines using tools provided by the host's virtualization platform.
|
||||
.SH OPTIONS
|
||||
.TP
|
||||
+.B \-h, --help
|
||||
+Display help and exit
|
||||
+.TP
|
||||
.B \-v, --verbose
|
||||
Verbose messages
|
||||
.TP
|
||||
diff --git a/vhostmd/vhostmd.c b/vhostmd/vhostmd.c
|
||||
index 7f04705..8576609 100644
|
||||
--- a/vhostmd/vhostmd.c
|
||||
+++ b/vhostmd/vhostmd.c
|
||||
@@ -950,6 +950,7 @@ static void usage(const char *argv0)
|
||||
%s [options]\n\
|
||||
\n\
|
||||
Options:\n\
|
||||
+ -h | --help Display program help.\n\
|
||||
-v | --verbose Verbose messages.\n\
|
||||
-c | --connect <uri> Set the libvirt URI.\n\
|
||||
-d | --no-daemonize Process will not daemonize - useful for debugging.\n\
|
||||
@@ -980,7 +981,7 @@ int main(int argc, char *argv[])
|
||||
{ "pid-file", required_argument, NULL, 'p'},
|
||||
{ "user", required_argument, NULL, 'u'},
|
||||
{ "connect", required_argument, NULL, 'c'},
|
||||
- { "help", no_argument, NULL, '?' },
|
||||
+ { "help", no_argument, NULL, 'h' },
|
||||
{0, 0, 0, 0}
|
||||
};
|
||||
|
||||
@@ -988,7 +989,7 @@ int main(int argc, char *argv[])
|
||||
int optidx = 0;
|
||||
int c;
|
||||
|
||||
- c = getopt_long(argc, argv, "c:df:p:u:v", opts, &optidx);
|
||||
+ c = getopt_long(argc, argv, "c:df:p:u:vh", opts, &optidx);
|
||||
|
||||
if (c == -1)
|
||||
break;
|
||||
@@ -1015,7 +1016,7 @@ int main(int argc, char *argv[])
|
||||
case 'c':
|
||||
libvirt_uri = optarg;
|
||||
break;
|
||||
- case '?':
|
||||
+ case 'h':
|
||||
usage(argv[0]);
|
||||
return 2;
|
||||
default:
|
||||
--
|
||||
2.19.0.rc0
|
||||
|
||||
110
SOURCES/0014-Add-SIGPIPE-handler-and-reconnect.patch
Normal file
110
SOURCES/0014-Add-SIGPIPE-handler-and-reconnect.patch
Normal file
@ -0,0 +1,110 @@
|
||||
From c7646e329ca61a038777f58042539611ac42b007 Mon Sep 17 00:00:00 2001
|
||||
From: Michael Trapp <Michael.Trapp@sap.com>
|
||||
Date: Thu, 21 Jun 2018 15:03:50 +0200
|
||||
Subject: [PATCH 14/17] Add SIGPIPE handler and reconnect
|
||||
|
||||
vhostmd has no signal handler for SIGPIPE and a restart of libvirtd results in
|
||||
a stopped vhostmd. The root cause seems to be a UDS socket between vhostmd and
|
||||
libvirtd which is closed by a libvirtd restart.
|
||||
In addition to the signal handler the connection to libvirtd has to be opened
|
||||
again otherwise vhostmd can't read any data from libvirtd and doesn't update
|
||||
the metrics.
|
||||
---
|
||||
vhostmd/vhostmd.c | 2 ++
|
||||
vhostmd/virt-util.c | 43 ++++++++++++++++++++++++++++++++++++-------
|
||||
2 files changed, 38 insertions(+), 7 deletions(-)
|
||||
|
||||
diff --git a/vhostmd/vhostmd.c b/vhostmd/vhostmd.c
|
||||
index 8576609..dc80345 100644
|
||||
--- a/vhostmd/vhostmd.c
|
||||
+++ b/vhostmd/vhostmd.c
|
||||
@@ -117,6 +117,7 @@ static void sig_handler(int sig, siginfo_t *siginfo ATTRIBUTE_UNUSED,
|
||||
case SIGQUIT:
|
||||
down = 1;
|
||||
break;
|
||||
+ case SIGPIPE:
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@@ -1054,6 +1055,7 @@ int main(int argc, char *argv[])
|
||||
sigaction(SIGINT, &sig_action, NULL);
|
||||
sigaction(SIGQUIT, &sig_action, NULL);
|
||||
sigaction(SIGTERM, &sig_action, NULL);
|
||||
+ sigaction(SIGPIPE, &sig_action, NULL);
|
||||
|
||||
xmlInitParser();
|
||||
|
||||
diff --git a/vhostmd/virt-util.c b/vhostmd/virt-util.c
|
||||
index 1c31305..587146f 100644
|
||||
--- a/vhostmd/virt-util.c
|
||||
+++ b/vhostmd/virt-util.c
|
||||
@@ -26,21 +26,48 @@
|
||||
|
||||
#include "util.h"
|
||||
|
||||
+enum {
|
||||
+ CLOSED = 0,
|
||||
+ ESTABLISHED
|
||||
+} connection = CLOSED;
|
||||
+
|
||||
static virConnectPtr conn = NULL;
|
||||
|
||||
const char *libvirt_uri = NULL;
|
||||
|
||||
+void
|
||||
+conn_close_cb(virConnectPtr c,
|
||||
+ int reason ATTRIBUTE_UNUSED,
|
||||
+ void *p ATTRIBUTE_UNUSED)
|
||||
+{
|
||||
+ if (c == conn)
|
||||
+ connection = CLOSED;
|
||||
+}
|
||||
+
|
||||
static int
|
||||
-do_connect (void)
|
||||
+do_connect(void)
|
||||
{
|
||||
+ if (connection == ESTABLISHED)
|
||||
+ return 0;
|
||||
+
|
||||
+ if (conn != NULL)
|
||||
+ virConnectClose(conn);
|
||||
+
|
||||
+ conn = virConnectOpenReadOnly(libvirt_uri);
|
||||
if (conn == NULL) {
|
||||
- conn = virConnectOpenReadOnly (libvirt_uri);
|
||||
- if (conn == NULL) {
|
||||
- vu_log (VHOSTMD_ERR, "Unable to open libvirt connection to %s",
|
||||
- libvirt_uri ? libvirt_uri : "default hypervisor");
|
||||
- return -1;
|
||||
- }
|
||||
+ vu_log(VHOSTMD_ERR, "Unable to open libvirt connection to %s",
|
||||
+ libvirt_uri ? libvirt_uri : "default hypervisor");
|
||||
+ return -1;
|
||||
}
|
||||
+
|
||||
+ if (virConnectRegisterCloseCallback(conn, conn_close_cb, NULL, NULL)) {
|
||||
+ vu_log(VHOSTMD_ERR, "Unable to register callback 'virConnectCloseFunc'");
|
||||
+ virConnectClose(conn);
|
||||
+ conn = NULL;
|
||||
+ return -1;
|
||||
+ }
|
||||
+
|
||||
+ connection = ESTABLISHED;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -107,8 +134,10 @@ void vu_vm_free(vu_vm *vm)
|
||||
void vu_vm_connect_close()
|
||||
{
|
||||
if (conn) {
|
||||
+ virConnectUnregisterCloseCallback(conn, conn_close_cb);
|
||||
virConnectClose(conn);
|
||||
conn = NULL;
|
||||
}
|
||||
+ connection = CLOSED;
|
||||
}
|
||||
|
||||
--
|
||||
2.19.0.rc0
|
||||
|
||||
40
SOURCES/0015-fix-deallocation-in-vu_vm_free.patch
Normal file
40
SOURCES/0015-fix-deallocation-in-vu_vm_free.patch
Normal file
@ -0,0 +1,40 @@
|
||||
From 03dc99825ad3d53cfcc7d8c2b8288b1549f261d6 Mon Sep 17 00:00:00 2001
|
||||
From: Michael Trapp <Michael.Trapp@sap.com>
|
||||
Date: Thu, 21 Jun 2018 15:19:26 +0200
|
||||
Subject: [PATCH 15/17] fix deallocation in vu_vm_free
|
||||
|
||||
Callers of vu_vm_free may pass a partially constructed vu_vm
|
||||
object. Check if members of the object have been allocated
|
||||
before deallocating them.
|
||||
---
|
||||
vhostmd/virt-util.c | 8 +++++---
|
||||
1 file changed, 5 insertions(+), 3 deletions(-)
|
||||
|
||||
diff --git a/vhostmd/virt-util.c b/vhostmd/virt-util.c
|
||||
index 587146f..a94cccd 100644
|
||||
--- a/vhostmd/virt-util.c
|
||||
+++ b/vhostmd/virt-util.c
|
||||
@@ -118,15 +118,17 @@ vu_vm *vu_get_vm(int id)
|
||||
|
||||
error:
|
||||
virDomainFree(dom);
|
||||
- free(vm);
|
||||
+ vu_vm_free(vm);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void vu_vm_free(vu_vm *vm)
|
||||
{
|
||||
if (vm) {
|
||||
- free(vm->name);
|
||||
- free(vm->uuid);
|
||||
+ if (vm->name)
|
||||
+ free(vm->name);
|
||||
+ if (vm->uuid)
|
||||
+ free(vm->uuid);
|
||||
free(vm);
|
||||
}
|
||||
}
|
||||
--
|
||||
2.19.0.rc0
|
||||
|
||||
39
SOURCES/0016-configure-fix-logic-in-init-script-check.patch
Normal file
39
SOURCES/0016-configure-fix-logic-in-init-script-check.patch
Normal file
@ -0,0 +1,39 @@
|
||||
From 6439d22cea451e54b58bb9d6e8072cc6c58694be Mon Sep 17 00:00:00 2001
|
||||
From: Jim Fehlig <jfehlig@suse.com>
|
||||
Date: Mon, 11 Jun 2018 20:35:50 -0600
|
||||
Subject: [PATCH 16/17] configure: fix logic in init script check
|
||||
|
||||
The logic introduced in commit d1276646to check for init script type is
|
||||
a bit flawed. If the init script type is specified, init_systemv is
|
||||
always set to 'yes', even when '--with-init-script=systemd'. Split the
|
||||
logic to only check for init script type when '--with-init-script=check'.
|
||||
|
||||
Signed-off-by: Jim Fehlig <jfehlig@suse.com>
|
||||
---
|
||||
configure.ac | 10 ++++++----
|
||||
1 file changed, 6 insertions(+), 4 deletions(-)
|
||||
|
||||
diff --git a/configure.ac b/configure.ac
|
||||
index c6b660e..9414440 100644
|
||||
--- a/configure.ac
|
||||
+++ b/configure.ac
|
||||
@@ -59,10 +59,12 @@ AC_ARG_WITH([init_script],
|
||||
[with_init_script=check])
|
||||
init_systemv=no
|
||||
init_systemd=no
|
||||
-if test "$with_init_script" = check && type systemctl >/dev/null 2>&1; then
|
||||
- init_systemd=yes
|
||||
-else
|
||||
- init_systemv=yes
|
||||
+if test "$with_init_script" = check; then
|
||||
+ if type systemctl >/dev/null 2>&1; then
|
||||
+ init_systemd=yes
|
||||
+ else
|
||||
+ init_systemv=yes
|
||||
+ fi
|
||||
fi
|
||||
case "${with_init_script}" in
|
||||
systemv) init_systemv=yes;;
|
||||
--
|
||||
2.19.0.rc0
|
||||
|
||||
175
SOURCES/0017-conf-Improve-example-configuration-file.patch
Normal file
175
SOURCES/0017-conf-Improve-example-configuration-file.patch
Normal file
@ -0,0 +1,175 @@
|
||||
From d1a230d6d3ca4ded376f6522688d379bac347fbe Mon Sep 17 00:00:00 2001
|
||||
From: Jim Fehlig <jfehlig@suse.com>
|
||||
Date: Wed, 20 Jun 2018 15:39:45 -0600
|
||||
Subject: [PATCH 17/17] conf: Improve example configuration file
|
||||
|
||||
Although the upstream vhostmd config file serves primarily as an
|
||||
example, it should at least work and not unconditionally call
|
||||
commands that no longer exist.
|
||||
|
||||
While at it, improve the comments describing the <action> element.
|
||||
|
||||
Signed-off-by: Jim Fehlig <jfehlig@suse.com>
|
||||
---
|
||||
vhostmd.xml | 95 +++++++++++++++++++++++++++++++++++++++++++----------
|
||||
1 file changed, 78 insertions(+), 17 deletions(-)
|
||||
|
||||
diff --git a/vhostmd.xml b/vhostmd.xml
|
||||
index 6f56b58..9b048df 100644
|
||||
--- a/vhostmd.xml
|
||||
+++ b/vhostmd.xml
|
||||
@@ -18,6 +18,12 @@ A metric's value is set to the output produced by executing its action.
|
||||
the vm currently under inspection is substituted for NAME. Only useful
|
||||
within the vm element.
|
||||
|
||||
+NOTE - 'action' must be a valid shell builtin, script or external
|
||||
+command found in the path specified by the global <path> element.
|
||||
+When chaining commands, '&', '<' and '>' are reserved characters,
|
||||
+therefore '&', '<' and '>' must be used instead. For example,
|
||||
+the logical && operator must be replaced with "&&".
|
||||
+
|
||||
-->
|
||||
|
||||
<vhostmd>
|
||||
@@ -28,52 +34,75 @@ within the vm element.
|
||||
<size unit="k">256</size>
|
||||
</disk>
|
||||
<update_period>5</update_period>
|
||||
- <path>/usr/bin:/usr/sbin:/usr/share/vhostmd/scripts</path>
|
||||
+ <path>/usr/sbin:/sbin:/usr/bin:/bin:/usr/share/vhostmd/scripts</path>
|
||||
<transport>vbd</transport>
|
||||
<!-- <transport>xenstore</transport> -->
|
||||
</globals>
|
||||
<metrics>
|
||||
<metric type="string" context="host">
|
||||
<name>HostName</name>
|
||||
- <action>virsh CONNECT hostname | tr -d '[:space:]'</action>
|
||||
+ <action>
|
||||
+ virsh CONNECT hostname | tr -d '[:space:]'
|
||||
+ </action>
|
||||
</metric>
|
||||
<metric type="string" context="host">
|
||||
<name>VirtualizationVendor</name>
|
||||
- <action>/bin/rpm -q --info xen | grep Vendor: | \
|
||||
- awk '{print substr($0, index($0,$5)) }'</action>
|
||||
+ <action>
|
||||
+ [ -f /proc/xen/privcmd ] && RPM="xen" || RPM="libvirt"; \
|
||||
+ rpm -q --queryformat "%{VENDOR}\n" $RPM | sort -u | sed -e 's/<.*//' -e 's/ *$//'
|
||||
+ </action>
|
||||
</metric>
|
||||
<metric type="string" context="host">
|
||||
<name>VirtualizationProductInfo</name>
|
||||
- <action>xm info | gawk '/^xen_(major|minor|extra)/ {print $3}' | \
|
||||
- tr -d . | tr '[:space:]' .</action>
|
||||
+ <action>
|
||||
+ [ -f /proc/xen/privcmd ] && xl info | \
|
||||
+ awk '/^xen_(major|minor|extra)/ {print $3}' | sed -e 'N;s/\n/./' -e 'N;s/\n//' || \
|
||||
+ rpm -q --queryformat "%{VERSION}-%{RELEASE}\n" libvirt | sort -u
|
||||
+ </action>
|
||||
</metric>
|
||||
<metric type="uint32" context="host">
|
||||
<name>TotalPhyCPUs</name>
|
||||
- <action>xm info | gawk '/^nr_cpus/ {print $3}'</action>
|
||||
+ <action>
|
||||
+ virsh nodeinfo | awk '/^CPU\(s\)/ {print $2}'
|
||||
+ </action>
|
||||
</metric>
|
||||
<metric type="uint32" context="host">
|
||||
<name>NumCPUs</name>
|
||||
- <action>xm info | gawk '/^nr_cpus/ {print $3}'</action>
|
||||
+ <action>
|
||||
+ virsh nodeinfo | awk '/^CPU\(s\)/ {print $2}'
|
||||
+ </action>
|
||||
</metric>
|
||||
<metric type="uint64" context="host">
|
||||
<name>TotalPhyMem</name>
|
||||
- <action>xm info | gawk '/^total_memory/ {print $3}'</action>
|
||||
+ <action>
|
||||
+ echo $((`virsh nodeinfo | awk '/^Memory/ {print $3}'` / 1024))
|
||||
+ </action>
|
||||
</metric>
|
||||
<metric type="uint64" context="host">
|
||||
<name>UsedMem</name>
|
||||
- <action>echo "$((`xentop -b -i 1 | gawk '/Domain-0/ {print $5}'` / 1024))"</action>
|
||||
+ <action>
|
||||
+ [ -f /proc/xen/privcmd ] && echo "$((`xentop -b -i 1 | awk '/Domain-0/ {print $5}'` / 1024))" || \
|
||||
+ free | egrep -i '^[[:space:]]*(.*buffers/cache:)' | awk '{ printf "%d\n", $3/1024; }'
|
||||
+ </action>
|
||||
</metric>
|
||||
<metric type="uint64" context="host">
|
||||
<name>FreeMem</name>
|
||||
- <action>xm info | gawk '/^max_free_memory/ {print $3}'</action>
|
||||
+ <action>
|
||||
+ [ -f /proc/xen/privcmd ] && xl info | awk '/^free_memory/ {print $3}' || \
|
||||
+ free | egrep -i '^[[:space:]]*(.*buffers/cache:)' | awk '{ printf "%d\n", $4/1024; }'
|
||||
+ </action>
|
||||
</metric>
|
||||
<metric type="uint64" context="host">
|
||||
<name>PagedInMemory</name>
|
||||
- <action>echo "$((`vmstat -s | gawk '/pages paged in/ {print $1}'` / 1024))"</action>
|
||||
+ <action>
|
||||
+ vmstat -s | awk '/pages paged in/ {printf "%d\n", $1 / 1024 * $(getconf PAGESIZE) / 1024;}'
|
||||
+ </action>
|
||||
</metric>
|
||||
<metric type="uint64" context="host">
|
||||
<name>PagedOutMemory</name>
|
||||
- <action>echo "$((`vmstat -s | gawk '/pages paged out/ {print $1}'` / 1024))"</action>
|
||||
+ <action>
|
||||
+ vmstat -s | awk '/pages paged out/ {printf "%d\n", $1 / 1024 * $(getconf PAGESIZE) / 1024;}'
|
||||
+ </action>
|
||||
</metric>
|
||||
<metric type="group" context="host">
|
||||
<name>PageRates</name>
|
||||
@@ -83,13 +112,45 @@ within the vm element.
|
||||
</metric>
|
||||
<metric type="real64" context="host">
|
||||
<name>TotalCPUTime</name>
|
||||
- <action>virsh CONNECT dominfo 0 | sed 's/: */:/' | \
|
||||
- gawk -F: '/CPU time/ {print $2;}'</action>
|
||||
+ <action>
|
||||
+ [ -f /proc/xen/privcmd ] && xl list | awk '/^Domain-0/ {print $6}' || \
|
||||
+ awk '
|
||||
+ function user_hz( hz)
|
||||
+ {
|
||||
+ cmd = "getconf CLK_TCK";
|
||||
+ cmd | getline;
|
||||
+ hz = $1;
|
||||
+ close(cmd);
|
||||
+
|
||||
+ return hz;
|
||||
+ }
|
||||
+
|
||||
+ BEGIN {
|
||||
+ USER_HZ = user_hz();
|
||||
+ TotalCPUTime = 0;
|
||||
+
|
||||
+ while ( 0 < ( getline < "/proc/stat" ) )
|
||||
+ {
|
||||
+ if ( "cpu" == $1 )
|
||||
+ {
|
||||
+ TotalCPUTime = $2 + $3 + $4;
|
||||
+
|
||||
+ break;
|
||||
+ }
|
||||
+ }
|
||||
+ close("/proc/stat");
|
||||
+
|
||||
+ TotalCPUTime /= USER_HZ;
|
||||
+ printf "%f\n", TotalCPUTime;
|
||||
+ }'
|
||||
+ </action>
|
||||
</metric>
|
||||
<metric type="real64" context="vm">
|
||||
<name>TotalCPUTime</name>
|
||||
- <action>virsh CONNECT dominfo NAME | sed 's/: */:/' | \
|
||||
- gawk -F: '/CPU time/ {print $2;}'</action>
|
||||
+ <action>
|
||||
+ virsh CONNECT dominfo NAME | sed 's/: */:/' | \
|
||||
+ awk -F: '/CPU time/ {print $2;}' | sed 's/s//'
|
||||
+ </action>
|
||||
</metric>
|
||||
</metrics>
|
||||
</vhostmd>
|
||||
--
|
||||
2.19.0.rc0
|
||||
|
||||
427
SOURCES/vhostmd.conf
Normal file
427
SOURCES/vhostmd.conf
Normal file
@ -0,0 +1,427 @@
|
||||
<?xml version="1.0" ?>
|
||||
<!DOCTYPE vhostmd SYSTEM "vhostmd.dtd">
|
||||
|
||||
<!--
|
||||
|
||||
Configuration file for virtual host metrics daemon (vhostmd).
|
||||
|
||||
A better, less noisy, more minimal configuration file
|
||||
which doesn't depend on Xen.
|
||||
|
||||
Supported metric types are: int32, uint32, int64, uint64, real32,
|
||||
real64, and string.
|
||||
|
||||
A metric's value is set to the output produced by executing its action.
|
||||
|
||||
'action' can include the special token NAME, in which case the name of
|
||||
the vm currently under inspection is substituted for NAME. Only useful
|
||||
within the vm element.
|
||||
|
||||
-->
|
||||
|
||||
|
||||
<!-- 1 2 3 4 5 6 -->
|
||||
<!-- 678901234567890123456789012345678901234567890123456789012345678 -->
|
||||
|
||||
|
||||
<!--
|
||||
We sometimes use the following awk form to filter the output of the
|
||||
virsh command (mostly `virsh -r CONNECT dominfo NAME' - use
|
||||
`virsh -r dominfo <dom id>' to test on the commandline) into a standard
|
||||
format like
|
||||
|
||||
ID:6
|
||||
NAME:ls3055v0
|
||||
UUID:955c3b65-d013-547f-321b-9fea65439c40
|
||||
OS_TYPE:hvm
|
||||
STATE:running
|
||||
CPU(S):4
|
||||
CPU_TIME:433016.4:S
|
||||
MAX_MEMORY:20000000:KB
|
||||
USED_MEMORY:16384000:KB
|
||||
AUTOSTART:disable
|
||||
|
||||
We do this to extract numbers out of physical quantities in a reliable
|
||||
way.
|
||||
-->
|
||||
<!--
|
||||
|awk -F ':' '
|
||||
function mkvarnam(s) { # UPPER_CASE_UNDERSCORE
|
||||
sub("(^[[:space:]]+|[[:space:]]+$)", "", s); # trim
|
||||
gsub("[[:space:]]+", "_", s); s = toupper(s);
|
||||
return s;
|
||||
}
|
||||
function filt_phys(s, sep, num, unit) { # 42.0 KM
|
||||
sub("(^[[:space:]]+|[[:space:]]+$)", "", s); # trim
|
||||
if ( s ~ /^[0-9]*\.?[0-9]+[[:space:]]*[[:alpha:]]+$/ )
|
||||
{
|
||||
num = s; unit = s;
|
||||
sub("[[:space:]]*[[:alpha:]]+$", "", num);
|
||||
sub("^[0-9]*[.]?[0-9]+[[:space:]]*", "", unit);
|
||||
return num sep toupper(unit);
|
||||
}
|
||||
else
|
||||
{
|
||||
return s;
|
||||
}
|
||||
}
|
||||
/:/ {
|
||||
d1 = substr($0, 1, index($0, ":") - 1);
|
||||
rest = substr($0, index($0, ":") + 1);
|
||||
printf("%s:%s\n", mkvarnam(d1), filt_phys(rest, ":"));
|
||||
}' \
|
||||
-->
|
||||
|
||||
<vhostmd>
|
||||
<globals>
|
||||
<disk>
|
||||
<name>host-metrics-disk</name>
|
||||
<path>/dev/shm/vhostmd0</path>
|
||||
<!-- must be between [128 KB, 256 MB] in size -->
|
||||
<size unit="k">256</size>
|
||||
</disk>
|
||||
<update_period>60</update_period>
|
||||
<path>/bin:/sbin:/usr/bin:/usr/sbin:/usr/share/vhostmd/scripts</path>
|
||||
<transport>vbd</transport>
|
||||
<!-- <transport>xenstore</transport> -->
|
||||
</globals>
|
||||
<metrics>
|
||||
<metric type="string" context="host">
|
||||
<name>HostName</name>
|
||||
<action>hostname</action>
|
||||
</metric>
|
||||
<metric type="uint64" context="host">
|
||||
<name>Time</name>
|
||||
<action>date +%s</action>
|
||||
</metric>
|
||||
<metric type="string" context="host">
|
||||
<name>VirtualizationVendor</name>
|
||||
<action>
|
||||
rpm -qi libvirt| grep Vendor: \
|
||||
| awk '{ print substr($0, index($0, $5)); }' | sort -u
|
||||
</action>
|
||||
</metric>
|
||||
<!-- SAP "CIM" -->
|
||||
<metric type="string" context="host">
|
||||
<name>VirtProductInfo</name>
|
||||
<action>
|
||||
virsh -r CONNECT version \
|
||||
|awk -F ':' '
|
||||
function mkvarnam(s) { # UPPER_CASE_UNDERSCORE
|
||||
sub("(^[[:space:]]+|[[:space:]]+$)", "", s); # trim
|
||||
gsub("[[:space:]]+", "_", s); s = toupper(s);
|
||||
return s;
|
||||
}
|
||||
function filt_phys(s, sep, num, unit) { # 42.0 KM
|
||||
sub("(^[[:space:]]+|[[:space:]]+$)", "", s); # trim
|
||||
if ( s ~ /^[0-9]*\.?[0-9]+[[:space:]]*[[:alpha:]]+$/ )
|
||||
{
|
||||
num = s; unit = s;
|
||||
sub("[[:space:]]*[[:alpha:]]+$", "", num);
|
||||
sub("^[0-9]*[.]?[0-9]+[[:space:]]*", "", unit);
|
||||
return num sep toupper(unit);
|
||||
}
|
||||
else
|
||||
{
|
||||
return s;
|
||||
}
|
||||
}
|
||||
/:/ {
|
||||
d1 = substr($0, 1, index($0, ":") - 1);
|
||||
rest = substr($0, index($0, ":") + 1);
|
||||
printf("%s:%s\n", mkvarnam(d1), filt_phys(rest, ":"));
|
||||
}' \
|
||||
| awk -F: '$1 == "USING_API" { print $2; }'
|
||||
</action>
|
||||
</metric>
|
||||
<!-- SAP "CIM" -->
|
||||
<metric type="string" context="host">
|
||||
<name>HostSystemInfo</name>
|
||||
<action>hostname -s</action>
|
||||
</metric>
|
||||
<!-- SAP "XCIM" -->
|
||||
<metric type="uint32" context="host">
|
||||
<name>NumberOfPhysicalCPUs</name>
|
||||
<!-- physical CPUs usable by the virtual machines -->
|
||||
<!-- SAP "CIM" uses "NumberOfPhysicalCPUsUtilized" -->
|
||||
<!-- which means something different, i.e. -->
|
||||
<!-- "physical CPUs used by the virtual machines" -->
|
||||
<!-- but may be calculated (on client side) by -->
|
||||
<!-- Delta TotalCPUTime / Delta ElapsedTime -->
|
||||
<action>
|
||||
virsh -r CONNECT nodeinfo \
|
||||
|awk -F ':' '
|
||||
function mkvarnam(s) { # UPPER_CASE_UNDERSCORE
|
||||
sub("(^[[:space:]]+|[[:space:]]+$)", "", s); # trim
|
||||
gsub("[[:space:]]+", "_", s); s = toupper(s);
|
||||
return s;
|
||||
}
|
||||
function filt_phys(s, sep, num, unit) { # 42.0 KM
|
||||
sub("(^[[:space:]]+|[[:space:]]+$)", "", s); # trim
|
||||
if ( s ~ /^[0-9]*\.?[0-9]+[[:space:]]*[[:alpha:]]+$/ )
|
||||
{
|
||||
num = s; unit = s;
|
||||
sub("[[:space:]]*[[:alpha:]]+$", "", num);
|
||||
sub("^[0-9]*[.]?[0-9]+[[:space:]]*", "", unit);
|
||||
return num sep toupper(unit);
|
||||
}
|
||||
else
|
||||
{
|
||||
return s;
|
||||
}
|
||||
}
|
||||
/:/ {
|
||||
d1 = substr($0, 1, index($0, ":") - 1);
|
||||
rest = substr($0, index($0, ":") + 1);
|
||||
printf("%s:%s\n", mkvarnam(d1), filt_phys(rest, ":"));
|
||||
}' \
|
||||
| awk -F: '$1 == "CPU(S)" { print $2; }'
|
||||
</action>
|
||||
</metric>
|
||||
<!-- SAP "CIM" -->
|
||||
<metric type="uint64" context="host">
|
||||
<name>MemoryAllocatedToVirtualServers</name>
|
||||
<!-- physical memory used by the virtual machines, -->
|
||||
<!-- (_not_ physical memory usable by the virtual -->
|
||||
<!-- machines) -->
|
||||
<action>
|
||||
free|egrep -i '^[[:space:]]*(Mem:)' \
|
||||
| awk 'BEGIN { sum = 0; }
|
||||
{ sum += $3; }
|
||||
END { printf "%d\n", sum/1024; }'
|
||||
</action>
|
||||
</metric>
|
||||
<!-- SAP "CIM" -->
|
||||
<metric type="uint64" context="host">
|
||||
<name>FreePhysicalMemory</name>
|
||||
<action>
|
||||
free|egrep -i '^[[:space:]]*(Mem:)' \
|
||||
| awk 'BEGIN { sum = 0; }
|
||||
{ sum += $4; }
|
||||
END { printf "%d\n", sum/1024; }'
|
||||
</action>
|
||||
</metric>
|
||||
<!-- SAP "CIM" -->
|
||||
<metric type="uint64" context="host">
|
||||
<name>FreeVirtualMemory</name>
|
||||
<action>
|
||||
free|egrep -i '^[[:space:]]*(Mem:|Swap:)' \
|
||||
| awk 'BEGIN { sum = 0; }
|
||||
{ sum += $4; }
|
||||
END { printf "%d\n", sum/1024; }'
|
||||
</action>
|
||||
</metric>
|
||||
<!-- SAP "CIM" -->
|
||||
<metric type="uint64" context="host">
|
||||
<name>UsedVirtualMemory</name>
|
||||
<action>
|
||||
free|egrep -i '^[[:space:]]*(Mem:|Swap:)' \
|
||||
| awk 'BEGIN { sum = 0; }
|
||||
{ sum += $3; }
|
||||
END { printf "%d\n", sum/1024; }'
|
||||
</action>
|
||||
</metric>
|
||||
<!-- SAP "XCIM" -->
|
||||
<metric type="uint64" context="host">
|
||||
<name>PagedInMemory</name>
|
||||
<action>
|
||||
vmstat -s | awk 'BEGIN {
|
||||
cmd = "getconf PAGESIZE";
|
||||
cmd | getline pagesize;
|
||||
close(cmd);
|
||||
}
|
||||
/pages swapped in/ {
|
||||
printf "%d\n", $1 / 1024 * pagesize / 1024;
|
||||
}'
|
||||
</action>
|
||||
</metric>
|
||||
<!-- SAP "CIM" -->
|
||||
<metric type="uint64" context="host">
|
||||
<name>PagedOutMemory</name>
|
||||
<action>
|
||||
vmstat -s | awk 'BEGIN {
|
||||
cmd = "getconf PAGESIZE";
|
||||
cmd | getline pagesize;
|
||||
close(cmd);
|
||||
}
|
||||
/pages swapped out/ {
|
||||
printf "%d\n", $1 / 1024 * pagesize / 1024;
|
||||
}'
|
||||
</action>
|
||||
</metric>
|
||||
<!-- SAP "CIM" -->
|
||||
<metric type="real64" context="host">
|
||||
<name>TotalCPUTime</name>
|
||||
<action>
|
||||
awk '
|
||||
function user_hz( hz)
|
||||
{
|
||||
cmd = "getconf CLK_TCK";
|
||||
cmd | getline;
|
||||
hz = $1;
|
||||
close(cmd);
|
||||
|
||||
return hz;
|
||||
}
|
||||
|
||||
BEGIN {
|
||||
USER_HZ = user_hz();
|
||||
TotalCPUTime = 0;
|
||||
|
||||
while ( 0 < ( getline < "/proc/stat" ) )
|
||||
{
|
||||
if ( "cpu" == $1 )
|
||||
{
|
||||
TotalCPUTime = $2 + $3 + $4;
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
close("/proc/stat");
|
||||
|
||||
#printf "USER_HZ = %d\n", USER_HZ | "cat 1>&2";
|
||||
TotalCPUTime /= USER_HZ;
|
||||
printf "%f\n", TotalCPUTime;
|
||||
|
||||
#close("cat 1>&2");
|
||||
}'
|
||||
</action>
|
||||
</metric>
|
||||
<!-- SAP "CIM" -->
|
||||
<metric type="real64" context="vm">
|
||||
<name>TotalCPUTime</name>
|
||||
<action>
|
||||
virsh -r CONNECT dominfo NAME \
|
||||
|awk -F ':' '
|
||||
function mkvarnam(s) { # UPPER_CASE_UNDERSCORE
|
||||
sub("(^[[:space:]]+|[[:space:]]+$)", "", s); # trim
|
||||
gsub("[[:space:]]+", "_", s); s = toupper(s);
|
||||
return s;
|
||||
}
|
||||
function filt_phys(s, sep, num, unit) { # 42.0 KM
|
||||
sub("(^[[:space:]]+|[[:space:]]+$)", "", s); # trim
|
||||
if ( s ~ /^[0-9]*\.?[0-9]+[[:space:]]*[[:alpha:]]+$/ )
|
||||
{
|
||||
num = s; unit = s;
|
||||
sub("[[:space:]]*[[:alpha:]]+$", "", num);
|
||||
sub("^[0-9]*[.]?[0-9]+[[:space:]]*", "", unit);
|
||||
return num sep toupper(unit);
|
||||
}
|
||||
else
|
||||
{
|
||||
return s;
|
||||
}
|
||||
}
|
||||
/:/ {
|
||||
d1 = substr($0, 1, index($0, ":") - 1);
|
||||
rest = substr($0, index($0, ":") + 1);
|
||||
printf("%s:%s\n", mkvarnam(d1), filt_phys(rest, ":"));
|
||||
}' \
|
||||
| awk -F: '$1 == "CPU_TIME" { print $2; }'
|
||||
</action>
|
||||
</metric>
|
||||
<!-- SAP "CIM" -->
|
||||
<metric type="uint32" context="vm">
|
||||
<name>ResourceProcessorLimit</name>
|
||||
<action>
|
||||
virsh -r CONNECT dominfo NAME \
|
||||
|awk -F ':' '
|
||||
function mkvarnam(s) { # UPPER_CASE_UNDERSCORE
|
||||
sub("(^[[:space:]]+|[[:space:]]+$)", "", s); # trim
|
||||
gsub("[[:space:]]+", "_", s); s = toupper(s);
|
||||
return s;
|
||||
}
|
||||
function filt_phys(s, sep, num, unit) { # 42.0 KM
|
||||
sub("(^[[:space:]]+|[[:space:]]+$)", "", s); # trim
|
||||
if ( s ~ /^[0-9]*\.?[0-9]+[[:space:]]*[[:alpha:]]+$/ )
|
||||
{
|
||||
num = s; unit = s;
|
||||
sub("[[:space:]]*[[:alpha:]]+$", "", num);
|
||||
sub("^[0-9]*[.]?[0-9]+[[:space:]]*", "", unit);
|
||||
return num sep toupper(unit);
|
||||
}
|
||||
else
|
||||
{
|
||||
return s;
|
||||
}
|
||||
}
|
||||
/:/ {
|
||||
d1 = substr($0, 1, index($0, ":") - 1);
|
||||
rest = substr($0, index($0, ":") + 1);
|
||||
printf("%s:%s\n", mkvarnam(d1), filt_phys(rest, ":"));
|
||||
}' \
|
||||
| awk -F: '$1 == "CPU(S)" { print $2; }'
|
||||
</action>
|
||||
</metric>
|
||||
<!-- SAP "CIM" -->
|
||||
<metric type="uint64" context="vm">
|
||||
<name>ResourceMemoryLimit</name>
|
||||
<action>
|
||||
virsh -r CONNECT dominfo NAME \
|
||||
|awk -F ':' '
|
||||
function mkvarnam(s) { # UPPER_CASE_UNDERSCORE
|
||||
sub("(^[[:space:]]+|[[:space:]]+$)", "", s); # trim
|
||||
gsub("[[:space:]]+", "_", s); s = toupper(s);
|
||||
return s;
|
||||
}
|
||||
function filt_phys(s, sep, num, unit) { # 42.0 KM
|
||||
sub("(^[[:space:]]+|[[:space:]]+$)", "", s); # trim
|
||||
if ( s ~ /^[0-9]*\.?[0-9]+[[:space:]]*[[:alpha:]]+$/ )
|
||||
{
|
||||
num = s; unit = s;
|
||||
sub("[[:space:]]*[[:alpha:]]+$", "", num);
|
||||
sub("^[0-9]*[.]?[0-9]+[[:space:]]*", "", unit);
|
||||
return num sep toupper(unit);
|
||||
}
|
||||
else
|
||||
{
|
||||
return s;
|
||||
}
|
||||
}
|
||||
/:/ {
|
||||
d1 = substr($0, 1, index($0, ":") - 1);
|
||||
rest = substr($0, index($0, ":") + 1);
|
||||
printf("%s:%s\n", mkvarnam(d1), filt_phys(rest, ":"));
|
||||
}' \
|
||||
| awk -F: '$1 == "MAX_MEMORY" { print int($2/1024); }'
|
||||
</action>
|
||||
</metric>
|
||||
<!-- SAP "CIM" -->
|
||||
<metric type="uint64" context="vm">
|
||||
<name>PhysicalMemoryAllocatedToVirtualSystem</name>
|
||||
<action>
|
||||
virsh -r CONNECT dominfo NAME \
|
||||
|awk -F ':' '
|
||||
function mkvarnam(s) { # UPPER_CASE_UNDERSCORE
|
||||
sub("(^[[:space:]]+|[[:space:]]+$)", "", s); # trim
|
||||
gsub("[[:space:]]+", "_", s); s = toupper(s);
|
||||
return s;
|
||||
}
|
||||
function filt_phys(s, sep, num, unit) { # 42.0 KM
|
||||
sub("(^[[:space:]]+|[[:space:]]+$)", "", s); # trim
|
||||
if ( s ~ /^[0-9]*\.?[0-9]+[[:space:]]*[[:alpha:]]+$/ )
|
||||
{
|
||||
num = s; unit = s;
|
||||
sub("[[:space:]]*[[:alpha:]]+$", "", num);
|
||||
sub("^[0-9]*[.]?[0-9]+[[:space:]]*", "", unit);
|
||||
return num sep toupper(unit);
|
||||
}
|
||||
else
|
||||
{
|
||||
return s;
|
||||
}
|
||||
}
|
||||
/:/ {
|
||||
d1 = substr($0, 1, index($0, ":") - 1);
|
||||
rest = substr($0, index($0, ":") + 1);
|
||||
printf("%s:%s\n", mkvarnam(d1), filt_phys(rest, ":"));
|
||||
}' \
|
||||
| awk -F: '$1 == "USED_MEMORY" { print int($2/1024); }'
|
||||
</action>
|
||||
</metric>
|
||||
</metrics>
|
||||
</vhostmd>
|
||||
<!--
|
||||
vi:ts=2:sw=2:expandtab:ignorecase:nu:ruler
|
||||
-->
|
||||
<!-- EOF -->
|
||||
118
SOURCES/vhostmd.init
Normal file
118
SOURCES/vhostmd.init
Normal file
@ -0,0 +1,118 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# vhostmd: Virtualization host metrics daemon
|
||||
#
|
||||
# chkconfig: - 98 02
|
||||
# description: This daemon allows access to host information from guests.
|
||||
|
||||
### BEGIN INIT INFO
|
||||
# Provides: vhostmd
|
||||
# Required-Start: libvirtd
|
||||
# Required-Stop: libvirtd
|
||||
# Default-Stop:
|
||||
# Short-Description: Virtualization host metrics daemon
|
||||
# Description: This daemon allows access to host information from guests.
|
||||
### END INIT INFO
|
||||
|
||||
# Source function library.
|
||||
. /etc/rc.d/init.d/functions
|
||||
|
||||
exec=/usr/sbin/vhostmd
|
||||
prog=vhostmd
|
||||
config=/etc/vhostmd/vhostmd.conf
|
||||
|
||||
[ -e /etc/sysconfig/$prog ] && . /etc/sysconfig/$prog
|
||||
|
||||
ARGS=
|
||||
if [ -n "$VHOSTMD_VERBOSE" ]; then
|
||||
ARGS="$ARGS --verbose"
|
||||
fi
|
||||
if [ -n "$VHOSTMD_CONFIG" ]; then
|
||||
ARGS="$ARGS --config $VHOSTMD_CONFIG"
|
||||
fi
|
||||
if [ -n "$VHOSTMD_USER" ]; then
|
||||
ARGS="$ARGS --user $VHOSTMD_USER"
|
||||
fi
|
||||
if [ -n "$VHOSTMD_URI" ]; then
|
||||
ARGS="$ARGS --connect $VHOSTMD_URI"
|
||||
elif virsh uri >/dev/null 2>&1; then
|
||||
default_uri=$(virsh uri)
|
||||
ARGS="$ARGS --connect '$default_uri'"
|
||||
fi
|
||||
|
||||
lockfile=/var/lock/subsys/$prog
|
||||
|
||||
start() {
|
||||
[ -x $exec ] || exit 5
|
||||
[ -f $config ] || exit 6
|
||||
echo -n $"Starting $prog: "
|
||||
daemon $exec $ARGS
|
||||
retval=$?
|
||||
echo
|
||||
[ $retval -eq 0 ] && touch $lockfile
|
||||
return $retval
|
||||
}
|
||||
|
||||
stop() {
|
||||
echo -n $"Stopping $prog: "
|
||||
killproc $prog
|
||||
rm -f /var/run/$prog.pid
|
||||
retval=$?
|
||||
echo
|
||||
[ $retval -eq 0 ] && rm -f $lockfile
|
||||
return $retval
|
||||
}
|
||||
|
||||
restart() {
|
||||
stop
|
||||
start
|
||||
}
|
||||
|
||||
reload() {
|
||||
restart
|
||||
}
|
||||
|
||||
force_reload() {
|
||||
restart
|
||||
}
|
||||
|
||||
rh_status() {
|
||||
status $prog
|
||||
}
|
||||
|
||||
rh_status_q() {
|
||||
rh_status >/dev/null 2>&1
|
||||
}
|
||||
|
||||
|
||||
case "$1" in
|
||||
start)
|
||||
rh_status_q && exit 0
|
||||
$1
|
||||
;;
|
||||
stop)
|
||||
rh_status_q || exit 0
|
||||
$1
|
||||
;;
|
||||
restart)
|
||||
$1
|
||||
;;
|
||||
reload)
|
||||
rh_status_q || exit 7
|
||||
$1
|
||||
;;
|
||||
force-reload)
|
||||
force_reload
|
||||
;;
|
||||
status)
|
||||
rh_status
|
||||
;;
|
||||
condrestart|try-restart)
|
||||
rh_status_q || exit 0
|
||||
restart
|
||||
;;
|
||||
*)
|
||||
echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload}"
|
||||
exit 2
|
||||
esac
|
||||
exit $?
|
||||
14
SOURCES/vhostmd.sysconfig
Normal file
14
SOURCES/vhostmd.sysconfig
Normal file
@ -0,0 +1,14 @@
|
||||
# Uncomment the following line to print verbose messages.
|
||||
#VHOSTMD_VERBOSE=1
|
||||
|
||||
# Override the default configuration file path.
|
||||
#VHOSTMD_CONFIG=/path/to/vhostmd.conf
|
||||
|
||||
# Set the user that the daemon runs as after dropping root privs.
|
||||
VHOSTMD_USER=vhostmd
|
||||
|
||||
# Set the libvirt URI.
|
||||
# Choose between KVM and Xen here. If both are commented out then
|
||||
# the libvirt default URI will be used.
|
||||
VHOSTMD_URI=qemu:///system
|
||||
#VHOSTMD_URI=xen:///
|
||||
323
SPECS/vhostmd.spec
Normal file
323
SPECS/vhostmd.spec
Normal file
@ -0,0 +1,323 @@
|
||||
%global have_xen 0
|
||||
|
||||
Summary: Virtualization host metrics daemon
|
||||
Name: vhostmd
|
||||
Version: 0.5
|
||||
Release: 18%{?dist}
|
||||
License: GPLv2+
|
||||
|
||||
URL: http://gitorious.org/vhostmd
|
||||
|
||||
# Upstream tarball hosting is screwed at the moment. This release is
|
||||
# of the 0.5 branch, with 'make dist' done by the packager.
|
||||
Source0: vhostmd-%{version}.tar.bz2
|
||||
Source1: vhostmd.init
|
||||
Source2: vhostmd.sysconfig
|
||||
Source3: vhostmd.conf
|
||||
|
||||
# These commits have been added upstream since vhostmd 0.5 was
|
||||
# released.
|
||||
Patch0001: 0001-Security-Set-supplemental-groups-correctly-when-drop.patch
|
||||
Patch0002: 0002-libmetrics-Return-error-indication-up-through-get_me.patch
|
||||
Patch0003: 0003-Make-Xen-Libraries-really-optional.patch
|
||||
Patch0004: 0004-Add-contact-info-to-README.patch
|
||||
Patch0005: 0005-Fix-name-and-location-of-the-vhostmd.conf-file.patch
|
||||
Patch0006: 0006-fix-typo-in-vhostmd.init-virutalization.patch
|
||||
Patch0007: 0007-Modernize-build-files.patch
|
||||
Patch0008: 0008-Add-systemd-service-file.patch
|
||||
Patch0009: 0009-Remove-xenctrl-support.patch
|
||||
Patch0010: 0010-Remove-support-for-libxenstat.patch
|
||||
Patch0011: 0011-Fix-compilation-with-xenstore.patch
|
||||
Patch0012: 0012-Fix-typo-in-systemd-service-file.patch
|
||||
Patch0013: 0013-Fix-help-option.patch
|
||||
Patch0014: 0014-Add-SIGPIPE-handler-and-reconnect.patch
|
||||
Patch0015: 0015-fix-deallocation-in-vu_vm_free.patch
|
||||
Patch0016: 0016-configure-fix-logic-in-init-script-check.patch
|
||||
Patch0017: 0017-conf-Improve-example-configuration-file.patch
|
||||
|
||||
BuildRequires: gcc
|
||||
BuildRequires: chrpath
|
||||
BuildRequires: perl-generators
|
||||
BuildRequires: pkgconfig
|
||||
BuildRequires: libxml2-devel
|
||||
BuildRequires: libvirt-devel
|
||||
BuildRequires: autoconf, automake, libtool
|
||||
BuildRequires: git
|
||||
%{?systemd_requires}
|
||||
BuildRequires: systemd
|
||||
|
||||
%if %{have_xen}
|
||||
BuildRequires: xen-devel
|
||||
%endif
|
||||
|
||||
|
||||
%description
|
||||
vhostmd provides a "metrics communication channel" between a host and
|
||||
its hosted virtual machines, allowing limited introspection of host
|
||||
resource usage from within virtual machines.
|
||||
|
||||
|
||||
%package -n vm-dump-metrics
|
||||
Summary: Virtualization host metrics dump
|
||||
|
||||
|
||||
%description -n vm-dump-metrics
|
||||
Executable to dump all available virtualization host metrics to stdout
|
||||
or a file.
|
||||
|
||||
|
||||
%package -n vm-dump-metrics-devel
|
||||
Summary: Virtualization host metrics dump development
|
||||
Requires: vm-dump-metrics = %{version}-%{release}
|
||||
Requires: pkgconfig
|
||||
|
||||
|
||||
%description -n vm-dump-metrics-devel
|
||||
Header and libraries necessary for metrics gathering development
|
||||
|
||||
|
||||
%prep
|
||||
%autosetup -S git
|
||||
|
||||
|
||||
%build
|
||||
autoreconf -i
|
||||
%configure \
|
||||
%if %{have_xen} == 0
|
||||
--without-xenstore \
|
||||
%endif
|
||||
--with-init-script=systemd \
|
||||
--enable-shared --disable-static
|
||||
make %{_smp_mflags}
|
||||
|
||||
|
||||
%install
|
||||
rm -rf $RPM_BUILD_ROOT
|
||||
|
||||
make DESTDIR=$RPM_BUILD_ROOT install
|
||||
|
||||
#rm $RPM_BUILD_ROOT%{_libdir}/libmetrics.a
|
||||
rm $RPM_BUILD_ROOT%{_libdir}/libmetrics.la
|
||||
|
||||
chrpath --delete $RPM_BUILD_ROOT%{_sbindir}/vm-dump-metrics
|
||||
|
||||
# Remove docdir - we'll make a proper one ourselves.
|
||||
rm -r $RPM_BUILD_ROOT%{_docdir}/vhostmd
|
||||
|
||||
# Remove metric.dtd from /etc.
|
||||
rm $RPM_BUILD_ROOT%{_sysconfdir}/vhostmd/metric.dtd
|
||||
|
||||
# The default configuration file is great for Xen, not so great
|
||||
# for anyone else. Replace it with one which is better for libvirt
|
||||
# users.
|
||||
rm $RPM_BUILD_ROOT%{_sysconfdir}/vhostmd/vhostmd.conf
|
||||
cp %{SOURCE3} $RPM_BUILD_ROOT%{_sysconfdir}/vhostmd/vhostmd.conf
|
||||
|
||||
%if 0%{?rhel}
|
||||
# Remove Perl script (https://bugzilla.redhat.com/show_bug.cgi?id=749875)
|
||||
rm $RPM_BUILD_ROOT%{_datadir}/vhostmd/scripts/pagerate.pl
|
||||
%endif
|
||||
|
||||
|
||||
%pre
|
||||
# UID:GID 112:112 reserved, see RHBZ#534109.
|
||||
getent group vhostmd >/dev/null || groupadd -g 112 -r vhostmd
|
||||
getent passwd vhostmd >/dev/null || \
|
||||
useradd -u 112 -r -g vhostmd -d %{_datadir}/vhostmd -s /sbin/nologin \
|
||||
-c "Virtual Host Metrics Daemon" vhostmd
|
||||
exit 0
|
||||
|
||||
|
||||
%post
|
||||
%systemd_post vhostmd.service
|
||||
|
||||
|
||||
%preun
|
||||
%systemd_preun vhostmd.service
|
||||
|
||||
|
||||
%postun
|
||||
%systemd_postun_with_restart vhostmd.service
|
||||
|
||||
|
||||
%files
|
||||
%doc AUTHORS ChangeLog COPYING README
|
||||
%doc mdisk.xml metric.dtd vhostmd.dtd vhostmd.xml
|
||||
|
||||
%{_sbindir}/vhostmd
|
||||
|
||||
%dir %{_sysconfdir}/vhostmd
|
||||
%config(noreplace) %{_sysconfdir}/vhostmd/vhostmd.conf
|
||||
%config %{_sysconfdir}/vhostmd/vhostmd.dtd
|
||||
|
||||
%{_unitdir}/vhostmd.service
|
||||
|
||||
%dir %{_datadir}/vhostmd
|
||||
%dir %{_datadir}/vhostmd/scripts
|
||||
%if !0%{?rhel}
|
||||
%{_datadir}/vhostmd/scripts/pagerate.pl
|
||||
%endif
|
||||
|
||||
%{_mandir}/man8/vhostmd.8.gz
|
||||
|
||||
|
||||
%files -n vm-dump-metrics
|
||||
%doc COPYING
|
||||
%{_sbindir}/vm-dump-metrics
|
||||
%{_libdir}/libmetrics.so.0
|
||||
%{_libdir}/libmetrics.so.0.0.0
|
||||
%{_mandir}/man1/vm-dump-metrics.1.gz
|
||||
|
||||
|
||||
%files -n vm-dump-metrics-devel
|
||||
%doc README
|
||||
%{_libdir}/libmetrics.so
|
||||
%dir %{_includedir}/vhostmd
|
||||
%{_includedir}/vhostmd/libmetrics.h
|
||||
|
||||
|
||||
%changelog
|
||||
* Tue Oct 16 2018 Richard W.M. Jones <rjones@redhat.com> - 0.5-19
|
||||
- Include all upstream patches since 0.5.
|
||||
- Enable systemd init scripts (RHBZ#1592400).
|
||||
|
||||
* Sat Jul 14 2018 Fedora Release Engineering <releng@fedoraproject.org> - 0.5-18
|
||||
- Rebuilt for https://fedoraproject.org/wiki/Fedora_29_Mass_Rebuild
|
||||
|
||||
* Thu Jul 05 2018 Richard W.M. Jones <rjones@redhat.com> - 0.5-17
|
||||
- Remove ldconfig
|
||||
https://lists.fedoraproject.org/archives/list/devel@lists.fedoraproject.org/thread/SU3LJVDZ7LUSJGZR5MS72BMRAFP3PQQL/
|
||||
|
||||
* Fri Feb 09 2018 Igor Gnatenko <ignatenkobrain@fedoraproject.org> - 0.5-16
|
||||
- Escape macros in %%changelog
|
||||
|
||||
* Thu Aug 03 2017 Fedora Release Engineering <releng@fedoraproject.org> - 0.5-15
|
||||
- Rebuilt for https://fedoraproject.org/wiki/Fedora_27_Binutils_Mass_Rebuild
|
||||
|
||||
* Thu Jul 27 2017 Fedora Release Engineering <releng@fedoraproject.org> - 0.5-14
|
||||
- Rebuilt for https://fedoraproject.org/wiki/Fedora_27_Mass_Rebuild
|
||||
|
||||
* Sat Feb 11 2017 Fedora Release Engineering <releng@fedoraproject.org> - 0.5-13
|
||||
- Rebuilt for https://fedoraproject.org/wiki/Fedora_26_Mass_Rebuild
|
||||
|
||||
* Fri Feb 05 2016 Fedora Release Engineering <releng@fedoraproject.org> - 0.5-12
|
||||
- Rebuilt for https://fedoraproject.org/wiki/Fedora_24_Mass_Rebuild
|
||||
|
||||
* Tue Jan 26 2016 Richard Jones <rjones@redhat.com> - 0.5-11
|
||||
- Remove useless defattr in files section.
|
||||
|
||||
* Fri Jun 19 2015 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 0.5-10
|
||||
- Rebuilt for https://fedoraproject.org/wiki/Fedora_23_Mass_Rebuild
|
||||
|
||||
* Mon Aug 18 2014 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 0.5-9
|
||||
- Rebuilt for https://fedoraproject.org/wiki/Fedora_21_22_Mass_Rebuild
|
||||
|
||||
* Sun Jun 08 2014 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 0.5-8
|
||||
- Rebuilt for https://fedoraproject.org/wiki/Fedora_21_Mass_Rebuild
|
||||
|
||||
* Sat Aug 03 2013 Petr Pisar <ppisar@redhat.com> - 0.5-7
|
||||
- Perl 5.18 rebuild
|
||||
|
||||
* Mon Jul 29 2013 Richard W.M. Jones <rjones@redhat.com> - 0.5-6
|
||||
- Completely disable Xen. APIs seem to have changed incompatibly.
|
||||
- Add commits from upstream since 0.5.
|
||||
- Remove pagerate.pl when building on RHEL.
|
||||
- Modernize the spec file.
|
||||
|
||||
* Wed Jul 17 2013 Petr Pisar <ppisar@redhat.com> - 0.5-5
|
||||
- Perl 5.18 rebuild
|
||||
|
||||
* Thu May 23 2013 Richard W.M. Jones <rjones@redhat.com> - 0.5-4
|
||||
- Disable Xen support on RHEL >= 6 (RHBZ#927853).
|
||||
|
||||
* Fri Feb 15 2013 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 0.5-3
|
||||
- Rebuilt for https://fedoraproject.org/wiki/Fedora_19_Mass_Rebuild
|
||||
|
||||
* Sun Jul 22 2012 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 0.5-2
|
||||
- Rebuilt for https://fedoraproject.org/wiki/Fedora_18_Mass_Rebuild
|
||||
|
||||
* Mon Jan 16 2012 Richard W.M. Jones <rjones@redhat.com> - 0.5-1
|
||||
- New upstream version 0.5.
|
||||
- Remove -ldl patch which is now upstream.
|
||||
|
||||
* Sat Jan 14 2012 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 0.4-13
|
||||
- Rebuilt for https://fedoraproject.org/wiki/Fedora_17_Mass_Rebuild
|
||||
|
||||
* Mon Feb 07 2011 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 0.4-12
|
||||
- Rebuilt for https://fedoraproject.org/wiki/Fedora_15_Mass_Rebuild
|
||||
|
||||
* Fri Jul 23 2010 Richard W.M. Jones <rjones@redhat.com> - 0.4-11
|
||||
- /etc/sysconfig/vhostmd: Default to KVM.
|
||||
|
||||
* Tue Jul 13 2010 Richard W.M. Jones <rjones@redhat.com> - 0.4-10
|
||||
- Patch Makefile.in directly so we don't need to run autotools.
|
||||
|
||||
* Tue Jul 6 2010 Richard W.M. Jones <rjones@redhat.com> - 0.4-9
|
||||
- Updated vhostmd.conf from Dr. Joachim Schneider at SAP.
|
||||
- Run aclocal.
|
||||
|
||||
* Tue Apr 27 2010 Richard W.M. Jones <rjones@redhat.com> - 0.4-6
|
||||
- Updated vhostmd.conf file which enables TotalCPUTime metric.
|
||||
|
||||
* Tue Feb 16 2010 Richard W.M. Jones <rjones@redhat.com> - 0.4-5
|
||||
- Add a patch to link tests explicitly with -ldl (RHBZ#565096).
|
||||
|
||||
* Thu Dec 10 2009 Richard W.M. Jones <rjones@redhat.com> - 0.4-2
|
||||
- Fix the PagedOutMemory and PagedInMemory stats to report MB instead
|
||||
of pages (fixes supplied by Joachim Schneider).
|
||||
|
||||
* Wed Dec 9 2009 Richard W.M. Jones <rjones@redhat.com> - 0.4-1
|
||||
- vhostmd didn't chdir ("/") when daemonizing. Fixed in this 0.4 release.
|
||||
|
||||
* Tue Nov 17 2009 Richard W.M. Jones <rjones@redhat.com> - 0.4-0.9.gite9db007b
|
||||
- Add a timestamp to the metrics.
|
||||
- Fix a typo in MemoryAllocatedToVirtualServers metric
|
||||
(https://bugzilla.redhat.com/show_bug.cgi?id=532070#c7)
|
||||
- %%{_sysconfdir}/sysconfig/vhostmd: Use libvirt default URI
|
||||
(https://bugzilla.redhat.com/show_bug.cgi?id=537828)
|
||||
- %%{_sysconfdir}/init.d/vhostmd: If using libvirt's default URI, then pass
|
||||
the root URI to vhostmd (the default URI changes in some circumstances
|
||||
when vhostmd switches to the non-root user).
|
||||
|
||||
* Wed Nov 11 2009 Richard W.M. Jones <rjones@redhat.com> - 0.4-0.8.gite9db007b
|
||||
- Use fixed UID:GID 112:112 (RHBZ#534109).
|
||||
|
||||
* Tue Nov 10 2009 Richard W.M. Jones <rjones@redhat.com> - 0.4-0.7.gite9db007b
|
||||
- vm-dump-metrics-devel package should require version and release of
|
||||
base package.
|
||||
|
||||
* Mon Nov 2 2009 Richard W.M. Jones <rjones@redhat.com> - 0.4-0.6.gite9db007b
|
||||
- Some changes to the default configuration file suggested by SAP to
|
||||
make it more CIM standards compliant.
|
||||
|
||||
* Fri Oct 16 2009 Richard W.M. Jones <rjones@redhat.com> - 0.4-0.5.gite9db007b
|
||||
- New upstream based on git e9db007b.
|
||||
- Fix segfault in vm-dump-metrics (RHBZ#529348).
|
||||
- On error, vm-dump-metrics now exits with status code 1.
|
||||
|
||||
* Thu Oct 15 2009 Richard W.M. Jones <rjones@redhat.com> - 0.4-0.2.gitea2f772d
|
||||
- New upstream based on git ea2f772d.
|
||||
- Update the configuration file based on upstream changes to how virsh
|
||||
has to be run.
|
||||
- vhostmd should run non-root as user 'vhostmd'.
|
||||
- Allow libvirt URI to be configured.
|
||||
|
||||
* Tue Oct 13 2009 Richard W.M. Jones <rjones@redhat.com> - 0.4-0.1.git326f0012172
|
||||
- Move to pre-release of 0.4, self-built tarball.
|
||||
- Disable xenstore on non-x86 platforms.
|
||||
- Add patch to fix --without-xenstore option.
|
||||
- Use have_xen RPM macro.
|
||||
|
||||
* Mon Oct 12 2009 Richard W.M. Jones <rjones@redhat.com> - 0.3-3
|
||||
- Remove metric.dtd file from /etc (fixes rpmlint warning), but
|
||||
vhostmd.dtd has to remain because it is needed to validate the
|
||||
XML configuration file.
|
||||
- Remove ExclusiveArch, instead conditionally depend on xen-devel.
|
||||
- Use a better, less noisy, more minimal configuration file which
|
||||
doesn't depend on Xen.
|
||||
|
||||
* Thu Oct 8 2009 Richard W.M. Jones <rjones@redhat.com> - 0.3-1
|
||||
- New upstream version 0.3.
|
||||
|
||||
* Fri Aug 14 2009 Richard W.M. Jones <rjones@redhat.com> - 0.2-1
|
||||
- Initial packaging for Fedora, based on SuSE package.
|
||||
Loading…
Reference in New Issue
Block a user