We have .initialized in EventNotifier to track was it actually
initialized, and we have a comment that @fd passed to
event_notifier_init_fd() must be an eventfd object.
Still, there are two specific users, which ignore these things,
and use -1 as specific value storing in notifier, to mark it
"uninitialized".
Let's make strict API:
- store only valid FDs in initialized notifier
- _set() asserts that passed fd is valid
- _get() asserts that notifier is initialized (actually, except
the two specific cases we rework, all other callers are not
prepared to notifier being uninitialized when _get() is called.
In this case _get() returns 0 (which is a valid fd), and caller
will mistakenly use it, which is worse than abort())
- for two specific cases, implement additional getter for .initialized
field itself
- zeroed notifier is uninitialized(.initialized is false)
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Message-ID: <20260911185800.134135-1-vsementsov@yandex-team.ru>