From 3e81399d5399d37ec3517a4e7ada2c57e1a2f9bb Mon Sep 17 00:00:00 2001 From: Tomas Bzatek Date: Fri, 3 May 2024 18:28:24 +0200 Subject: [PATCH] Sync with RHEL 9: - generate hostnqn and hostid in %post - silence hostnqn-hostid consistency checks --- ...se-corresponding-hostid-when-hostnqn.patch | 19 ++++++++++++++ nvme-cli.spec | 26 ++++++++++++++----- 2 files changed, 38 insertions(+), 7 deletions(-) create mode 100644 0001-Revert-fabrics-Use-corresponding-hostid-when-hostnqn.patch diff --git a/0001-Revert-fabrics-Use-corresponding-hostid-when-hostnqn.patch b/0001-Revert-fabrics-Use-corresponding-hostid-when-hostnqn.patch new file mode 100644 index 0000000..4103f29 --- /dev/null +++ b/0001-Revert-fabrics-Use-corresponding-hostid-when-hostnqn.patch @@ -0,0 +1,19 @@ +diff -up nvme-cli-2.9.1/fabrics.c.bak nvme-cli-2.9.1/fabrics.c +--- nvme-cli-2.9.1/fabrics.c.bak 2024-05-03 16:03:42.000000000 +0200 ++++ nvme-cli-2.9.1/fabrics.c 2024-05-03 18:26:34.915157152 +0200 +@@ -643,6 +643,7 @@ char *nvmf_hostid_from_hostnqn(const cha + + void nvmf_check_hostid_and_hostnqn(const char *hostid, const char *hostnqn, unsigned int verbose) + { ++#if 0 + _cleanup_free_ char *hostid_from_file = NULL; + _cleanup_free_ char *hostid_from_hostnqn = NULL; + +@@ -665,6 +666,7 @@ void nvmf_check_hostid_and_hostnqn(const + fprintf(stderr, + "warning: use hostid which does not match uuid in hostnqn\n"); + } ++#endif + } + + int nvmf_discover(const char *desc, int argc, char **argv, bool connect) diff --git a/nvme-cli.spec b/nvme-cli.spec index e60ea89..5def2e1 100644 --- a/nvme-cli.spec +++ b/nvme-cli.spec @@ -10,6 +10,8 @@ License: GPL-2.0-only URL: https://github.com/linux-nvme/nvme-cli Source0: %{url}/archive/v%{version_no_tilde}/%{name}-%{version_no_tilde}.tar.gz +Patch0: 0001-Revert-fabrics-Use-corresponding-hostid-when-hostnqn.patch + BuildRequires: meson >= 0.50.0 BuildRequires: gcc gcc-c++ BuildRequires: systemd-devel @@ -45,13 +47,6 @@ nvme-cli provides NVM-Express user space tooling for Linux. %meson_install %{__install} -pm 644 README.md %{buildroot}%{_pkgdocdir} -# hostid and hostnqn are supposed to be unique per machine. We obviously -# can't package them. -# nvme-stas ships the stas-config@.service that will take care -# of generating these files if missing. See rhbz 2065886#c19 -rm -f %{buildroot}%{_sysconfdir}/nvme/hostid -rm -f %{buildroot}%{_sysconfdir}/nvme/hostnqn - # Do not install the dracut rule yet. See rhbz 1742764 rm -f %{buildroot}/usr/lib/dracut/dracut.conf.d/70-nvmf-autoconnect.conf @@ -80,6 +75,23 @@ rm -rf %{buildroot}%{_pkgdocdir}/nvme # Do not install the dracut rule yet. See rhbz 1742764 # /usr/lib/dracut/dracut.conf.d/70-nvmf-autoconnect.conf +%post +if [ $1 -eq 1 ] || [ $1 -eq 2 ]; then + if [ ! -s %{_sysconfdir}/nvme/hostnqn ]; then + echo $(nvme gen-hostnqn) > %{_sysconfdir}/nvme/hostnqn + fi + if [ ! -s %{_sysconfdir}/nvme/hostid ]; then + echo $(nvme show-hostnqn | sed 's/^.*uuid://') > %{_sysconfdir}/nvme/hostid + fi + + # apply udev and systemd changes that we did + if [ $1 -eq 1 ]; then + systemctl enable nvmefc-boot-connections + fi + systemctl daemon-reload + udevadm control --reload-rules && udevadm trigger + exit 0 +fi %changelog * Fri May 03 2024 Tomas Bzatek - 2.9.1-1