[Pkg-libvirt-maintainers] Bug#507553: libvirt: simple logrotate

Harald Staub harald.staub at switch.ch
Tue Dec 2 12:14:33 UTC 2008


Package: libvirt
Version: 0.4.4-3
Severity: normal

The log files in /var/log/libvirt/qemu/ may become quite large, especially
with collectd's libvirt plugin (collects and logs drive statistics every 10
seconds). munin-libvirt-plugins has a similar effect, only that the volume
is smaller (every 5 minutes).

I use the following quick hack to make the logs rotateable (with logrotate's
copytruncate option):

diff -ur libvirt-0.4.4.orig/src/qemu_driver.c libvirt-0.4.4/src/qemu_driver.c
--- libvirt-0.4.4.orig/src/qemu_driver.c        2008-06-12
16:52:53.000000000 +0200
+++ libvirt-0.4.4/src/qemu_driver.c     2008-12-02 12:48:32.271881000 +0100
@@ -844,7 +844,7 @@
         return -1;
     }

-    if ((vm->logfile = open(logfile, O_CREAT | O_TRUNC | O_WRONLY,
+    if ((vm->logfile = open(logfile, O_CREAT | O_APPEND | O_WRONLY,
                             S_IRUSR | S_IWUSR)) < 0) {
         qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
                          _("failed to create logfile %s: %s"),

So the log file is opened with O_APPEND (to make logrotate work with
copytruncate) and without O_TRUNC (to not lose log information e.g. with
stop and start of a VM).






More information about the Pkg-libvirt-maintainers mailing list