Re: [PATCH v6 11/27] util: introduce some API docs for logging APIs
Markus Armbruster <[email protected]> Wed, 18 Feb 2026 10:38:41 +0100
| Newsgroups | org.nongnu.qemu-rust,org.nongnu.qemu-devel |
|---|---|
| Message-ID | <[email protected]> |
Daniel P. Berrangé <[email protected]> writes: > There is a gotcha with qemu_log() usage in a threaded process. > If fragments of a log message are output via qemu_log() it is > possible for messages from two threads to get mixed up. To > prevent this qemu_log_trylock() should be used, along with > fprintf(f) calls. > > This is a subtle problem that needs to be explained in the > API docs to ensure correct usage. > > In the Rust code, the log_mask_ln method which is conceptually > equivalent to the C qemu_log() call will unconditionally append > a newline so must only ever be used for complete log messages. > > Reported-by: Markus Armbruster <[email protected]> > Signed-off-by: Daniel P. Berrangé <[email protected]> Reviewed-by: Markus Armbruster <[email protected]>