logrotate qemu monitor logs

This commit is contained in:
Guido Günther 2008-12-09 20:22:39 +00:00
parent 1c9968a2b1
commit 54f4ed6ba1
4 changed files with 37 additions and 3 deletions

View File

@ -1,3 +1,11 @@
Tue 9 Dez 2008 21:08:43 CET Guido Günther <agx@sigxcpu.org>
logrotate qemu monitor logs
* src/qemu_driver.c: open logfile O_APPEND instead of O_TRUNC when
running as root
* qemud/Makefile.am: install logrotate configuration (by Harald Sraub)
and create logdir
Mon Dec 8 13:22:06 +0100 2008 Jim Meyering <meyering@redhat.com>
virsh.c: tweak options to produce more accurate help

View File

@ -134,7 +134,8 @@ endif
default_xml_dest = libvirt/qemu/networks/default.xml
install-data-local: install-init install-data-sasl install-data-polkit
install-data-local: install-init install-data-sasl install-data-polkit \
install-logrotate
mkdir -p $(DESTDIR)$(sysconfdir)/libvirt/qemu/networks/autostart
$(INSTALL_DATA) $(srcdir)/default-network.xml \
$(DESTDIR)$(sysconfdir)/$(default_xml_dest)
@ -198,6 +199,17 @@ remote_dispatch_ret.h: $(srcdir)/remote_generate_stubs.pl remote_protocol.x
perl -w $(srcdir)/remote_generate_stubs.pl -r $(srcdir)/remote_protocol.x > $@
libvirtd.logrotate: libvirtd.logrotate.in
sed \
-e s!\@localstatedir\@!@localstatedir@!g \
< $< > $@-t
mv $@-t $@
install-logrotate: libvirtd.logrotate
mkdir -p $(DESTDIR)$(localstatedir)/log/libvirt/qemu/
mkdir -p $(DESTDIR)$(sysconfdir)/logrotate.d/
$(INSTALL_DATA) $< $(DESTDIR)$(sysconfdir)/logrotate.d/libvirtd
if LIBVIRT_INIT_SCRIPTS_RED_HAT
install-init: libvirtd.init
mkdir -p $(DESTDIR)$(sysconfdir)/rc.d/init.d

View File

@ -0,0 +1,8 @@
@localstatedir@/log/libvirt/qemu/*.log {
daily
missingok
rotate 7
compress
delaycompress
copytruncate
}

View File

@ -841,6 +841,8 @@ static int qemudStartVMDaemon(virConnectPtr conn,
unsigned int qemuCmdFlags;
fd_set keepfd;
const char *emulator;
uid_t uid = geteuid();
mode_t logmode;
FD_ZERO(&keepfd);
@ -884,8 +886,12 @@ static int qemudStartVMDaemon(virConnectPtr conn,
return -1;
}
if ((vm->logfile = open(logfile, O_CREAT | O_TRUNC | O_WRONLY,
S_IRUSR | S_IWUSR)) < 0) {
logmode = O_CREAT | O_WRONLY;
if (uid != 0)
logmode |= O_TRUNC;
else
logmode |= O_APPEND;
if ((vm->logfile = open(logfile, logmode, S_IRUSR | S_IWUSR)) < 0) {
qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
_("failed to create logfile %s: %s"),
logfile, strerror(errno));