mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-02 23:33:54 -06:00
monitor: Use getter/setter functions for cur_mon
cur_mon really needs to be coroutine-local as soon as we move monitor command handlers to coroutines and let them yield. As a first step, just remove all direct accesses to cur_mon so that we can implement this in the getter function later. Signed-off-by: Kevin Wolf <kwolf@redhat.com> Message-Id: <20201005155855.256490-4-kwolf@redhat.com> Reviewed-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com> Signed-off-by: Markus Armbruster <armbru@redhat.com>
This commit is contained in:
parent
87e6f4a4d6
commit
947e47448d
21 changed files with 73 additions and 46 deletions
|
@ -125,13 +125,12 @@ char *qmp_human_monitor_command(const char *command_line, bool has_cpu_index,
|
|||
|
||||
monitor_data_init(&hmp.common, false, true, false);
|
||||
|
||||
old_mon = cur_mon;
|
||||
cur_mon = &hmp.common;
|
||||
old_mon = monitor_set_cur(&hmp.common);
|
||||
|
||||
if (has_cpu_index) {
|
||||
int ret = monitor_set_cpu(&hmp.common, cpu_index);
|
||||
if (ret < 0) {
|
||||
cur_mon = old_mon;
|
||||
monitor_set_cur(old_mon);
|
||||
error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "cpu-index",
|
||||
"a CPU number");
|
||||
goto out;
|
||||
|
@ -139,7 +138,7 @@ char *qmp_human_monitor_command(const char *command_line, bool has_cpu_index,
|
|||
}
|
||||
|
||||
handle_hmp_command(&hmp, command_line);
|
||||
cur_mon = old_mon;
|
||||
monitor_set_cur(old_mon);
|
||||
|
||||
WITH_QEMU_LOCK_GUARD(&hmp.common.mon_lock) {
|
||||
if (qstring_get_length(hmp.common.outbuf) > 0) {
|
||||
|
@ -297,7 +296,7 @@ static CPUState *mon_get_cpu_sync(Monitor *mon, bool synchronize)
|
|||
|
||||
CPUState *mon_get_cpu(void)
|
||||
{
|
||||
return mon_get_cpu_sync(cur_mon, true);
|
||||
return mon_get_cpu_sync(monitor_cur(), true);
|
||||
}
|
||||
|
||||
CPUArchState *mon_get_cpu_env(void)
|
||||
|
@ -1232,6 +1231,7 @@ static void hmp_acl_remove(Monitor *mon, const QDict *qdict)
|
|||
|
||||
void qmp_getfd(const char *fdname, Error **errp)
|
||||
{
|
||||
Monitor *cur_mon = monitor_cur();
|
||||
mon_fd_t *monfd;
|
||||
int fd, tmp_fd;
|
||||
|
||||
|
@ -1270,6 +1270,7 @@ void qmp_getfd(const char *fdname, Error **errp)
|
|||
|
||||
void qmp_closefd(const char *fdname, Error **errp)
|
||||
{
|
||||
Monitor *cur_mon = monitor_cur();
|
||||
mon_fd_t *monfd;
|
||||
int tmp_fd;
|
||||
|
||||
|
@ -1356,7 +1357,7 @@ AddfdInfo *qmp_add_fd(bool has_fdset_id, int64_t fdset_id, bool has_opaque,
|
|||
const char *opaque, Error **errp)
|
||||
{
|
||||
int fd;
|
||||
Monitor *mon = cur_mon;
|
||||
Monitor *mon = monitor_cur();
|
||||
AddfdInfo *fdinfo;
|
||||
|
||||
fd = qemu_chr_fe_get_msgfd(&mon->chr);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue