Daniel P. Berrangé <berra...@redhat.com> writes:

> Some monitor functions, most notably, monitor_cur() rely on global
> data being initialized by 'monitor_init_globals()'. The latter is
> called relatively late in startup. If code triggers error_report()
> before monitor_init_globals() is called, QEMU will abort when
> accessing the uninitialized monitor mutex.
>
> The critical monitor global data must be initialized from a
> constructor function, to improve the guarantee that it is done
> before any possible calls to monitor_cur(). Not only that, but
> the constructor must be marked to run before the default
> constructor in case any of them trigger error reporting.

Is error reporting from constructors a good idea?  I feel they're best
used for simple initializations only.

Do we actually do it?

> Note in particular that the RCU constructor will spawn a background
> thread so we might even have non-constructor QEMU code running
> concurrently with other constructors.

Ugh!

Arguably

  Fixes: e69ee454b5f9 (monitor: Make current monitor a per-coroutine property)

I never liked the @coroutine_mon hash table (which is what broke early
monitor_cur()), but accepted it for want of better ideas.

> Reviewed-by: Richard Henderson <richard.hender...@linaro.org>
> Reviewed-by: Dr. David Alan Gilbert <d...@treblig.org>
> Signed-off-by: Daniel P. Berrangé <berra...@redhat.com>


Reply via email to