monitor: allow calling monitor_resume under mon_lock
authorPaolo Bonzini <pbonzini@redhat.com>
Wed, 17 May 2023 15:19:03 +0000 (17:19 +0200)
committerPaolo Bonzini <pbonzini@redhat.com>
Thu, 25 May 2023 08:18:33 +0000 (10:18 +0200)
Move monitor_resume()'s call to readline_show_prompt() outside the
potentially locked section.  Reuse the existing monitor_accept_input()
bottom half for this purpose.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
monitor/monitor.c

index 4b11bca2a21d7105d4072eef0d2e279e4e23048f..7080d2da8ec6cf16f1d203536b9da3c2fab8792f 100644 (file)
@@ -567,6 +567,12 @@ static void monitor_accept_input(void *opaque)
 {
     Monitor *mon = opaque;
 
+    if (!monitor_is_qmp(mon)) {
+        MonitorHMP *hmp_mon = container_of(mon, MonitorHMP, common);
+        assert(hmp_mon->rs);
+        readline_show_prompt(hmp_mon->rs);
+    }
+
     qemu_chr_fe_accept_input(&mon->chr);
 }
 
@@ -585,12 +591,6 @@ void monitor_resume(Monitor *mon)
             ctx = qemu_get_aio_context();
         }
 
-        if (!monitor_is_qmp(mon)) {
-            MonitorHMP *hmp_mon = container_of(mon, MonitorHMP, common);
-            assert(hmp_mon->rs);
-            readline_show_prompt(hmp_mon->rs);
-        }
-
         aio_bh_schedule_oneshot(ctx, monitor_accept_input, mon);
     }