diff --git a/.gitignore b/.gitignore index cac46c7..50a82e8 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1 @@ -SOURCES/vhostmd-1.1.tar.gz +vhostmd-1.2.tar.gz diff --git a/.vhostmd.metadata b/.vhostmd.metadata deleted file mode 100644 index 97fa25d..0000000 --- a/.vhostmd.metadata +++ /dev/null @@ -1 +0,0 @@ -93e6bbbf15be248e7da222d377d2b98fb4c2be24 SOURCES/vhostmd-1.1.tar.gz diff --git a/0001-Add-channel_path-setting-to-daemon-config-file.patch b/0001-Add-channel_path-setting-to-daemon-config-file.patch new file mode 100644 index 0000000..e4212ea --- /dev/null +++ b/0001-Add-channel_path-setting-to-daemon-config-file.patch @@ -0,0 +1,137 @@ +commit 5a04b59495490bf921c661ff95754ea9955e7cd4 +Author: Jim Fehlig +Date: Fri Sep 27 09:20:52 2024 -0600 + + Add channel_path setting to daemon config file + + libvirt commit 8abc979b moved the target path for channel devices. + To accommodate libvirt deployments with and without that commit, + allow specifying the path in the daemon configuration file. + + Signed-off-by: Jim Fehlig +diff --git a/README b/README +index 579acd5..2ff7e8b 100644 +--- a/README ++++ b/README +@@ -51,6 +51,7 @@ includes a few examples of user-defined metrics, which provide a + 256 + + ++ /var/run/libvirt/qemu/channel + 1024 + 15 + +@@ -300,6 +301,8 @@ between the host and VMs. Basically for a virtio serial device, QEMU creates + - 'connects' both to a 'communication channel' + + It can be configured in the virtio section of the vhostmd configuration file. ++ defines a path on the host where QEMU creates the unix domain ++sockets. + defines the maximum number of virtio channels/VMs supported + by the vhostmd instance with a default value of 1024. + is the time after which the virtio serial channel of a VM +diff --git a/include/virtio.h b/include/virtio.h +index 1ff31a2..962adea 100644 +--- a/include/virtio.h ++++ b/include/virtio.h +@@ -24,7 +24,7 @@ + /* + * Initialize virtio layer + */ +-int virtio_init(int max_channel, int expiration_period); ++int virtio_init(char *channel_path, int max_channel, int expiration_period); + + /* + * Main virtio function +diff --git a/vhostmd.dtd b/vhostmd.dtd +index 6c159dd..045860d 100644 +--- a/vhostmd.dtd ++++ b/vhostmd.dtd +@@ -20,7 +20,8 @@ Virtual Host Metrics Daemon (vhostmd). Configuration file DTD + + + +- ++ ++ + + + +diff --git a/vhostmd.xml b/vhostmd.xml +index 5c88d8c..0dff85d 100644 +--- a/vhostmd.xml ++++ b/vhostmd.xml +@@ -34,6 +34,7 @@ the logical && operator must be replaced with "&&". + 256 + + ++ /var/run/libvirt/qemu/channel + 1024 + 15 + +diff --git a/vhostmd/vhostmd.c b/vhostmd/vhostmd.c +index 4426faf..88e89ac 100644 +--- a/vhostmd/vhostmd.c ++++ b/vhostmd/vhostmd.c +@@ -105,6 +105,7 @@ static mdisk_header md_header = + }; + static char *search_path = NULL; + static int transports = 0; ++static char *virtio_channel_path = NULL; + static int virtio_max_channels = 1024; + static int virtio_expiration_time = 15; + +@@ -623,7 +624,14 @@ static int parse_config_file(const char *filename) + } + + if (transports & VIRTIO) { +- if (vu_xpath_long("string(./globals/virtio/max_channels[1])", ctxt, &l) == 0) ++ virtio_channel_path = vu_xpath_string("string(./globals/virtio/channel_path[1])", ctxt); ++ if (virtio_channel_path == NULL) { ++ virtio_channel_path = strdup("/var/lib/libvirt/qemu/channel/target"); ++ if (virtio_channel_path == NULL) ++ goto out; ++ } ++ ++ if (vu_xpath_long("string(./globals/virtio/max_channels[1])", ctxt, &l) == 0) + virtio_max_channels = (int)l; + + if (vu_xpath_long("string(./globals/virtio/expiration_time[1])", ctxt, &l) == 0) +@@ -980,7 +988,7 @@ static int vhostmd_run(int diskfd) + if (virtio_expiration_time < (update_period * 3)) + virtio_expiration_time = update_period * 3; + +- if (virtio_init(virtio_max_channels, virtio_expiration_time)) { ++ if (virtio_init(virtio_channel_path, virtio_max_channels, virtio_expiration_time)) { + vu_buffer_delete(buf); + return -1; + } +diff --git a/vhostmd/virtio.c b/vhostmd/virtio.c +index 98340ce..d2d07bf 100644 +--- a/vhostmd/virtio.c ++++ b/vhostmd/virtio.c +@@ -68,7 +68,7 @@ static channel_t *channel = NULL; + static id_map_t *id_map = NULL; + static time_t exp_period = 0; + +-static const char *channel_path = "/var/lib/libvirt/qemu/channel/target"; ++static const char *channel_path = NULL; + static const char *channel_name = "org.github.vhostmd.1"; + static int channel_max = 0; + static volatile int channel_count = 0; +@@ -572,13 +572,14 @@ static void vio_handle_io(unsigned epoll_wait_ms) + * Once the channel is added to epoll the vu_buffer can be accessed + * by the epoll_event.data.ptr. + */ +-int virtio_init(int _max_channel, int _expiration_period) ++int virtio_init(char *_channel_path, int _max_channel, int _expiration_period) + { + int i; + + if (virtio_status == VIRTIO_INIT) { + pthread_mutex_init(&channel_mtx, NULL); + ++ channel_path = _channel_path; + channel_max = _max_channel; + exp_period = _expiration_period; + channel_count = 0; diff --git a/0002-Support-libvirts-new-channel-path-naming-scheme.patch b/0002-Support-libvirts-new-channel-path-naming-scheme.patch new file mode 100644 index 0000000..9e491f1 --- /dev/null +++ b/0002-Support-libvirts-new-channel-path-naming-scheme.patch @@ -0,0 +1,77 @@ +commit 176fcda44caca807b4bec9fd613991afd9d5a70b +Author: Jim Fehlig +Date: Fri Sep 27 10:48:41 2024 -0600 + + Support libvirt's new channel path naming scheme + + libvirt commit 8abc979bb0 changed the channel path naming scheme from + domain-- to -. Change the logic searching for channels + to work with either scheme. + + Signed-off-by: Jim Fehlig +diff --git a/vhostmd/virtio.c b/vhostmd/virtio.c +index d2d07bf..4516b1f 100644 +--- a/vhostmd/virtio.c ++++ b/vhostmd/virtio.c +@@ -277,34 +277,37 @@ static int vio_readdir(const char * path) + } + + while ((ent = readdir(dir)) != NULL) { +- int rc, id; +- +- if (sscanf(ent->d_name, "domain-%d-", &id) == 1) { +- +- char tmp[SUN_PATH_LEN + 8]; +- struct stat st; +- +- rc = snprintf(tmp, sizeof(tmp), "%s/%s/%s", path, ent->d_name, channel_name); ++ char tmp[SUN_PATH_LEN + 8]; ++ struct stat st; ++ char *name = NULL; ++ int id = -1; ++ int rc; ++ channel_t *c = NULL; ++ ++ if (sscanf(ent->d_name, "domain-%d-", &id) == 1) ++ name = strchr(&(ent->d_name[strlen("domain-")]), '-'); ++ else if (sscanf(ent->d_name, "%d-", &id) == 1) ++ name = strchr(ent->d_name, '-'); ++ else ++ continue; + +- if (rc > 0 && rc < (int) sizeof(tmp) && +- strlen(tmp) < SUN_PATH_LEN && +- stat(tmp, &st) == 0 && +- S_ISSOCK(st.st_mode)) { ++ rc = snprintf(tmp, sizeof(tmp), "%s/%s/%s", path, ent->d_name, channel_name); + +- channel_t *c = NULL; +- const char *name = strchr(&(ent->d_name[strlen("domain-")]), '-'); ++ if (rc > 0 && rc < (int) sizeof(tmp) && ++ strlen(tmp) < SUN_PATH_LEN && ++ stat(tmp, &st) == 0 && ++ S_ISSOCK(st.st_mode)) { + +- pthread_mutex_lock(&channel_mtx); +- c = vio_channel_find(id, name, 0); +- pthread_mutex_unlock(&channel_mtx); ++ pthread_mutex_lock(&channel_mtx); ++ c = vio_channel_find(id, name, 0); ++ pthread_mutex_unlock(&channel_mtx); + +- if (c && c->fd == FREE) { +- c->uds_name = strdup(tmp); +- if (c->uds_name == NULL) +- goto error; +- if (vio_channel_open(c)) +- goto error; +- } ++ if (c && c->fd == FREE) { ++ c->uds_name = strdup(tmp); ++ if (c->uds_name == NULL) ++ goto error; ++ if (vio_channel_open(c)) ++ goto error; + } + } + } diff --git a/0003-Fix-parsing-of-vmstat-output.patch b/0003-Fix-parsing-of-vmstat-output.patch new file mode 100644 index 0000000..f9d28bf --- /dev/null +++ b/0003-Fix-parsing-of-vmstat-output.patch @@ -0,0 +1,31 @@ +commit 9d282891eaaeebf1b94c67314d97e55a0b58d9c2 (HEAD -> master, origin/master, origin/HEAD) +Author: Jim Fehlig +Date: Fri Sep 27 13:25:58 2024 -0600 + + Fix parsing of vmstat output + + The output of `vmstat -s`, which is used to calculate the Paged{In,Out}Memory + metrics, changed from "pages paged {in,out}" to "K paged {in,out}" in procps4. + Change the associated actions to match against the new output. + + Signed-off-by: Jim Fehlig +diff --git a/vhostmd.xml b/vhostmd.xml +index 0dff85d..c957d1d 100644 +--- a/vhostmd.xml ++++ b/vhostmd.xml +@@ -98,13 +98,13 @@ the logical && operator must be replaced with "&&". + + PagedInMemory + +- vmstat -s | awk '/pages paged in/ {printf "%d\n", $1 / 1024 * $(getconf PAGESIZE) / 1024;}' ++ vmstat -s | awk '/K paged in/ {printf "%d\n", $1;}' + + + + PagedOutMemory + +- vmstat -s | awk '/pages paged out/ {printf "%d\n", $1 / 1024 * $(getconf PAGESIZE) / 1024;}' ++ vmstat -s | awk '/K paged out/ {printf "%d\n", $1;}' + + + diff --git a/SOURCES/0001-Relax-virtio-requirement-in-config-file.patch b/SOURCES/0001-Relax-virtio-requirement-in-config-file.patch deleted file mode 100644 index 5f49e4c..0000000 --- a/SOURCES/0001-Relax-virtio-requirement-in-config-file.patch +++ /dev/null @@ -1,42 +0,0 @@ -From 83cc269f6892852be94467cea771b3ad1da8a369 Mon Sep 17 00:00:00 2001 -From: Jim Fehlig -Date: Tue, 8 Oct 2019 20:56:18 -0600 -Subject: [PATCH] Relax virtio requirement in config file - -When the virtio transport was introduced the schema was changed to -require a transport in vhostmd.conf. When updating existing -deployments without a virtio transport specified in vhostmd.conf, -vhostmd fails to start - -/usr/sbin/vhostmd -d -/etc/vhostmd/vhostmd.conf:41: element globals: validity error : Element -globals content does not follow the DTD, expecting (disk , virtio , -update_period , path , transport+), got (disk update_period path transport ) -validate_config_file(): Failed to validate :/etc/vhostmd/vhostmd.conf -Config file: /etc/vhostmd/vhostmd.conf, fails DTD validation - -Relax the requirement for virtio transport in the schema. With the -introduction of multiple transports perhaps the others shoud be optional -as well, but requiring virtio is clearly a regression. - -Signed-off-by: Jim Fehlig ---- - vhostmd.dtd | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/vhostmd.dtd b/vhostmd.dtd -index db417fd..888270e 100644 ---- a/vhostmd.dtd -+++ b/vhostmd.dtd -@@ -9,7 +9,7 @@ Virtual Host Metrics Daemon (vhostmd). Configuration file DTD - --> - - -- -+ - - - --- -2.24.1 - diff --git a/sources b/sources new file mode 100644 index 0000000..306f9bc --- /dev/null +++ b/sources @@ -0,0 +1 @@ +SHA512 (vhostmd-1.2.tar.gz) = 13f797ca29ad9038bae966625d2dd764e030369b885ac520aa49d102d3bb9ea2356d0cf381ee3ce2ac3c1da0fc19ba2613241c736644c099bb3697180b852aed diff --git a/SOURCES/vhostmd.conf b/vhostmd.conf old mode 100644 new mode 100755 similarity index 96% rename from SOURCES/vhostmd.conf rename to vhostmd.conf index 955dd2f..4808a6a --- a/SOURCES/vhostmd.conf +++ b/vhostmd.conf @@ -5,6 +5,7 @@ Configuration file for virtual host metrics daemon (vhostmd). +A metrics disk between 1024 bytes and 256Mbytes is supported. A better, less noisy, more minimal configuration file which doesn't depend on Xen. @@ -17,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 element. +When chaining commands, '&', '<' and '>' are reserved characters, +therefore '&', '<' and '>' must be used instead. For example, +the logical && operator must be replaced with "&&". + --> @@ -81,6 +88,7 @@ way. 256 + /run/libvirt/qemu/channel 1024 15 diff --git a/SPECS/vhostmd.spec b/vhostmd.spec similarity index 75% rename from SPECS/vhostmd.spec rename to vhostmd.spec index 4436482..4562a49 100644 --- a/SPECS/vhostmd.spec +++ b/vhostmd.spec @@ -2,20 +2,20 @@ Summary: Virtualization host metrics daemon Name: vhostmd -Version: 1.1 -Release: 5%{?dist} -License: GPLv2+ +Version: 1.2 +Release: 1%{?dist} +License: LGPL-2.1-or-later URL: https://github.com/vhostmd/vhostmd Source0: https://github.com/vhostmd/vhostmd/archive/v%{version}/%{name}-%{version}.tar.gz Source1: vhostmd.conf -# Prevents updates from previous versions with the old config file -# from breaking (RHBZ#1782897). -# https://github.com/vhostmd/vhostmd/commit/83cc269f6892852be94467cea771b3ad1da8a369 -Patch1: 0001-Relax-virtio-requirement-in-config-file.patch +Patch0001: 0001-Add-channel_path-setting-to-daemon-config-file.patch +Patch0002: 0002-Support-libvirts-new-channel-path-naming-scheme.patch +Patch0003: 0003-Fix-parsing-of-vmstat-output.patch +BuildRequires: make BuildRequires: gcc BuildRequires: chrpath BuildRequires: perl-generators @@ -106,11 +106,7 @@ rm $RPM_BUILD_ROOT%{_datadir}/vhostmd/scripts/pagerate.pl %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 +%sysusers_create_inline u vhostmd 112 "Virtual Host Metrics Daemon" %{_datadir}/vhostmd /sbin/nologin %post @@ -162,29 +158,74 @@ exit 0 %changelog -* Tue Dec 01 2020 Richard W.M. Jones - 1.1-5.el8 -- Add Requires libvirt - resolves: rhbz#1897130 +* Tue Jan 22 2026 Nils Koenig - 1.2-1 +- Updated to upstream version 1.2 plus latest fixes + resolves: RHEL-143145 -* Fri Jan 31 2020 Richard W.M. Jones - 1.1-4.el8 -- Prevent updates from previous versions from breaking - resolves: rhbz#1782897 +* Tue Oct 29 2024 Troy Dawson - 1.1-17 +- Bump release for October 2024 mass rebuild: + Resolves: RHEL-64018 -* Mon Nov 25 2019 Richard W.M. Jones - 1.1-3.el8 -- Fix URL - resolves: rhbz#1775565 +* Mon Jun 24 2024 Troy Dawson - 1.1-16 +- Bump release for June 2024 mass rebuild -* Mon Nov 25 2019 Richard W.M. Jones - 1.1-2.el8 -- Fix vhostmd.conf - related: rhbz#1689213 +* Sat Jan 27 2024 Fedora Release Engineering - 1.1-15 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_40_Mass_Rebuild -* Thu Aug 29 2019 Richard W.M. Jones - 1.1-1.el8.1 +* Sat Jul 22 2023 Fedora Release Engineering - 1.1-14 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_39_Mass_Rebuild + +* Sat Jan 21 2023 Fedora Release Engineering - 1.1-13 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_38_Mass_Rebuild + +* Sat Jul 23 2022 Fedora Release Engineering - 1.1-12 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_37_Mass_Rebuild + +* Sat Jan 22 2022 Fedora Release Engineering - 1.1-11 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_36_Mass_Rebuild + +* Thu Jul 29 2021 Richard W.M. Jones - 1.1-10 +- Miscellaneous upstream fixes. + +* Fri Jul 23 2021 Fedora Release Engineering - 1.1-9 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_35_Mass_Rebuild + +* Tue Mar 02 2021 Zbigniew Jędrzejewski-Szmek - 1.1-8 +- Rebuilt for updated systemd-rpm-macros + See https://pagure.io/fesco/issue/2583. + +* Tue Feb 09 2021 Richard W.M. Jones - 1.1-7 +- Unify vhostmd.conf with RHEL 8.4 (RHBZ#1924966). + +* Thu Feb 04 2021 Richard W.M. Jones - 1.1-6 +- Increase release so > RHEL 8 (RHBZ#1924966). +- Unify spec files between RHEL and Fedora. + +* Wed Jan 27 2021 Fedora Release Engineering - 1.1-4 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_34_Mass_Rebuild + +* Wed Jul 29 2020 Fedora Release Engineering - 1.1-3 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_33_Mass_Rebuild + +* Fri Jan 31 2020 Fedora Release Engineering - 1.1-2 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_32_Mass_Rebuild + +* Thu Aug 29 2019 Richard W.M. Jones - 1.1-1 - Upstream version 1.1. - Remove patches, since all included 1.1. - resolves: 1689213 -* Thu Mar 21 2019 Richard W.M. Jones - 0.5-19 -- Add gating tests resolves: rhbz#1682784 +* Sat Jul 27 2019 Fedora Release Engineering - 1.0-4 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_31_Mass_Rebuild + +* Sun Feb 03 2019 Fedora Release Engineering - 1.0-3 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_30_Mass_Rebuild + +* Fri Jan 18 2019 Richard W.M. Jones - 1.0-2 +- Upstream version 1.0. +- Remove patches, since all included 1.0. +- Add patches since 1.0. +- Fix Source0 URL, hosted on github. +- Remove old Source1 and Source2, not used. * Tue Oct 16 2018 Richard W.M. Jones - 0.5-19 - Include all upstream patches since 0.5.