monitor: add more *_locked() functions
Allow flushing and printing to the monitor while mon->mon_lock is held. This will help cleaning up the locking of mon->mux_out and mon->suspend_cnt. Reviewed-by: Richard Henderson <richard.henderson@linaro.org> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
This commit is contained in:
parent
c5d0c55f1a
commit
4cb96b9742
@ -40,6 +40,9 @@ void monitor_flush(Monitor *mon);
|
|||||||
int monitor_set_cpu(Monitor *mon, int cpu_index);
|
int monitor_set_cpu(Monitor *mon, int cpu_index);
|
||||||
int monitor_get_cpu_index(Monitor *mon);
|
int monitor_get_cpu_index(Monitor *mon);
|
||||||
|
|
||||||
|
int monitor_puts_locked(Monitor *mon, const char *str);
|
||||||
|
void monitor_flush_locked(Monitor *mon);
|
||||||
|
|
||||||
void *gpa2hva(MemoryRegion **p_mr, hwaddr addr, uint64_t size, Error **errp);
|
void *gpa2hva(MemoryRegion **p_mr, hwaddr addr, uint64_t size, Error **errp);
|
||||||
|
|
||||||
void monitor_read_command(MonitorHMP *mon, int show_prompt);
|
void monitor_read_command(MonitorHMP *mon, int show_prompt);
|
||||||
|
@ -154,8 +154,6 @@ static inline bool monitor_is_hmp_non_interactive(const Monitor *mon)
|
|||||||
return !monitor_uses_readline(container_of(mon, MonitorHMP, common));
|
return !monitor_uses_readline(container_of(mon, MonitorHMP, common));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void monitor_flush_locked(Monitor *mon);
|
|
||||||
|
|
||||||
static gboolean monitor_unblocked(void *do_not_use, GIOCondition cond,
|
static gboolean monitor_unblocked(void *do_not_use, GIOCondition cond,
|
||||||
void *opaque)
|
void *opaque)
|
||||||
{
|
{
|
||||||
@ -168,7 +166,7 @@ static gboolean monitor_unblocked(void *do_not_use, GIOCondition cond,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Caller must hold mon->mon_lock */
|
/* Caller must hold mon->mon_lock */
|
||||||
static void monitor_flush_locked(Monitor *mon)
|
void monitor_flush_locked(Monitor *mon)
|
||||||
{
|
{
|
||||||
int rc;
|
int rc;
|
||||||
size_t len;
|
size_t len;
|
||||||
@ -207,12 +205,11 @@ void monitor_flush(Monitor *mon)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* flush at every end of line */
|
/* flush at every end of line */
|
||||||
int monitor_puts(Monitor *mon, const char *str)
|
int monitor_puts_locked(Monitor *mon, const char *str)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
char c;
|
char c;
|
||||||
|
|
||||||
qemu_mutex_lock(&mon->mon_lock);
|
|
||||||
for (i = 0; str[i]; i++) {
|
for (i = 0; str[i]; i++) {
|
||||||
c = str[i];
|
c = str[i];
|
||||||
if (c == '\n') {
|
if (c == '\n') {
|
||||||
@ -223,11 +220,16 @@ int monitor_puts(Monitor *mon, const char *str)
|
|||||||
monitor_flush_locked(mon);
|
monitor_flush_locked(mon);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
qemu_mutex_unlock(&mon->mon_lock);
|
|
||||||
|
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int monitor_puts(Monitor *mon, const char *str)
|
||||||
|
{
|
||||||
|
QEMU_LOCK_GUARD(&mon->mon_lock);
|
||||||
|
return monitor_puts_locked(mon, str);
|
||||||
|
}
|
||||||
|
|
||||||
int monitor_vprintf(Monitor *mon, const char *fmt, va_list ap)
|
int monitor_vprintf(Monitor *mon, const char *fmt, va_list ap)
|
||||||
{
|
{
|
||||||
char *buf;
|
char *buf;
|
||||||
|
Loading…
Reference in New Issue
Block a user