[PATCH v3] spec: don't touch existing nwfilters on update

Nikolay Shirokovskiy posted 1 patch 3 years, 4 months ago
Test syntax-check failed
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/libvirt tags/patchew/1607582371-960514-1-git-send-email-nshirokovskiy@virtuozzo.com
libvirt.spec.in | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
[PATCH v3] spec: don't touch existing nwfilters on update
Posted by Nikolay Shirokovskiy 3 years, 4 months ago
Nwfilter can be edited by the user and we don't want to overwrite the editings.
Also the filters in %{datadir} does not have UUIDs and these are generated on
libvirtd start. Thus this patch also fixes regeneration of UUIDs on libvirtd
update.

Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
---

It is a successor to PATCH v2[1].

Diff to v2:
- Misc changes according to Andrea's review

[1] PATCH v2
https://www.redhat.com/archives/libvir-list/2020-December/msg00399.html
 

 libvirt.spec.in | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/libvirt.spec.in b/libvirt.spec.in
index 880051b..f20a1c7 100644
--- a/libvirt.spec.in
+++ b/libvirt.spec.in
@@ -1439,9 +1439,13 @@ fi
 rm -rf %{_localstatedir}/lib/rpm-state/libvirt || :
 
 %post daemon-config-nwfilter
-cp %{_datadir}/libvirt/nwfilter/*.xml %{_sysconfdir}/libvirt/nwfilter/
-# libvirt saves these files with mode 600
-chmod 600 %{_sysconfdir}/libvirt/nwfilter/*.xml
+for datadir_file in %{_datadir}/libvirt/nwfilter/*.xml; do
+  sysconfdir_file=%{_sysconfdir}/libvirt/nwfilter/$(basename "$datadir_file")
+  if [ ! -f "$sysconfdir_file" ]; then
+    # libvirt saves these files with mode 600
+    install -m 0600 "$datadir_file" "$sysconfdir_file"
+  fi
+done
 # Make sure libvirt picks up the new nwfilter defininitons
 mkdir -p %{_localstatedir}/lib/rpm-state/libvirt || :
 touch %{_localstatedir}/lib/rpm-state/libvirt/restart || :
-- 
1.8.3.1

Re: [PATCH v3] spec: don't touch existing nwfilters on update
Posted by Andrea Bolognani 3 years, 4 months ago
On Thu, 2020-12-10 at 09:39 +0300, Nikolay Shirokovskiy wrote:
> Nwfilter can be edited by the user and we don't want to overwrite the editings.
> Also the filters in %{datadir} does not have UUIDs and these are generated on
> libvirtd start. Thus this patch also fixes regeneration of UUIDs on libvirtd
> update.
> 
> Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
> Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
> ---
> 
> It is a successor to PATCH v2[1].
> 
> Diff to v2:
> - Misc changes according to Andrea's review
> 
> [1] PATCH v2
> https://www.redhat.com/archives/libvir-list/2020-December/msg00399.html
>  
> 
>  libvirt.spec.in | 10 +++++++---
>  1 file changed, 7 insertions(+), 3 deletions(-)

Looks great now!

  Reviewed-by: Andrea Bolognani <abologna@redhat.com>

Thanks for your patience :)

-- 
Andrea Bolognani / Red Hat / Virtualization