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(a)virtuozzo.com>
---
It is a successor to original version of the patch [1]. The discussion can
be found in [2].
Diff to v1:
- just keep existing nwfilters untouched instead of bringing new
version of nwfilter while keeping UUID
[1]
https://www.redhat.com/archives/libvir-list/2020-October/msg01357.html
[2]
https://www.redhat.com/archives/libvir-list/2020-December/msg00260.html
libvirt.spec.in | 19 ++++++++++++++-----
1 file changed, 14 insertions(+), 5 deletions(-)
diff --git a/libvirt.spec.in b/libvirt.spec.in
index 880051b..98914ce 100644
--- a/libvirt.spec.in
+++ b/libvirt.spec.in
@@ -1439,12 +1439,21 @@ 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
+restart_daemon=0
+for dfile in %{_datadir}/libvirt/nwfilter/*.xml; do
+ sfile=%{_sysconfdir}/libvirt/nwfilter/`basename $dfile`
+ if [ ! -f "$sfile" ]; then
+ cp "$dfile" "$sfile"
+ # libvirt saves these files with mode 600
+ chmod 600 "$sfile"
+ restart_daemon=1
+ 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 || :
+if [ $restart_daemon -eq 1 ]; then
+ mkdir -p %{_localstatedir}/lib/rpm-state/libvirt || :
+ touch %{_localstatedir}/lib/rpm-state/libvirt/restart || :
+fi
%posttrans daemon-config-nwfilter
if [ -f %{_localstatedir}/lib/rpm-state/libvirt/restart ]; then
--
1.8.3.1