monitor: do not use mb_read/mb_set for suspend_cnt
authorPaolo Bonzini <pbonzini@redhat.com>
Fri, 3 Mar 2023 12:32:13 +0000 (13:32 +0100)
committerPaolo Bonzini <pbonzini@redhat.com>
Thu, 25 May 2023 08:18:33 +0000 (10:18 +0200)
commit6ee7c82d0df9bb6e972a8ea689b935df3ba37486
treef99a5786fb54b9072069e498313d4336bd9aaa6a
parent4cb96b974265f97a9902b4458e50d01082572a16
monitor: do not use mb_read/mb_set for suspend_cnt

Clean up monitor_event to just use monitor_suspend/monitor_resume,
using mon->mux_out to protect against incorrect nesting (especially
on startup).

The only remaining case of reading suspend_cnt is in the can_read
callback, which is just advisory and can use qatomic_read.

As an extra benefit, mux_out is now simply protected by mon_lock.
Also, moving the prompt to the beginning of the main loop removes
it from the output in some error cases where QEMU does not actually
start successfully.  It is not a full fix and it would be nice to
also remove the monitor heading, but this is already a small (though
unintentional) improvement.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
monitor/hmp.c
monitor/monitor-internal.h
monitor/monitor.c
tests/qemu-iotests/051.out
tests/qemu-iotests/051.pc.out