crosvm/base
Noah Gold 39a9977505 base: syslog panics on double-init.
We've had multiple silent bugs stemming from the current double-init
behavior of the logging system. To prevent that from happening for the
fourth time, this CL makes all subsequent logging inits panic. This way,
it will be much harder to commit code that won't work. Details:

* Current behavior: only the first init applies logging configuration.
  The subsequent inits will silently do nothing, and discard the
  supplied settings. These settings could be important things like
  setting the log file, whether to echo to stderr, etc.
* New behavior: after the first call to init, any subseqent call will
  panic.

NOTE: If this CL breaks a downstream project, there is very likely
a bug in that project which may be causing logs from crosvm to be
lost. Please fix that bug, or revert this CL in the downstream project
temporarily.

In this CL, we discovered that openlog_and_get_socket (used in linux
syslog) mutates global state. In tests, this manifested as a failure.
For this CL, we've chosen to preserve the behavior of only re-creating
State (and by extension, PlatformSyslog) when there is no STATE
currently set. (This behavior is nice for other reasons since it keeps
us from performing unnecessary operations when a no-op is possible.)

BUG=b:238680255
TEST=presubmit & tested downstream by verifying log files were written.
Also ran example_simple & verified it didn't panic.

Change-Id: Iad64c1b52b917e63d14a42cbbd1739ef94107fae
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3756274
Commit-Queue: Noah Gold <nkgold@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Vikram Auradkar <auradkar@google.com>
2022-07-14 02:37:03 +00:00
..
base_event_token_derive base: replace PollToken with EventToken tree-wide 2022-06-02 22:30:38 +00:00
src base: syslog panics on double-init. 2022-07-14 02:37:03 +00:00
.build_test_serial Refactoring: Move common/base into base 2022-03-17 00:01:27 +00:00
Cargo.toml Cargo: bump all rand dependencies to 0.8 2022-06-30 23:22:37 +00:00