From 0eca4e900d5cd2e05464c556346ae927da1b3faa1d6567b5e07ea16af210571d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adrian=20Schr=C3=B6ter?= Date: Fri, 11 Oct 2024 10:10:45 +0200 Subject: [PATCH] Sync from SUSE:SLFO:Main vhostmd revision 8f6ad46e635f9addc71cd1964c71f605 --- ...cda4-Support-new-channel-path-naming.patch | 82 ++++++++++ 5a04b594-Add-channel_path-setting.patch | 148 ++++++++++++++++++ 9d282891-Fix-parsing-of-vmstat-output.patch | 37 +++++ _service | 17 ++ harden_vhostmd.service.patch | 6 +- libmetrics-link.patch | 6 +- manpage.patch | 6 +- relax-virtio-config-requirement.patch | 37 ----- value-newline.patch | 6 +- vhostmd-1.1.tar.bz2 | 3 - vhostmd-1.2.tar.bz2 | 3 + vhostmd-conf.patch | 6 +- vhostmd.changes | 26 +++ vhostmd.spec | 10 +- 14 files changed, 334 insertions(+), 59 deletions(-) create mode 100644 176fcda4-Support-new-channel-path-naming.patch create mode 100644 5a04b594-Add-channel_path-setting.patch create mode 100644 9d282891-Fix-parsing-of-vmstat-output.patch create mode 100644 _service delete mode 100644 relax-virtio-config-requirement.patch delete mode 100644 vhostmd-1.1.tar.bz2 create mode 100644 vhostmd-1.2.tar.bz2 diff --git a/176fcda4-Support-new-channel-path-naming.patch b/176fcda4-Support-new-channel-path-naming.patch new file mode 100644 index 0000000..e748878 --- /dev/null +++ b/176fcda4-Support-new-channel-path-naming.patch @@ -0,0 +1,82 @@ +From 176fcda44caca807b4bec9fd613991afd9d5a70b Mon Sep 17 00:00:00 2001 +From: Jim Fehlig +Date: Fri, 27 Sep 2024 10:48:41 -0600 +Subject: [PATCH 2/3] 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 +--- + vhostmd/virtio.c | 49 +++++++++++++++++++++++++----------------------- + 1 file changed, 26 insertions(+), 23 deletions(-) + +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; ++ 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) { ++ 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; + +- char tmp[SUN_PATH_LEN + 8]; +- struct stat st; ++ rc = snprintf(tmp, sizeof(tmp), "%s/%s/%s", path, ent->d_name, channel_name); + +- rc = snprintf(tmp, sizeof(tmp), "%s/%s/%s", path, ent->d_name, channel_name); ++ if (rc > 0 && rc < (int) sizeof(tmp) && ++ strlen(tmp) < SUN_PATH_LEN && ++ stat(tmp, &st) == 0 && ++ S_ISSOCK(st.st_mode)) { + +- 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); + +- channel_t *c = NULL; +- const char *name = strchr(&(ent->d_name[strlen("domain-")]), '-'); +- +- 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; + } + } + } +-- +2.35.3 + diff --git a/5a04b594-Add-channel_path-setting.patch b/5a04b594-Add-channel_path-setting.patch new file mode 100644 index 0000000..10efb1e --- /dev/null +++ b/5a04b594-Add-channel_path-setting.patch @@ -0,0 +1,148 @@ +From 5a04b59495490bf921c661ff95754ea9955e7cd4 Mon Sep 17 00:00:00 2001 +From: Jim Fehlig +Date: Fri, 27 Sep 2024 09:20:52 -0600 +Subject: [PATCH 1/3] 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 +--- + README | 3 +++ + include/virtio.h | 2 +- + vhostmd.dtd | 3 ++- + vhostmd.xml | 1 + + vhostmd/vhostmd.c | 12 ++++++++++-- + vhostmd/virtio.c | 5 +++-- + 6 files changed, 20 insertions(+), 6 deletions(-) + +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; +-- +2.35.3 + diff --git a/9d282891-Fix-parsing-of-vmstat-output.patch b/9d282891-Fix-parsing-of-vmstat-output.patch new file mode 100644 index 0000000..3cb1120 --- /dev/null +++ b/9d282891-Fix-parsing-of-vmstat-output.patch @@ -0,0 +1,37 @@ +From 9d282891eaaeebf1b94c67314d97e55a0b58d9c2 Mon Sep 17 00:00:00 2001 +From: Jim Fehlig +Date: Fri, 27 Sep 2024 13:25:58 -0600 +Subject: [PATCH 3/3] 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 +--- + vhostmd.xml | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +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;}' + + + +-- +2.35.3 + diff --git a/_service b/_service new file mode 100644 index 0000000..919c6d7 --- /dev/null +++ b/_service @@ -0,0 +1,17 @@ + + + vhostmd + v1.2 + git + disable + https://github.com/vhostmd/vhostmd.git + @PARENT_TAG@ + [v]?([^\+]+)(.*) + \1 + + + *.tar + bz2 + + + diff --git a/harden_vhostmd.service.patch b/harden_vhostmd.service.patch index ceaaa79..7cda626 100644 --- a/harden_vhostmd.service.patch +++ b/harden_vhostmd.service.patch @@ -1,7 +1,7 @@ -Index: vhostmd-1.1/vhostmd.service +Index: vhostmd-1.2/vhostmd.service =================================================================== ---- vhostmd-1.1.orig/vhostmd.service -+++ vhostmd-1.1/vhostmd.service +--- vhostmd-1.2.orig/vhostmd.service ++++ vhostmd-1.2/vhostmd.service @@ -4,6 +4,17 @@ After=libvirtd.service Documentation=man:vhostmd(8) diff --git a/libmetrics-link.patch b/libmetrics-link.patch index ea5a172..c3ca2bf 100644 --- a/libmetrics-link.patch +++ b/libmetrics-link.patch @@ -2,10 +2,10 @@ link libmetrics with libxml libmetrics uses libxml, so link with it. -Index: vhostmd-1.1/libmetrics/Makefile.am +Index: vhostmd-1.2/libmetrics/Makefile.am =================================================================== ---- vhostmd-1.1.orig/libmetrics/Makefile.am -+++ vhostmd-1.1/libmetrics/Makefile.am +--- vhostmd-1.2.orig/libmetrics/Makefile.am ++++ vhostmd-1.2/libmetrics/Makefile.am @@ -19,3 +19,5 @@ libmetrics_la_SOURCES = \ libmetrics_la_DEPENDENCIES = \ diff --git a/manpage.patch b/manpage.patch index aa7a8ba..87bb19b 100644 --- a/manpage.patch +++ b/manpage.patch @@ -1,7 +1,7 @@ -Index: vhostmd-1.1/docs/man/vm-dump-metrics.1 +Index: vhostmd-1.2/docs/man/vm-dump-metrics.1 =================================================================== ---- vhostmd-1.1.orig/docs/man/vm-dump-metrics.1 -+++ vhostmd-1.1/docs/man/vm-dump-metrics.1 +--- vhostmd-1.2.orig/docs/man/vm-dump-metrics.1 ++++ vhostmd-1.2/docs/man/vm-dump-metrics.1 @@ -10,8 +10,12 @@ vm-dump-metrics \- Dump VM metrics. .BR vm-dump-metrics reads virtualization hosts provided metrics decription and dumps output diff --git a/relax-virtio-config-requirement.patch b/relax-virtio-config-requirement.patch deleted file mode 100644 index f4f4044..0000000 --- a/relax-virtio-config-requirement.patch +++ /dev/null @@ -1,37 +0,0 @@ -commit 83cc269f6892852be94467cea771b3ad1da8a369 -Author: Jim Fehlig -Date: Tue Oct 8 20:56:18 2019 -0600 - - 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 - -Index: vhostmd-1.1/vhostmd.dtd -=================================================================== ---- vhostmd-1.1.orig/vhostmd.dtd -+++ vhostmd-1.1/vhostmd.dtd -@@ -9,7 +9,7 @@ Virtual Host Metrics Daemon (vhostmd). C - --> - - -- -+ - - - diff --git a/value-newline.patch b/value-newline.patch index 560aca7..4342d7a 100644 --- a/value-newline.patch +++ b/value-newline.patch @@ -1,7 +1,7 @@ -Index: vhostmd-1.1/vhostmd/metric.c +Index: vhostmd-1.2/vhostmd/metric.c =================================================================== ---- vhostmd-1.1.orig/vhostmd/metric.c -+++ vhostmd-1.1/vhostmd/metric.c +--- vhostmd-1.2.orig/vhostmd/metric.c ++++ vhostmd-1.2/vhostmd/metric.c @@ -280,6 +280,12 @@ int metric_value_get(metric *m) goto out; diff --git a/vhostmd-1.1.tar.bz2 b/vhostmd-1.1.tar.bz2 deleted file mode 100644 index c825b25..0000000 --- a/vhostmd-1.1.tar.bz2 +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:c55bf06e2d3362ac6b18625b3ab8bb22272e088997dedcd3e4ed3cca7549c5ec -size 49313 diff --git a/vhostmd-1.2.tar.bz2 b/vhostmd-1.2.tar.bz2 new file mode 100644 index 0000000..c729904 --- /dev/null +++ b/vhostmd-1.2.tar.bz2 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:22973590bc9c23bc5058fa93260750e1b3d4586c6b8008bdb9b1a6fff21e273b +size 48781 diff --git a/vhostmd-conf.patch b/vhostmd-conf.patch index bc634c4..0246b3f 100644 --- a/vhostmd-conf.patch +++ b/vhostmd-conf.patch @@ -5,10 +5,10 @@ one transport - vbd. Comment the recently added virtio transport. Users can uncomment it and restart vhostmd if virtio transport is desired, similar to the xenstore transport. -Index: vhostmd-1.1/vhostmd.xml +Index: vhostmd-1.2/vhostmd.xml =================================================================== ---- vhostmd-1.1.orig/vhostmd.xml -+++ vhostmd-1.1/vhostmd.xml +--- vhostmd-1.2.orig/vhostmd.xml ++++ vhostmd-1.2/vhostmd.xml @@ -40,7 +40,7 @@ the logical && operator must be replaced 5 /usr/sbin:/sbin:/usr/bin:/bin:/usr/share/vhostmd/scripts diff --git a/vhostmd.changes b/vhostmd.changes index 0c6890d..78fe501 100644 --- a/vhostmd.changes +++ b/vhostmd.changes @@ -1,3 +1,29 @@ +------------------------------------------------------------------- +Tue Oct 1 17:55:04 UTC 2024 - James Fehlig + +- Fix virtio transport to work with libvirt >= 9.7.0 + Added patches: + 5a04b594-Add-channel_path-setting.patch, + 176fcda4-Support-new-channel-path-naming.patch, + 9d282891-Fix-parsing-of-vmstat-output.patch + bsc#1230961 + +------------------------------------------------------------------- +Fri Sep 20 18:10:53 UTC 2024 - James Fehlig + +- Update to version 1.2 + - Fix actions using the 'free' command + - Fix buffer accounting when generating metric XML + - Fix warning with gcc >= 13 + - Fix implicit declarations + - Change actions to retrieve vendor and product info + - Add a 'unit' attribute to the metrics element + - vif-stats.py: convert to Python3 + - Misc coverity fixes + - Relax virtio requirement in config file +- Drop relax-virtio-config-requirement.patch +- Add service file + ------------------------------------------------------------------- Tue Feb 20 13:25:13 UTC 2024 - Dominique Leuenberger diff --git a/vhostmd.spec b/vhostmd.spec index 7fc81cc..3c774c3 100644 --- a/vhostmd.spec +++ b/vhostmd.spec @@ -1,7 +1,7 @@ # # spec file for package vhostmd # -# Copyright (c) 2022 SUSE LLC +# Copyright (c) 2024 SUSE LLC # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -24,7 +24,7 @@ %endif Name: vhostmd -Version: 1.1 +Version: 1.2 Release: 0 Summary: Virtual Host Metrics Daemon (vhostmd) License: LGPL-2.1-or-later @@ -36,8 +36,10 @@ Patch0: vhostmd-conf.patch Patch1: manpage.patch Patch2: value-newline.patch Patch3: libmetrics-link.patch -Patch4: relax-virtio-config-requirement.patch -Patch5: harden_vhostmd.service.patch +Patch4: harden_vhostmd.service.patch +Patch5: 5a04b594-Add-channel_path-setting.patch +Patch6: 176fcda4-Support-new-channel-path-naming.patch +Patch7: 9d282891-Fix-parsing-of-vmstat-output.patch BuildRequires: libtool BuildRequires: libvirt-devel BuildRequires: libxml2