]> xenbits.xensource.com Git - people/pauldu/qemu.git/commitdiff
hmp: Restrict auto-complete in preconfig
authorDr. David Alan Gilbert <dgilbert@redhat.com>
Wed, 20 Jun 2018 15:39:43 +0000 (16:39 +0100)
committerDr. David Alan Gilbert <dgilbert@redhat.com>
Thu, 21 Jun 2018 11:49:02 +0000 (12:49 +0100)
Don't show the commands that aren't available.

Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
Reviewed-by: Peter Xu <peterx@redhat.com>
Reviewed-by: Igor Mammedov <imammedo@redhat.com>
Message-Id: <20180620153947.30834-4-dgilbert@redhat.com>
Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
monitor.c

index 18c2207e6d0cb4d0c5ce8c873a4834e6838d3fed..068c094a9a82bb975d9f55c261946e005ac8810b 100644 (file)
--- a/monitor.c
+++ b/monitor.c
@@ -4020,12 +4020,17 @@ static void monitor_find_completion_by_table(Monitor *mon,
             cmdname = args[0];
         readline_set_completion_index(mon->rs, strlen(cmdname));
         for (cmd = cmd_table; cmd->name != NULL; cmd++) {
-            cmd_completion(mon, cmdname, cmd->name);
+            if (!runstate_check(RUN_STATE_PRECONFIG) ||
+                 cmd_can_preconfig(cmd)) {
+                cmd_completion(mon, cmdname, cmd->name);
+            }
         }
     } else {
         /* find the command */
         for (cmd = cmd_table; cmd->name != NULL; cmd++) {
-            if (compare_cmd(args[0], cmd->name)) {
+            if (compare_cmd(args[0], cmd->name) &&
+                (!runstate_check(RUN_STATE_PRECONFIG) ||
+                 cmd_can_preconfig(cmd))) {
                 break;
             }
         }