From de8d2a9d0430317de9dd02d9e5d3efb41b092c8fbb6428e76a4aa631aa011793 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adrian=20Schr=C3=B6ter?= Date: Fri, 2 Aug 2024 14:10:03 +0200 Subject: [PATCH] Sync from SUSE:SLFO:Main vhostmd revision c49f09456a95088932ef01eafb67a97d --- .gitattributes | 23 +++ harden_vhostmd.service.patch | 22 +++ libmetrics-link.patch | 14 ++ manpage.patch | 19 +++ relax-virtio-config-requirement.patch | 37 ++++ value-newline.patch | 17 ++ vhostmd-1.1.tar.bz2 | 3 + vhostmd-conf.patch | 20 +++ vhostmd.changes | 234 ++++++++++++++++++++++++++ vhostmd.spec | 156 +++++++++++++++++ 10 files changed, 545 insertions(+) create mode 100644 .gitattributes create mode 100644 harden_vhostmd.service.patch create mode 100644 libmetrics-link.patch create mode 100644 manpage.patch create mode 100644 relax-virtio-config-requirement.patch create mode 100644 value-newline.patch create mode 100644 vhostmd-1.1.tar.bz2 create mode 100644 vhostmd-conf.patch create mode 100644 vhostmd.changes create mode 100644 vhostmd.spec diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..9b03811 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,23 @@ +## Default LFS +*.7z filter=lfs diff=lfs merge=lfs -text +*.bsp filter=lfs diff=lfs merge=lfs -text +*.bz2 filter=lfs diff=lfs merge=lfs -text +*.gem filter=lfs diff=lfs merge=lfs -text +*.gz filter=lfs diff=lfs merge=lfs -text +*.jar filter=lfs diff=lfs merge=lfs -text +*.lz filter=lfs diff=lfs merge=lfs -text +*.lzma filter=lfs diff=lfs merge=lfs -text +*.obscpio filter=lfs diff=lfs merge=lfs -text +*.oxt filter=lfs diff=lfs merge=lfs -text +*.pdf filter=lfs diff=lfs merge=lfs -text +*.png filter=lfs diff=lfs merge=lfs -text +*.rpm filter=lfs diff=lfs merge=lfs -text +*.tbz filter=lfs diff=lfs merge=lfs -text +*.tbz2 filter=lfs diff=lfs merge=lfs -text +*.tgz filter=lfs diff=lfs merge=lfs -text +*.ttf filter=lfs diff=lfs merge=lfs -text +*.txz filter=lfs diff=lfs merge=lfs -text +*.whl filter=lfs diff=lfs merge=lfs -text +*.xz filter=lfs diff=lfs merge=lfs -text +*.zip filter=lfs diff=lfs merge=lfs -text +*.zst filter=lfs diff=lfs merge=lfs -text diff --git a/harden_vhostmd.service.patch b/harden_vhostmd.service.patch new file mode 100644 index 0000000..ceaaa79 --- /dev/null +++ b/harden_vhostmd.service.patch @@ -0,0 +1,22 @@ +Index: vhostmd-1.1/vhostmd.service +=================================================================== +--- vhostmd-1.1.orig/vhostmd.service ++++ vhostmd-1.1/vhostmd.service +@@ -4,6 +4,17 @@ After=libvirtd.service + Documentation=man:vhostmd(8) + + [Service] ++# added automatically, for details please see ++# https://en.opensuse.org/openSUSE:Security_Features#Systemd_hardening_effort ++ProtectSystem=full ++ProtectHome=true ++ProtectHostname=true ++ProtectKernelTunables=true ++ProtectKernelModules=true ++ProtectKernelLogs=true ++ProtectControlGroups=true ++RestrictRealtime=true ++# end of automatic additions + Type=forking + ExecStart=/usr/sbin/vhostmd + ExecReload=/bin/kill -HUP $MAINPID diff --git a/libmetrics-link.patch b/libmetrics-link.patch new file mode 100644 index 0000000..ea5a172 --- /dev/null +++ b/libmetrics-link.patch @@ -0,0 +1,14 @@ +link libmetrics with libxml + +libmetrics uses libxml, so link with it. + +Index: vhostmd-1.1/libmetrics/Makefile.am +=================================================================== +--- vhostmd-1.1.orig/libmetrics/Makefile.am ++++ vhostmd-1.1/libmetrics/Makefile.am +@@ -19,3 +19,5 @@ libmetrics_la_SOURCES = \ + + libmetrics_la_DEPENDENCIES = \ + libmetrics.h ++ ++libmetrics_la_LIBADD = $(LIBXML_LIBS) diff --git a/manpage.patch b/manpage.patch new file mode 100644 index 0000000..aa7a8ba --- /dev/null +++ b/manpage.patch @@ -0,0 +1,19 @@ +Index: vhostmd-1.1/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 +@@ -10,8 +10,12 @@ vm-dump-metrics \- Dump VM metrics. + .BR vm-dump-metrics + reads virtualization hosts provided metrics decription and dumps output + .SH OPTIONS +-.B \-f, --dest +-Specify a dump file to be used instead of ++.TP 4 ++.B -v\fR, \fB--verbose\fR ++Verbose output ++.TP ++.B -d\fR, \fB--dest\fR ++Destination file for metrics, default stdout + + .SH XML Format of Content + diff --git a/relax-virtio-config-requirement.patch b/relax-virtio-config-requirement.patch new file mode 100644 index 0000000..f4f4044 --- /dev/null +++ b/relax-virtio-config-requirement.patch @@ -0,0 +1,37 @@ +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 new file mode 100644 index 0000000..560aca7 --- /dev/null +++ b/value-newline.patch @@ -0,0 +1,17 @@ +Index: vhostmd-1.1/vhostmd/metric.c +=================================================================== +--- vhostmd-1.1.orig/vhostmd/metric.c ++++ vhostmd-1.1/vhostmd/metric.c +@@ -280,6 +280,12 @@ int metric_value_get(metric *m) + goto out; + + fread(m->value, 1, len-1, fp); ++ ++ if (m->type != M_XML) { ++ size_t end = strlen(m->value) - 1; ++ if (m->value[end] == '\n') ++ m->value[end] = '\0'; ++ } + + out: + ret = pclose(fp); diff --git a/vhostmd-1.1.tar.bz2 b/vhostmd-1.1.tar.bz2 new file mode 100644 index 0000000..c825b25 --- /dev/null +++ b/vhostmd-1.1.tar.bz2 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:c55bf06e2d3362ac6b18625b3ab8bb22272e088997dedcd3e4ed3cca7549c5ec +size 49313 diff --git a/vhostmd-conf.patch b/vhostmd-conf.patch new file mode 100644 index 0000000..bc634c4 --- /dev/null +++ b/vhostmd-conf.patch @@ -0,0 +1,20 @@ +Disable virtio transport in SUSE-provided config file + +In SUSE distros, the default vhostmd config file has only enabled +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 +=================================================================== +--- vhostmd-1.1.orig/vhostmd.xml ++++ vhostmd-1.1/vhostmd.xml +@@ -40,7 +40,7 @@ the logical && operator must be replaced + 5 + /usr/sbin:/sbin:/usr/bin:/bin:/usr/share/vhostmd/scripts + vbd +- virtio ++ + + + diff --git a/vhostmd.changes b/vhostmd.changes new file mode 100644 index 0000000..0c6890d --- /dev/null +++ b/vhostmd.changes @@ -0,0 +1,234 @@ +------------------------------------------------------------------- +Tue Feb 20 13:25:13 UTC 2024 - Dominique Leuenberger + +- Use %autosetup macro. Allows to eliminate the usage of deprecated + %patchN + +------------------------------------------------------------------- +Wed Jan 5 08:45:27 UTC 2022 - Johannes Segitz + +- Added hardening to systemd service (bsc#1181400) + harden_vhostmd.service.patch + +------------------------------------------------------------------- +Mon Feb 3 16:54:14 UTC 2020 - Dominique Leuenberger + +- BuildRequire pkgconfig(systemd) instead of systemd: allow OBS to + shortcut through the -mini flavors. + +------------------------------------------------------------------- +Mon Oct 28 20:56:18 UTC 2019 - James Fehlig + +- spec: Don't replace user-modified dtd in /etc/vhostmd/ + bsc#1154838 + +------------------------------------------------------------------- +Wed Oct 9 17:04:14 UTC 2019 - James Fehlig + +- Relax virtio requirement in config file + relax-virtio-config-requirement.patch + bsc#1152803 + +------------------------------------------------------------------- +Fri Apr 12 19:27:24 UTC 2019 - James Fehlig + +- Update to vhostmd 1.1 + - Merge libserialclient with libmetrics + - Misc bug fixes and improvements + - bsc#1129772 + +------------------------------------------------------------------- +Mon Dec 3 22:53:13 UTC 2018 - James Fehlig + +- Update to vhostmd 1.0 + - Add virtio as transport mechanism + - Update to work with modern Xen + - Add SIGPIPE handler and reconnect + - Add systemd service file + - Modernize build files + - Misc bug fixes and improvements + - Dropped patches: + modernize-build-files.patch, + add-systemd-service.patch, + c7646e32-handle-sigpipe-reconnect.patch, + 03dc9982-fix-deallocation.patch + +------------------------------------------------------------------- +Mon Jun 25 15:05:23 UTC 2018 - jfehlig@suse.com + +- Handle SIGPIPE and reconnect to libvirtd + c7646e32-handle-sigpipe-reconnect.patch, + 03dc9982-fix-deallocation.patch + bsc#1098804 + +------------------------------------------------------------------- +Mon Apr 30 18:31:17 UTC 2018 - jfehlig@suse.com + +- vhostmd.service: fix typo and move Documentation from [Service] + to [Unit] section + bsc#1090769 + +------------------------------------------------------------------- +Sat Apr 29 15:58:03 UTC 2017 - jengelh@inai.de + +- Fix RPM group for libmetrics0 +- Replace old RPM shell vars in %install +- Author lists do not belong into the description +- Use macros in file list to compact paths + +------------------------------------------------------------------- +Thu Apr 27 16:34:53 UTC 2017 - jfehlig@suse.com + +- Add systemd service file + add-systemd-service.patch + bsc#1036427 +- Replace build-improvements.patch with + modernize-build-files.patch sent upstream + +------------------------------------------------------------------- +Wed Jan 14 09:21:43 MST 2015 - jfehlig@suse.com + +- Build vhostmd for all architectures + +------------------------------------------------------------------- +Mon Nov 10 20:19:34 MST 2014 - jfehlig@suse.com + +- Improve build scripts + Replace build-fix.patch with build-improvements.patch + +------------------------------------------------------------------- +Mon Nov 3 16:02:45 MST 2014 - jfehlig@suse.com + +- Fix Factory build + build-fix.patch + +------------------------------------------------------------------- +Fri Jun 13 19:34:33 UTC 2014 - mlatimer@suse.com + +- Further updates to vmhostd.xml + - Support both xen and non-xen hypervisors (kvm) + - Document reserved characters in 'action' field + - Revert xen_version back to major/minor/extra to maintain compatability + with xend + - Minor syntax and legibility cleanup + vhostmd-conf.patch + bnc#872736 + +------------------------------------------------------------------- +Wed Jun 11 23:02:06 UTC 2014 - mlatimer@suse.com + +- Various updates to vmhostd.xml + - Replace xm commands with xl commands + - Add /sbin and /bin to + - Use xen_version for VirtualizationProductInfo + vhostmd-conf.patch + +------------------------------------------------------------------- +Mon Dec 9 17:42:19 MST 2013 - jfehlig@suse.com + +- link libmetrics with libxml to fix Factory build + +------------------------------------------------------------------- +Sun Nov 20 06:29:32 UTC 2011 - coolo@suse.com + +- add libtool as buildrequire to avoid implicit dependency + +------------------------------------------------------------------- +Tue Mar 30 11:00:42 MDT 2010 - jfehlig@novell.com + +- Fixed vm-dump-metrics man page + bnc#592242 + manpage.patch +- Build vhostmd without xenstore support since it is not well + tested on SuSE distributions. Additionally, it can be confusing + when used in context of KVM where xenstore does not exist. +- Strip 's' (seconds) from metrics that contain a time value + vhostmd-conf.patch +- Remove stray newline from metric values to improve XML readability + value-newline.patch + +------------------------------------------------------------------- +Wed Dec 9 09:17:48 MST 2009 - jfehlig@novell.com + +- Release of version 0.4 + - configure.ac: Fix C compiler detection to be compatible with + automake + - chdir ("/") when daemonizing self + +------------------------------------------------------------------- +Fri Oct 30 15:04:32 MDT 2009 - jfehlig@novell.com + +- Release of version 0.3 + - change default disk location to /dev/shm/vhostmd0 + - open metrics disk with O_DIRECT + - Fixes for '--with{,out}-xenstore' option + - Allow gcc to check calls to vu_log* printf-like functions + - Always connect to libvirt read-only + - Add '-u user' command line option to drop root privs + - Add '-c uri' command line option to specify libvirt connection + URI + - Add CONNECT substitution s + - vm-dump-metrics: On error, exit with status code 1 + +------------------------------------------------------------------- +Tue Sep 29 13:00:27 UTC 2009 - aj@suse.de + +- Fix devel package requires. + +------------------------------------------------------------------- +Wed Sep 16 22:11:57 CEST 2009 - dmueller@suse.de + +- fix devel package requires + +------------------------------------------------------------------- +Mon Jun 29 16:42:39 MDT 2009 - jfehlig@novell.com + +- Validate XML returned by 'action' for metric type 'xml' +- Do not convert metrics values internally in vhostmd. Treat + all metric values as strings and leave it to consumers to do + any conversion. + +------------------------------------------------------------------- +Fri Jun 26 17:24:38 MDT 2009 - jfehlig@novell.com + +- Allow larger buffer for 'xml' type + +------------------------------------------------------------------- +Thu Jun 25 22:24:27 MDT 2009 - jfehlig@novell.com + +- Add metric type 'XML' + +------------------------------------------------------------------- +Fri Jun 19 14:19:19 MDT 2009 - jfehlig@novell.com + +- vhostmd is currently only used with Xen so make it + ExclusiveArch x86 and x86_64 + +------------------------------------------------------------------- +Mon Jun 15 14:47:42 MDT 2009 - jfehlig@novell.com + +- Truncate metrics disk on open + +------------------------------------------------------------------- +Tue Jun 9 09:30:06 MDT 2009 - jfehlig@novell.com + +- Change COPYING from GPL3 to LGPL2.1 + +------------------------------------------------------------------- +Fri Jun 5 11:16:36 MDT 2009 - jfehlig@novell.com + +- Explicitly name subpackages with -n + +------------------------------------------------------------------- +Thu Jun 4 18:29:39 MDT 2009 - jfehlig@novell.com + +- Version 0.2 + - Updated documentation + - Added group metric type + - Added perl script for generating {PageIn,PageFault}Rate + +------------------------------------------------------------ +Wed Jan 7 12:39:17 MST 2009 - plc@novell.com + +- Initial creation + diff --git a/vhostmd.spec b/vhostmd.spec new file mode 100644 index 0000000..7fc81cc --- /dev/null +++ b/vhostmd.spec @@ -0,0 +1,156 @@ +# +# spec file for package vhostmd +# +# Copyright (c) 2022 SUSE LLC +# +# All modifications and additions to the file contributed by third parties +# remain the property of their copyright owners, unless otherwise agreed +# upon. The license for this file, and modifications and additions to the +# file, is the same license as for the pristine package itself (unless the +# license for the pristine package is not an Open Source License, in which +# case the license is the MIT License). An "Open Source License" is a +# license that conforms to the Open Source Definition (Version 1.9) +# published by the Open Source Initiative. + +# Please submit bugfixes or comments via https://bugs.opensuse.org/ +# + + +%define with_xen 0%{!?_without_xen:1} + +# Xen is available only on x86_64 +%ifnarch x86_64 +%define with_xen 0 +%endif + +Name: vhostmd +Version: 1.1 +Release: 0 +Summary: Virtual Host Metrics Daemon (vhostmd) +License: LGPL-2.1-or-later +Group: System/Daemons +URL: https://github.com/vhostmd/vhostmd +BuildRoot: %{_tmppath}/%{name}-%{version}-build +Source0: vhostmd-%{version}.tar.bz2 +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 +BuildRequires: libtool +BuildRequires: libvirt-devel +BuildRequires: libxml2 +BuildRequires: libxml2-devel +BuildRequires: pkg-config +BuildRequires: pkgconfig(systemd) +%{?systemd_ordering} +%if %{with_xen} +BuildRequires: xen-devel +%endif +PreReq: coreutils + +%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: Virtual Host Metrics Daemon (vhostmd) +Group: System/Monitoring + +%description -n vm-dump-metrics +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 libmetrics0 +Summary: Virtual Host Metrics Daemon (vhostmd) +Group: System/Libraries + +%description -n libmetrics0 +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 libmetrics-devel +Summary: Virtual Host Metrics Daemon (vhostmd) +Group: Development/Libraries/C and C++ +Requires: libmetrics0 = %{version} + +%description -n libmetrics-devel +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. + +%prep +%autosetup -p1 + +%build +%if ! %{with_xen} +%define _disable_libxenstat --disable-libxenstat +%define _disable_xenctrl --disable-xenctrl +%endif + +autoreconf -fi +%configure --without-xenstore \ + %{?_disable_libxenstat} \ + %{?_disable_xenctrl} +make + +%install +%make_install +rm -f %{buildroot}/%{_libdir}/*.la %{buildroot}/%{_libdir}/*.a +ln -s %{_sbindir}/service %{buildroot}/%{_sbindir}/rcvhostmd + +%pre +%service_add_pre vhostmd.service + +%post +%service_add_post vhostmd.service + +%preun +%service_del_preun vhostmd.service + +%postun +%service_del_postun vhostmd.service + +%post -n libmetrics0 -p /sbin/ldconfig +%postun -n libmetrics0 -p /sbin/ldconfig + +%files +%defattr(-,root,root) +%dir /etc/vhostmd +%dir %{_datadir}/vhostmd +%dir %{_datadir}/vhostmd/scripts +%dir %{_datadir}/doc/vhostmd +%{_sbindir}/vhostmd +%{_sbindir}/rcvhostmd +%{_datadir}/vhostmd/scripts/pagerate.pl +%config(noreplace) /etc/vhostmd/vhostmd.conf +%config(noreplace) /etc/vhostmd/vhostmd.dtd +%config(noreplace) /etc/vhostmd/metric.dtd +%{_unitdir}/vhostmd.service +%{_datadir}/doc/vhostmd/vhostmd.dtd +%{_datadir}/doc/vhostmd/metric.dtd +%{_datadir}/doc/vhostmd/vhostmd.xml +%{_datadir}/doc/vhostmd/mdisk.xml +%{_datadir}/doc/vhostmd/README +%{_datadir}/man/man8/vhostmd.8.gz + +%files -n vm-dump-metrics +%defattr(-,root,root) +%{_sbindir}/vm-dump-metrics +%{_datadir}/man/man1/vm-dump-metrics.1.gz + +%files -n libmetrics0 +%defattr(-,root,root) +%{_libdir}/libmetrics.so.* + +%files -n libmetrics-devel +%defattr(-,root,root) +%{_libdir}/libmetrics.so +%dir %{_includedir}/vhostmd +%{_includedir}/vhostmd/libmetrics.h + +%changelog