On Wed, Sep 24, 2025 at 02:34:30PM +0200, Markus Armbruster wrote:
> Pondering the interleave between logging and error reporting led me to
> an interleave between error reporting and itself.
> 
> vreport() prints a single line to stderr in several parts:
> 
> * Timestamp (if enabled)
> 
> * Guest name (if enabled)
> 
> * Program name
> 
> * Location (if there is one)
> 
> * Message type
> 
> * Message text
> 
> * Newline
> 
> Stdio guarantees that each part comes out as a whole even when other
> threads print to the same FILE at the same time.  But another thread's
> print output can still squeeze in between parts.  Unlikely, but
> possible.  To avoid it, we'd need to guard vreport()'s printing with
> flockfile() ... funlockfile().
> 
> Thoughts?

You are totally correct. The qemu_log code will do the right thing
with flockfile /funlockfile, but we're missing that serialization
in the error report code. It doesn't matter quite as much as logging,
since much of time when error_report is used, it is in a scenario
that is likely to either be serialized, or be about to call exit/
abort. None the less I'm sure we can come up with real world
scenarios where error report will be concurrent in QEMU that can
interleave, so we should add the flockfile usage.

With regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|


Reply via email to