Change logrotate to be per-hypervisor logs

Having a single logrotate configuration file for all hypervisors
did not work as logrotate would get confused if an hypervisor not
supported on that platform was still listed. Simplest is to split
the logrotate as separate per hypervisor files and change the
spec file to only install the ones compiled in.
* daemon/libvirtd.lxc.logrotate.in daemon/libvirtd.qemu.logrotate.in
  daemon/libvirtd.uml.logrotate.in: copy and split the original
  daemon/libvirtd.logrotate.in file
* daemon/Makefile.am: update to support the different files and
  cleanup in sed suggested by Eric Blake
* libvirt.spec.in: only install the relevant logrotate configs
* daemon/.gitignore: update logrotate generated list
This commit is contained in:
Daniel Veillard 2010-03-04 15:17:08 +01:00
parent 36d8e7d8d7
commit 89bf843a6d
6 changed files with 51 additions and 10 deletions

2
daemon/.gitignore vendored
View File

@ -9,4 +9,4 @@ Makefile.in
libvirt_qemud
libvirtd
libvirtd.init
libvirtd.logrotate
libvirtd.*.logrotate

View File

@ -25,7 +25,9 @@ EXTRA_DIST = \
libvirtd.sasl \
libvirtd.sysconf \
libvirtd.aug \
libvirtd.logrotate.in \
libvirtd.qemu.logrotate.in \
libvirtd.lxc.logrotate.in \
libvirtd.uml.logrotate.in \
test_libvirtd.aug \
$(AVAHI_SOURCES) \
$(DAEMON_SOURCES)
@ -177,20 +179,37 @@ remote_dispatch_args.h: $(srcdir)/remote_generate_stubs.pl $(REMOTE_PROTOCOL)
remote_dispatch_ret.h: $(srcdir)/remote_generate_stubs.pl $(REMOTE_PROTOCOL)
perl -w $(srcdir)/remote_generate_stubs.pl -r $(REMOTE_PROTOCOL) > $@
BUILT_SOURCES += libvirtd.logrotate
LOGROTATE_CONFS = libvirtd.qemu.logrotate libvirtd.lxc.logrotate \
libvirtd.uml.logrotate
libvirtd.logrotate: libvirtd.logrotate.in
sed \
-e s!\@localstatedir\@!@localstatedir@!g \
BUILT_SOURCES += $(LOGROTATE_CONFS)
libvirtd.qemu.logrotate: libvirtd.qemu.logrotate.in
sed \
-e 's![@]localstatedir[@]!$(localstatedir)!g' \
< $< > $@-t
mv $@-t $@
install-logrotate: libvirtd.logrotate
libvirtd.lxc.logrotate: libvirtd.lxc.logrotate.in
sed \
-e 's![@]localstatedir[@]!$(localstatedir)!g' \
< $< > $@-t
mv $@-t $@
libvirtd.uml.logrotate: libvirtd.uml.logrotate.in
sed \
-e 's![@]localstatedir[@]!$(localstatedir)!g' \
< $< > $@-t
mv $@-t $@
install-logrotate: $(LOGROTATE_CONFS)
mkdir -p $(DESTDIR)$(localstatedir)/log/libvirt/qemu/
mkdir -p $(DESTDIR)$(localstatedir)/log/libvirt/lxc/
mkdir -p $(DESTDIR)$(localstatedir)/log/libvirt/uml/
mkdir -p $(DESTDIR)$(sysconfdir)/logrotate.d/
$(INSTALL_DATA) $< $(DESTDIR)$(sysconfdir)/logrotate.d/libvirtd
$(INSTALL_DATA) libvirtd.qemu.logrotate $(DESTDIR)$(sysconfdir)/logrotate.d/libvirtd.qemu
$(INSTALL_DATA) libvirtd.lxc.logrotate $(DESTDIR)$(sysconfdir)/logrotate.d/libvirtd.lxc
$(INSTALL_DATA) libvirtd.uml.logrotate $(DESTDIR)$(sysconfdir)/logrotate.d/libvirtd.uml
if LIBVIRT_INIT_SCRIPT_RED_HAT
install-init: libvirtd.init

View File

@ -1,4 +1,4 @@
@localstatedir@/log/libvirt/qemu/*.log @localstatedir@/log/libvirt/uml/*.log @localstatedir@/log/libvirt/lxc/*.log {
@localstatedir@/log/libvirt/lxc/*.log {
weekly
missingok
rotate 4

View File

@ -0,0 +1,9 @@
@localstatedir@/log/libvirt/qemu/*.log {
weekly
missingok
rotate 4
compress
delaycompress
copytruncate
minsize 100k
}

View File

@ -0,0 +1,9 @@
@localstatedir@/log/libvirt/uml/*.log {
weekly
missingok
rotate 4
compress
delaycompress
copytruncate
minsize 100k
}

View File

@ -668,16 +668,20 @@ fi
%{_sysconfdir}/rc.d/init.d/libvirtd
%config(noreplace) %{_sysconfdir}/sysconfig/libvirtd
%config(noreplace) %{_sysconfdir}/libvirt/libvirtd.conf
%config(noreplace) %{_sysconfdir}/logrotate.d/libvirtd
%dir %attr(0700, root, root) %{_localstatedir}/log/libvirt/qemu/
%dir %attr(0700, root, root) %{_localstatedir}/log/libvirt/lxc/
%dir %attr(0700, root, root) %{_localstatedir}/log/libvirt/uml/
%if %{with_qemu}
%config(noreplace) %{_sysconfdir}/libvirt/qemu.conf
%config(noreplace) %{_sysconfdir}/logrotate.d/libvirtd.qemu
%endif
%if %{with_lxc}
%config(noreplace) %{_sysconfdir}/libvirt/lxc.conf
%config(noreplace) %{_sysconfdir}/logrotate.d/libvirtd.lxc
%endif
%if %{with_uml}
%config(noreplace) %{_sysconfdir}/logrotate.d/libvirtd.uml
%endif
%dir %{_datadir}/libvirt/