diff mbox series

[v6,04/11] hmp: disable monitor in preconfig state

Message ID 1524841523-95513-5-git-send-email-imammedo@redhat.com
State New
Headers show
Series enable numa configuration before machine_init() from QMP | expand

Commit Message

Igor Mammedov April 27, 2018, 3:05 p.m. UTC
Ban it for now, if someone would need it to work early,
one would have to implement checks if HMP command is valid
at preconfig state.

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
---
v5:
  * add 'use QMP instead" to error message, suggesting user
    the right interface to use
v4:
  * v3 was only printing error but not preventing command execution,
    Fix it by returning after printing error message.
    ("Dr. David Alan Gilbert" <dgilbert@redhat.com>)
---
 monitor.c | 6 ++++++
 1 file changed, 6 insertions(+)

Comments

Eric Blake April 27, 2018, 9:48 p.m. UTC | #1
On 04/27/2018 10:05 AM, Igor Mammedov wrote:
> Ban it for now, if someone would need it to work early,
> one would have to implement checks if HMP command is valid
> at preconfig state.
> 
> Signed-off-by: Igor Mammedov <imammedo@redhat.com>
> ---

Reviewed-by: Eric Blake <eblake@redhat.com>

There's a bisection window between when RUN_STATE_PRECONFIG is added and
this patch where HMP can be used to screw things up, but I'm less
worried about that being triggered in practice.  If you want to avoid
that window, then introduce RUN_STATE_PRECONFIG in one patch, then this
patch, then add command line --preconfig in a later patch (thus, NOTHING
can get into preconfig state, even though the code is starting to be
modified to honor it, until --preconfig is enabled on the command line).
diff mbox series

Patch

diff --git a/monitor.c b/monitor.c
index 39f8ee1..0ffdf1d 100644
--- a/monitor.c
+++ b/monitor.c
@@ -3374,6 +3374,12 @@  static void handle_hmp_command(Monitor *mon, const char *cmdline)
 
     trace_handle_hmp_command(mon, cmdline);
 
+    if (runstate_check(RUN_STATE_PRECONFIG)) {
+        monitor_printf(mon, "HMP not available in preconfig state, "
+                            "use QMP instead\n");
+        return;
+    }
+
     cmd = monitor_parse_command(mon, cmdline, &cmdline, mon->cmd_table);
     if (!cmd) {
         return;