cpu_list_add() was doing 2 distinct things:
- assign some index to vCPU
- add unrealized (thus in inconsistent state) vcpu to &cpus_queue
Code using CPU_FOREACH() macro would iterate over possibly
unrealized vCPUs, often dealt with special casing.
In order to avoid that, we move the addition of vCPU to global queue
to the DeviceWire handler, which is called just before switching the
vCPU to REALIZED state. This ensure all &cpus_queue users (like via
&first_cpu or CPU_FOREACH) get a realized vCPU in consistent state.
Similarly we remove it from the global queue at DeviceUnwire phase,
just after marking the vCPU UNREALIZED.
Signed-off-by: Philippe Mathieu-Daudé<philmd@linaro.org>
---
cpu-common.c | 2 --
hw/core/cpu-common.c | 5 +++++
2 files changed, 5 insertions(+), 2 deletions(-)