libvirt/src/logging
Daniel P. Berrangé cc9e80c593 logging: ensure pending I/O is drained before reading position
The virtualization driver has two connections to the virtlogd daemon,
one pipe fd for writing to the log file, and one socket fd for making
RPC calls. The typical sequence is to write some data to the pipe fd and
then make an RPC call to determine the current log file offset.

Unfortunately these two operations are not guaranteed to be handling in
order by virtlogd. The event loop for virtlogd may identify an incoming
event on both the pipe fd and socket fd in the same iteration of the
event loop. It is then entirely possible that it will process the socket
fd RPC call before reading the pending log data from the pipe fd.

As a result the virtualization driver will get an outdated log file
offset reported back.

This can be seen with the QEMU driver where, when a guest fails to
start, it will randomly include too much data in the error message it
has fetched from the log file.

The solution is to ensure we have drained all pending data from the pipe
fd before reporting the log file offset. The pipe fd is always in
blocking mode, so cares needs to be taken to avoid blocking. When
draining this is taken care of by using poll(). The extra complication
is that they might already be an event loop dispatch pending on the pipe
fd. If we have just drained the pipe this pending event will be invalid
so must be discarded.

See also https://bugzilla.redhat.com/show_bug.cgi?id=1356108

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2018-12-18 14:49:59 +00:00
..
log_daemon_config.c Remove all Author(s): lines from source file headers 2018-12-13 16:08:38 +00:00
log_daemon_config.h Enforce a standard header file guard symbol name 2018-12-14 10:47:13 +00:00
log_daemon_dispatch.c Remove all Author(s): lines from source file headers 2018-12-13 16:08:38 +00:00
log_daemon_dispatch.h Enforce a standard header file guard symbol name 2018-12-14 10:47:13 +00:00
log_daemon.c Remove all Author(s): lines from source file headers 2018-12-13 16:08:38 +00:00
log_daemon.h Enforce a standard header file guard symbol name 2018-12-14 10:47:13 +00:00
log_handler.c logging: ensure pending I/O is drained before reading position 2018-12-18 14:49:59 +00:00
log_handler.h Enforce a standard header file guard symbol name 2018-12-14 10:47:13 +00:00
log_manager.c Remove all Author(s): lines from source file headers 2018-12-13 16:08:38 +00:00
log_manager.h Enforce a standard header file guard symbol name 2018-12-14 10:47:13 +00:00
log_protocol.x log: daemon: Add remote protocol handling for the log appending API 2016-06-07 18:10:29 +02:00
Makefile.inc.am make: split logging daemon build rules into logging/Makefile.inc.am 2018-03-05 17:12:01 +00:00
test_virtlogd.aug.in log: update docs for daemons to improve user understanding 2018-05-11 17:11:46 +01:00
virtlogd-admin.socket.in logd: add support for admin protocol in virtlogd 2018-01-31 15:17:47 +00:00
virtlogd.aug rpc: remove remains of obsolete log_buffer_size config parameter 2018-03-23 10:44:35 +00:00
virtlogd.conf log: update docs for daemons to improve user understanding 2018-05-11 17:11:46 +01:00
virtlogd.init.in Fix LSB requirements in service script and sync them 2016-01-11 15:49:13 +01:00
virtlogd.pod Use https:// links for most sites 2017-10-16 10:22:34 +01:00
virtlogd.service.in logd: add support for admin protocol in virtlogd 2018-01-31 15:17:47 +00:00
virtlogd.socket.in virtlogd: Don't stop or restart along with libvirtd 2016-09-20 15:22:04 +02:00
virtlogd.sysconf Import stripped down virtlockd code as basis of virtlogd 2015-11-26 14:28:55 +00:00