Skip to contentSkip to conversation

Reenable hmp for preconfig mode

PATCH Superseded Dr. David Alan Gilbert (git) 4 participants 33 messages Jun 5, 2018 – Jun 8, 2018

v1 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#0 lore raw

cover Reenable hmp for preconfig mode

From: "Dr. David Alan Gilbert" <[email protected]>

Reenable HMP in preconfig mode; it's pretty
easy and anyway I want to do a similar thing for OOB eventually. We'll want to enable more commands in preconfig mode to make it useful at some point.

Dave

Dr. David Alan Gilbert (6):
hmp: Add flag for preconfig commands
hmp: Allow help on preconfig commands
hmp: Restrict auto-complete in preconfig
hmp: Add info commands for preconfig
hmp: add exit_preconfig
hmp: Allow HMP in preconfig state again

 hmp-commands-info.hx |  9 +++++++++
 hmp-commands.hx      | 17 +++++++++++++++++
 hmp.c                |  7 +++++++
 hmp.h                |  1 +
 monitor.c            | 42 +++++++++++++++++++++++++++++++++---------
 5 files changed, 67 insertions(+), 9 deletions(-)
Signature · 1 line
2.17.0
#1 lore raw

PATCH 1/6 hmp: Add flag for preconfig commands

From: "Dr. David Alan Gilbert" <[email protected]>

Add a flag to command definitions to allow them to be used in preconfig and check it.

---
 monitor.c | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)
monitor.c +19 -0
index 6d0cec552e..50b95f41db 100644
@@ -128,6 +128,7 @@ typedef struct mon_cmd_t {
     const char *args_type;
     const char *params;
     const char *help;
+    const char *flags; /* p=preconfig */
     void (*cmd)(Monitor *mon, const QDict *qdict);
     /* @sub_table is a list of 2nd level of commands. If it does not exist,
      * cmd should be used. If it exists, sub_table[?].cmd should be
@@ -936,6 +937,19 @@ static int parse_cmdline(const char *cmdline,
     return -1;
 }
 
+/*
+ * Returns true if the command can be executed in preconfig mode
+ * i.e. it has the 'p' flag.
+ */
+static bool cmd_can_preconfig(const mon_cmd_t *cmd)
+{
+    if (!cmd->flags) {
+        return false;
+    }
+
+    return strchr(cmd->flags, 'p');
+}
+
 static void help_cmd_dump_one(Monitor *mon,
                               const mon_cmd_t *cmd,
                               char **prefix_args,
@@ -2976,6 +2990,11 @@ static const mon_cmd_t *monitor_parse_command(Monitor *mon,
                        (int)(p - cmdp_start), cmdp_start);
         return NULL;
     }
+    if (runstate_check(RUN_STATE_PRECONFIG) && !cmd_can_preconfig(cmd)) {
+        monitor_printf(mon, "Command '%.*s' not available in preconfig\n",
+                       (int)(p - cmdp_start), cmdp_start);
+        return NULL;
+    }
 
     /* filter out following useless space */
     while (qemu_isspace(*p)) {
Signature · 1 line
2.17.0
#3 lore raw

Re: [Qemu-devel] [PATCH 1/6] hmp: Add flag for preconfig commands

In reply to Dr. David Alan Gilbert (git)
Quoted 44 lines · Dr. David Alan Gilbert (git)

From: "Dr. David Alan Gilbert" <[email protected]>

Add a flag to command definitions to allow them to be used in preconfig and check it.

---
 monitor.c | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)
monitor.c +14 -0
index 6d0cec552e..50b95f41db 100644
@@ -128,6 +128,7 @@ typedef struct mon_cmd_t {
     const char *args_type;
     const char *params;
     const char *help;
+    const char *flags; /* p=preconfig */
     void (*cmd)(Monitor *mon, const QDict *qdict);
     /* @sub_table is a list of 2nd level of commands. If it does not exist,
      * cmd should be used. If it exists, sub_table[?].cmd should be
@@ -936,6 +937,19 @@ static int parse_cmdline(const char *cmdline,
     return -1;
 }
 
+/*
+ * Returns true if the command can be executed in preconfig mode
+ * i.e. it has the 'p' flag.
+ */
+static bool cmd_can_preconfig(const mon_cmd_t *cmd)
+{
+    if (!cmd->flags) {
+        return false;
+    }
+
+    return strchr(cmd->flags, 'p');
+}
+
 static void help_cmd_dump_one(Monitor *mon,
                               const mon_cmd_t *cmd,
                               char **prefix_args,
@@ -2976,6 +2990,11 @@ static const mon_cmd_t *monitor_parse_command(Monitor *mon,
                        (int)(p - cmdp_start), cmdp_start);

monitor.c static const mon_cmd_t *monitor_parse_command(Monitor *mon, · line 3000

Quoted 10 lines
monitor.c +5 -0
         return NULL;
     }
+    if (runstate_check(RUN_STATE_PRECONFIG) && !cmd_can_preconfig(cmd)) {
+        monitor_printf(mon, "Command '%.*s' not available in preconfig\n",
+                       (int)(p - cmdp_start), cmdp_start);
+        return NULL;
+    }
 
     /* filter out following useless space */
     while (qemu_isspace(*p)) {

This

(qemu) c
Command 'c' not available in preconfig

is not a nice user experience. We can do better (paraphrasing myself):

Command 'c' not available with -preconfig until you complete configuration with QMP

Note that this talks to the user in the user's terms (-preconfig) instead of internal terms ("in preconfig", whatever that is), and is more specific on how to ready the monitor.

Obviously, "with QMP" needs an update once HMP acquires a command to exit preconfig state.

#4 lore raw

Re: [Qemu-devel] [PATCH 1/6] hmp: Add flag for preconfig commands

Quoted 67 lines · * Markus Armbruster ([email protected]) wrote:
Quoted 44 lines · Dr. David Alan Gilbert (git)

From: "Dr. David Alan Gilbert" <[email protected]>

Add a flag to command definitions to allow them to be used in preconfig and check it.

---
 monitor.c | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)
monitor.c +14 -0
index 6d0cec552e..50b95f41db 100644
@@ -128,6 +128,7 @@ typedef struct mon_cmd_t {
     const char *args_type;
     const char *params;
     const char *help;
+    const char *flags; /* p=preconfig */
     void (*cmd)(Monitor *mon, const QDict *qdict);
     /* @sub_table is a list of 2nd level of commands. If it does not exist,
      * cmd should be used. If it exists, sub_table[?].cmd should be
@@ -936,6 +937,19 @@ static int parse_cmdline(const char *cmdline,
     return -1;
 }
 
+/*
+ * Returns true if the command can be executed in preconfig mode
+ * i.e. it has the 'p' flag.
+ */
+static bool cmd_can_preconfig(const mon_cmd_t *cmd)
+{
+    if (!cmd->flags) {
+        return false;
+    }
+
+    return strchr(cmd->flags, 'p');
+}
+
 static void help_cmd_dump_one(Monitor *mon,
                               const mon_cmd_t *cmd,
                               char **prefix_args,
@@ -2976,6 +2990,11 @@ static const mon_cmd_t *monitor_parse_command(Monitor *mon,
                        (int)(p - cmdp_start), cmdp_start);

monitor.c static const mon_cmd_t *monitor_parse_command(Monitor *mon, · line 3000

Quoted 10 lines
monitor.c +5 -0
         return NULL;
     }
+    if (runstate_check(RUN_STATE_PRECONFIG) && !cmd_can_preconfig(cmd)) {
+        monitor_printf(mon, "Command '%.*s' not available in preconfig\n",
+                       (int)(p - cmdp_start), cmdp_start);
+        return NULL;
+    }
 
     /* filter out following useless space */
     while (qemu_isspace(*p)) {

This

(qemu) c
Command 'c' not available in preconfig

is not a nice user experience. We can do better (paraphrasing myself):

Command 'c' not available with -preconfig until you complete configuration with QMP

Quoted 6 lines

Note that this talks to the user in the user's terms (-preconfig) instead of internal terms ("in preconfig", whatever that is), and is more specific on how to ready the monitor.

Obviously, "with QMP" needs an update once HMP acquires a command to exit preconfig state.

This series already adds that command.

Dave

--
Dr. David Alan Gilbert / [email protected] / Manchester, UK

#5 lore raw

PATCH 2/6 hmp: Allow help on preconfig commands

In reply to Dr. David Alan Gilbert (git)

From: "Dr. David Alan Gilbert" <[email protected]>

Allow the 'help' command in preconfig state but
make it only list the preconfig commands.

---
 hmp-commands.hx | 1 +
 monitor.c       | 8 +++++++-
 2 files changed, 8 insertions(+), 1 deletion(-)
hmp-commands.hx +1 -0
index 0734fea931..8bf590ae4b 100644
@@ -15,6 +15,7 @@ ETEXI
         .params     = "[cmd]",
         .help       = "show the help",
         .cmd        = do_help_cmd,
+        .flags      = "p",
     },
 
 STEXI
monitor.c +7 -1
index 50b95f41db..7d1709c225 100644
@@ -957,6 +957,10 @@ static void help_cmd_dump_one(Monitor *mon,
 {
     int i;
 
+    if (runstate_check(RUN_STATE_PRECONFIG) && !cmd_can_preconfig(cmd)) {
+        return;
+    }
+
     for (i = 0; i < prefix_args_nb; i++) {
         monitor_printf(mon, "%s ", prefix_args[i]);
     }
@@ -979,7 +983,9 @@ static void help_cmd_dump(Monitor *mon, const mon_cmd_t *cmds,
 
     /* Find one entry to dump */
     for (cmd = cmds; cmd->name != NULL; cmd++) {
-        if (compare_cmd(args[arg_index], cmd->name)) {
+        if (compare_cmd(args[arg_index], cmd->name) &&
+            ((!runstate_check(RUN_STATE_PRECONFIG) ||
+                cmd_can_preconfig(cmd)))) {
             if (cmd->sub_table) {
                 /* continue with next arg */
                 help_cmd_dump(mon, cmd->sub_table,
Signature · 1 line
2.17.0
Reviewed-by on v1 2/6
#6 lore raw

Re: [Qemu-devel] [PATCH 2/6] hmp: Allow help on preconfig commands

Quoted 39 lines · Dr. David Alan Gilbert (git)

From: "Dr. David Alan Gilbert" <[email protected]>

Allow the 'help' command in preconfig state but
make it only list the preconfig commands.

---
 hmp-commands.hx | 1 +
 monitor.c       | 8 +++++++-
 2 files changed, 8 insertions(+), 1 deletion(-)
hmp-commands.hx +1 -0
index 0734fea931..8bf590ae4b 100644
@@ -15,6 +15,7 @@ ETEXI
         .params     = "[cmd]",
         .help       = "show the help",
         .cmd        = do_help_cmd,
+        .flags      = "p",
     },
 
 STEXI
monitor.c +4 -0
index 50b95f41db..7d1709c225 100644
@@ -957,6 +957,10 @@ static void help_cmd_dump_one(Monitor *mon,
 {
     int i;
 
+    if (runstate_check(RUN_STATE_PRECONFIG) && !cmd_can_preconfig(cmd)) {
+        return;
+    }
+
     for (i = 0; i < prefix_args_nb; i++) {
         monitor_printf(mon, "%s ", prefix_args[i]);
     }

monitor.c static void help_cmd_dump(Monitor *mon, const mon_cmd_t *cmds, · line 988

Quoted 7 lines
monitor.c +3 -1
@@ -979,7 +983,9 @@ static void help_cmd_dump(Monitor *mon, const mon_cmd_t *cmds,
 
     /* Find one entry to dump */
     for (cmd = cmds; cmd->name != NULL; cmd++) {
-        if (compare_cmd(args[arg_index], cmd->name)) {
+        if (compare_cmd(args[arg_index], cmd->name) &&
+            ((!runstate_check(RUN_STATE_PRECONFIG) ||
+                cmd_can_preconfig(cmd)))) {

I saw that this pattern is used for multiple times already. Maybe it's time to introduce hmp_cmd_is_available(). :) I'll leave the decision to you...

Signature · 1 line
Peter Xu
#7 lore raw

PATCH 3/6 hmp: Restrict auto-complete in preconfig

In reply to Dr. David Alan Gilbert (git)

From: "Dr. David Alan Gilbert" <[email protected]>

Don't show the commands that aren't available.

---
 monitor.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
monitor.c +7 -2
index 7d1709c225..9b29787a52 100644
@@ -3950,12 +3950,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;
             }
         }
Signature · 1 line
2.17.0
Reviewed-by on v1 3/6
#8 lore raw

Re: [Qemu-devel] [PATCH 3/6] hmp: Restrict auto-complete in preconfig

Quoted 20 lines · Dr. David Alan Gilbert (git)

From: "Dr. David Alan Gilbert" <[email protected]>

Don't show the commands that aren't available.

---
 monitor.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
monitor.c +2 -1
index 7d1709c225..9b29787a52 100644
@@ -3950,12 +3950,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)) {

monitor.c static void monitor_find_completion_by_table(Monitor *mon, · line 3963

Quoted 10 lines
monitor.c +5 -1
+                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))) {

(so if there is a helper we can also use it here)

Quoted 7 lines
monitor.c +0 -0
                 break;
             }
         }
Signature · 1 line
2.17.0
Signature · 1 line
Peter Xu
#9 lore raw

PATCH 4/6 hmp: Add info commands for preconfig

In reply to Dr. David Alan Gilbert (git)

From: "Dr. David Alan Gilbert" <[email protected]>

Allow a bunch of the info commands to be used in preconfig. Could probably add most of them.

---
 hmp-commands-info.hx | 9 +++++++++
 hmp-commands.hx      | 1 +
 2 files changed, 10 insertions(+)
hmp-commands-info.hx +9 -0
index ddfcd5adcc..00735e7d1c 100644
@@ -19,6 +19,7 @@ ETEXI
         .params     = "",
         .help       = "show the version of QEMU",
         .cmd        = hmp_info_version,
+        .flags      = "p",
     },
 
 STEXI
@@ -33,6 +34,7 @@ ETEXI
         .params     = "",
         .help       = "show the network state",
         .cmd        = hmp_info_network,
+        .flags      = "p",
     },
 
 STEXI
@@ -47,6 +49,7 @@ ETEXI
         .params     = "",
         .help       = "show the character devices",
         .cmd        = hmp_info_chardev,
+        .flags      = "p",
     },
 
 STEXI
@@ -62,6 +65,7 @@ ETEXI
         .help       = "show info of one block device or all block devices "
                       "(-n: show named nodes; -v: show details)",
         .cmd        = hmp_info_block,
+        .flags      = "p",
     },
 
 STEXI
@@ -151,6 +155,7 @@ ETEXI
         .params     = "",
         .help       = "show infos for each CPU",
         .cmd        = hmp_info_cpus,
+        .flags      = "p",
     },
 
 STEXI
@@ -165,6 +170,7 @@ ETEXI
         .params     = "",
         .help       = "show the command line history",
         .cmd        = hmp_info_history,
+        .flags      = "p",
     },
 
 STEXI
@@ -255,6 +261,7 @@ ETEXI
         .help       = "show memory tree (-f: dump flat view for address spaces;"
                       "-d: dump dispatch tree, valid with -f only)",
         .cmd        = hmp_info_mtree,
+        .flags      = "p",
     },
 
 STEXI
@@ -399,6 +406,7 @@ ETEXI
         .params     = "",
         .help       = "show the current VM status (running|paused)",
         .cmd        = hmp_info_status,
+        .flags      = "p",
     },
 
 STEXI
@@ -829,6 +837,7 @@ ETEXI
         .params     = "",
         .help       = "Show information about hotpluggable CPUs",
         .cmd        = hmp_hotpluggable_cpus,
+        .flags      = "p",
     },
 
 STEXI
hmp-commands.hx +1 -0
index 8bf590ae4b..dc82ed526f 100644
@@ -1856,6 +1856,7 @@ ETEXI
         .help       = "show various information about the system state",
         .cmd        = hmp_info_help,
         .sub_table  = info_cmds,
+        .flags      = "p",
     },
 
 STEXI
Signature · 1 line
2.17.0
Reviewed-by on v1 4/6
#10 lore raw

Re: [Qemu-devel] [PATCH 4/6] hmp: Add info commands for preconfig

Quoted 4 lines · Dr. David Alan Gilbert (git)

From: "Dr. David Alan Gilbert" <[email protected]>

Allow a bunch of the info commands to be used in preconfig. Could probably add most of them.

I guess some of them may not work yet during preconfig. E.g.:

$ ./x86_64-softmmu/qemu-system-x86_64 -preconfig -monitor stdio
QEMU 2.12.50 monitor - type 'help' for more information
(qemu) info mtree
address-space: memory
  0000000000000000-ffffffffffffffff (prio 0, i/o): system

address-space: I/O
0000000000000000-000000000000ffff (prio 0, i/o): io

But it's fine to enable that I guess.

(Which "info" command would you want to use during preconfig?)

Quoted 2 lines
Signature · 1 line
Peter Xu
#11 lore raw

Re: [Qemu-devel] [PATCH 4/6] hmp: Add info commands for preconfig

Quoted 17 lines · Peter Xu
Quoted 4 lines · Dr. David Alan Gilbert (git)

From: "Dr. David Alan Gilbert" <[email protected]>

Allow a bunch of the info commands to be used in preconfig. Could probably add most of them.

I guess some of them may not work yet during preconfig. E.g.:

$ ./x86_64-softmmu/qemu-system-x86_64 -preconfig -monitor stdio
QEMU 2.12.50 monitor - type 'help' for more information
(qemu) info mtree
address-space: memory
  0000000000000000-ffffffffffffffff (prio 0, i/o): system

address-space: I/O
0000000000000000-000000000000ffff (prio 0, i/o): io

Quoted 8 lines

But it's fine to enable that I guess.

(Which "info" command would you want to use during preconfig?)

Quoted 2 lines

The reason for having -preconfig is us despairing of making -S do the right thing. We'd have to *understand* the tangled mess that is our startup, and rearrange it so QMP becomes available early enough for configuring NUMA (and other things), yet late enough for everything to work.

-preconfig is a cheap hack to avoid this headache, by bypassing almost all of "everything".

Now you bring back some of "everything". Dangerous. You better show it actually works. Until you do:

NAK

#12 lore raw

Re: [Qemu-devel] [PATCH 4/6] hmp: Add info commands for preconfig

Quoted 34 lines · * Markus Armbruster ([email protected]) wrote:
Quoted 17 lines · Peter Xu
Quoted 4 lines · Dr. David Alan Gilbert (git)

From: "Dr. David Alan Gilbert" <[email protected]>

Allow a bunch of the info commands to be used in preconfig. Could probably add most of them.

I guess some of them may not work yet during preconfig. E.g.:

$ ./x86_64-softmmu/qemu-system-x86_64 -preconfig -monitor stdio
QEMU 2.12.50 monitor - type 'help' for more information
(qemu) info mtree
address-space: memory
  0000000000000000-ffffffffffffffff (prio 0, i/o): system

address-space: I/O
0000000000000000-000000000000ffff (prio 0, i/o): io

Quoted 8 lines

But it's fine to enable that I guess.

(Which "info" command would you want to use during preconfig?)

Quoted 2 lines

The reason for having -preconfig is us despairing of making -S do the right thing. We'd have to *understand* the tangled mess that is our startup, and rearrange it so QMP becomes available early enough for configuring NUMA (and other things), yet late enough for everything to work.

Quoted 7 lines

-preconfig is a cheap hack to avoid this headache, by bypassing almost all of "everything".

Now you bring back some of "everything". Dangerous. You better show it actually works. Until you do:

NAK

Well I did test each command in here to make sure it didn't crash/produce complete junk; but here's the output with the v2 of this patch that Igor R-b:

[dgilbert@dgilbert-t530 try]$ ./x86_64-softmmu/qemu-system-x86_64 -nographic -preconfig

(qemu)
(qemu)
(qemu) help info
info chardev -- show the character devices
info history -- show the command line history
info hotpluggable-cpus -- Show information about hotpluggable CPUs info iothreads -- show iothreads
info memdev -- show memory backends
info name -- show the current VM name
info numa -- show NUMA information
info qom-tree [path] -- show QOM composition tree
info status -- show the current VM status (running|paused) info usbhost -- show host USB devices
info uuid -- show the current VM UUID
info version -- show the version of QEMU
(qemu) info chardev
serial0: filename=mux
serial0-base: filename=stdio
parallel0: filename=null
(qemu) info history
0: 'help info'
1: 'info chardev'
2: 'info history'
(qemu) info hotpluggable-cpus
Hotpluggable CPUs:
type: "qemu64-x86_64-cpu"
vcpus_count: "1"
CPUInstance Properties:

    socket-id: "0"
    core-id: "0"
    thread-id: "0"

(qemu) info iothreads
(qemu) info memdev

(qemu) info name
(qemu) info numa
0 nodes
(qemu) info qom-tree
/machine (pc-i440fx-3.0-machine)
/peripheral (container)
/peripheral-anon (container)
/unattached (container)

    /system[0] (qemu:memory-region)
    /io[0] (qemu:memory-region)

(qemu) info status
VM status: paused (preconfig)
(qemu) info usbhost
Bus 2, Addr 3, Port 1.5, Speed 1.5 Mb/s

    Class 00: USB device 093a:2510
  Bus 1, Addr 3, Port 1.6, Speed 480 Mb/s
    Class ef: USB device 5986:02d2
  Bus 3, Addr 2, Port 1, Speed 1.5 Mb/s
    Class 00: USB device 0d3d:0001

(qemu) info uuid
00000000-0000-0000-0000-000000000000
(qemu) info version
2.12.50v2.12.0-1074-gfbb4dcae3a
(qemu)

Dave

--
Dr. David Alan Gilbert / [email protected] / Manchester, UK

#13 lore raw

Re: [Qemu-devel] [PATCH 4/6] hmp: Add info commands for preconfig

Quoted 38 lines · Dr. David Alan Gilbert
Quoted 37 lines · * Markus Armbruster ([email protected]) wrote:
Quoted 17 lines · Peter Xu
Quoted 4 lines · Dr. David Alan Gilbert (git)

From: "Dr. David Alan Gilbert" <[email protected]>

Allow a bunch of the info commands to be used in preconfig. Could probably add most of them.

I guess some of them may not work yet during preconfig. E.g.:

$ ./x86_64-softmmu/qemu-system-x86_64 -preconfig -monitor stdio
QEMU 2.12.50 monitor - type 'help' for more information
(qemu) info mtree
address-space: memory
  0000000000000000-ffffffffffffffff (prio 0, i/o): system

address-space: I/O
0000000000000000-000000000000ffff (prio 0, i/o): io

Quoted 8 lines

But it's fine to enable that I guess.

(Which "info" command would you want to use during preconfig?)

Quoted 2 lines

The reason for having -preconfig is us despairing of making -S do the right thing. We'd have to *understand* the tangled mess that is our startup, and rearrange it so QMP becomes available early enough for configuring NUMA (and other things), yet late enough for everything to work.

-preconfig is a cheap hack to avoid this headache, by bypassing almost all of "everything".

Quoted 8 lines
Quoted 4 lines

Now you bring back some of "everything". Dangerous. You better show it actually works. Until you do:

NAK

Well I did test each command in here to make sure it didn't crash/produce complete junk; but here's the output with the v2 of this patch that Igor R-b:

[...]

For the sake of the argument, let's assume these commands all work in preconfig state. Are their QMP equivalents all available in preconfig state?

#14 lore raw

Re: [Qemu-devel] [PATCH 4/6] hmp: Add info commands for preconfig

Quoted 45 lines · * Markus Armbruster ([email protected]) wrote:
Quoted 43 lines · Dr. David Alan Gilbert
Quoted 41 lines · * Markus Armbruster ([email protected]) wrote:
Quoted 17 lines · Peter Xu
Quoted 4 lines · Dr. David Alan Gilbert (git)

From: "Dr. David Alan Gilbert" <[email protected]>

Allow a bunch of the info commands to be used in preconfig. Could probably add most of them.

I guess some of them may not work yet during preconfig. E.g.:

$ ./x86_64-softmmu/qemu-system-x86_64 -preconfig -monitor stdio
QEMU 2.12.50 monitor - type 'help' for more information
(qemu) info mtree
address-space: memory
  0000000000000000-ffffffffffffffff (prio 0, i/o): system

address-space: I/O
0000000000000000-000000000000ffff (prio 0, i/o): io

Quoted 8 lines

But it's fine to enable that I guess.

(Which "info" command would you want to use during preconfig?)

Quoted 2 lines

The reason for having -preconfig is us despairing of making -S do the right thing. We'd have to *understand* the tangled mess that is our startup, and rearrange it so QMP becomes available early enough for configuring NUMA (and other things), yet late enough for everything to work.

-preconfig is a cheap hack to avoid this headache, by bypassing almost all of "everything".

Now you bring back some of "everything". Dangerous. You better show it actually works. Until you do:

NAK

Quoted 8 lines
Quoted 3 lines

Well I did test each command in here to make sure it didn't crash/produce complete junk; but here's the output with the v2 of this patch that Igor R-b:

[...]

For the sake of the argument, let's assume these commands all work in preconfig state. Are their QMP equivalents all available in preconfig state?

That I don't know; I was happy to fix my list to the ones Igor recommended. If you object to some particular entries I'll be happy to change them.

Dave

--
Dr. David Alan Gilbert / [email protected] / Manchester, UK

#15 lore raw

Re: [Qemu-devel] [PATCH 4/6] hmp: Add info commands for preconfig

Quoted 51 lines · Dr. David Alan Gilbert
Quoted 50 lines · * Markus Armbruster ([email protected]) wrote:
Quoted 46 lines · Dr. David Alan Gilbert
Quoted 34 lines · * Markus Armbruster ([email protected]) wrote:
Quoted 17 lines · Peter Xu
Quoted 4 lines · Dr. David Alan Gilbert (git)

From: "Dr. David Alan Gilbert" <[email protected]>

Allow a bunch of the info commands to be used in preconfig. Could probably add most of them.

I guess some of them may not work yet during preconfig. E.g.:

$ ./x86_64-softmmu/qemu-system-x86_64 -preconfig -monitor stdio
QEMU 2.12.50 monitor - type 'help' for more information
(qemu) info mtree
address-space: memory
  0000000000000000-ffffffffffffffff (prio 0, i/o): system

address-space: I/O
0000000000000000-000000000000ffff (prio 0, i/o): io

Quoted 8 lines

But it's fine to enable that I guess.

(Which "info" command would you want to use during preconfig?)

Quoted 2 lines

The reason for having -preconfig is us despairing of making -S do the right thing. We'd have to *understand* the tangled mess that is our startup, and rearrange it so QMP becomes available early enough for configuring NUMA (and other things), yet late enough for everything to work.

Quoted 7 lines

-preconfig is a cheap hack to avoid this headache, by bypassing almost all of "everything".

Now you bring back some of "everything". Dangerous. You better show it actually works. Until you do:

NAK

Well I did test each command in here to make sure it didn't crash/produce complete junk; but here's the output with the v2 of this patch that Igor R-b:

[...]

Quoted 7 lines
Quoted 3 lines

For the sake of the argument, let's assume these commands all work in preconfig state. Are their QMP equivalents all available in preconfig state?

That I don't know; I was happy to fix my list to the ones Igor recommended. If you object to some particular entries I'll be happy to change them.

HMP must not provide more functionality than QMP. Specifically, we may provide "info FOO" only when we also provide query-FOO.

There are exceptions to this rule. I don't think they apply here. I'm prepared to discuss them, of course.

I wish there was a way to automate "provide command in HMP when its buddy is available in QMP", but since the buddies are only connected by code, that seems infeasible.

Without such automation, the two sets of available commands need to be kept consistent manually. The larger they are, the more of a bother.

Bother is fine when it provides commensurate value to users. Options in increasing order of value provided:

(1) HMP becomes ready only after we exit preconfig state (what I

    proposed in Message-ID: <[email protected]>.

(2) HMP provides help, quit, exit-preconfig.

(3) HMP provides (a subset of) the commands QMP provides.

I figure the maintenance cost of (1) and (2) will be negligible, but (3) could be a drag. Are you sure it's worthwhile?

#16 lore raw

Re: [Qemu-devel] [PATCH 4/6] hmp: Add info commands for preconfig

Quoted 61 lines · * Markus Armbruster ([email protected]) wrote:
Quoted 51 lines · Dr. David Alan Gilbert
Quoted 50 lines · * Markus Armbruster ([email protected]) wrote:
Quoted 46 lines · Dr. David Alan Gilbert
Quoted 34 lines · * Markus Armbruster ([email protected]) wrote:
Quoted 17 lines · Peter Xu
Quoted 4 lines · Dr. David Alan Gilbert (git)

From: "Dr. David Alan Gilbert" <[email protected]>

Allow a bunch of the info commands to be used in preconfig. Could probably add most of them.

I guess some of them may not work yet during preconfig. E.g.:

$ ./x86_64-softmmu/qemu-system-x86_64 -preconfig -monitor stdio
QEMU 2.12.50 monitor - type 'help' for more information
(qemu) info mtree
address-space: memory
  0000000000000000-ffffffffffffffff (prio 0, i/o): system

address-space: I/O
0000000000000000-000000000000ffff (prio 0, i/o): io

Quoted 8 lines

But it's fine to enable that I guess.

(Which "info" command would you want to use during preconfig?)

Quoted 2 lines

The reason for having -preconfig is us despairing of making -S do the right thing. We'd have to *understand* the tangled mess that is our startup, and rearrange it so QMP becomes available early enough for configuring NUMA (and other things), yet late enough for everything to work.

Quoted 7 lines

-preconfig is a cheap hack to avoid this headache, by bypassing almost all of "everything".

Now you bring back some of "everything". Dangerous. You better show it actually works. Until you do:

NAK

Well I did test each command in here to make sure it didn't crash/produce complete junk; but here's the output with the v2 of this patch that Igor R-b:

[...]

Quoted 7 lines
Quoted 3 lines

For the sake of the argument, let's assume these commands all work in preconfig state. Are their QMP equivalents all available in preconfig state?

That I don't know; I was happy to fix my list to the ones Igor recommended. If you object to some particular entries I'll be happy to change them.

Quoted 5 lines

HMP must not provide more functionality than QMP. Specifically, we may provide "info FOO" only when we also provide query-FOO.

There are exceptions to this rule. I don't think they apply here. I'm prepared to discuss them, of course.

No, that's strictly not true; HMP can provide anything that helps a human debug stuff. The requirement is that if a tool needs it then it must be provided in QMP.

Quoted 11 lines

I wish there was a way to automate "provide command in HMP when its buddy is available in QMP", but since the buddies are only connected by code, that seems infeasible.

Without such automation, the two sets of available commands need to be kept consistent manually. The larger they are, the more of a bother.

Bother is fine when it provides commensurate value to users. Options in increasing order of value provided:

(1) HMP becomes ready only after we exit preconfig state (what I

Quoted 8 lines
    proposed in Message-ID: <[email protected]>.

(2) HMP provides help, quit, exit-preconfig.

(3) HMP provides (a subset of) the commands QMP provides.

I figure the maintenance cost of (1) and (2) will be negligible, but (3) could be a drag. Are you sure it's worthwhile?

I'm not prepared to restrict to (2), and I'm not prepared to restrict HMP to a subset of QMP; As I said previously, if there's a command that you think is incorrect/broken that I've enabled then I'm happy to remove it.

Dave

--
Dr. David Alan Gilbert / [email protected] / Manchester, UK

#17 lore raw

Re: [Qemu-devel] [PATCH 4/6] hmp: Add info commands for preconfig

Quoted 89 lines · On Fri, 8 Jun 2018 09:18:46 +0100 "Dr. David Alan Gilbert"…
Quoted 61 lines · * Markus Armbruster ([email protected]) wrote:
Quoted 51 lines · Dr. David Alan Gilbert
Quoted 50 lines · * Markus Armbruster ([email protected]) wrote:
Quoted 46 lines · Dr. David Alan Gilbert
Quoted 34 lines · * Markus Armbruster ([email protected]) wrote:
Quoted 17 lines · Peter Xu
Quoted 4 lines · Dr. David Alan Gilbert (git)

From: "Dr. David Alan Gilbert" <[email protected]>

Allow a bunch of the info commands to be used in preconfig. Could probably add most of them.

I guess some of them may not work yet during preconfig. E.g.:

$ ./x86_64-softmmu/qemu-system-x86_64 -preconfig -monitor stdio
QEMU 2.12.50 monitor - type 'help' for more information
(qemu) info mtree
address-space: memory
  0000000000000000-ffffffffffffffff (prio 0, i/o): system

address-space: I/O
0000000000000000-000000000000ffff (prio 0, i/o): io

Quoted 8 lines

But it's fine to enable that I guess.

(Which "info" command would you want to use during preconfig?)

Quoted 2 lines

The reason for having -preconfig is us despairing of making -S do the right thing. We'd have to *understand* the tangled mess that is our startup, and rearrange it so QMP becomes available early enough for configuring NUMA (and other things), yet late enough for everything to work.

Quoted 7 lines

-preconfig is a cheap hack to avoid this headache, by bypassing almost all of "everything".

Now you bring back some of "everything". Dangerous. You better show it actually works. Until you do:

NAK

Well I did test each command in here to make sure it didn't crash/produce complete junk; but here's the output with the v2 of this patch that Igor R-b:

[...]

Quoted 7 lines
Quoted 3 lines

For the sake of the argument, let's assume these commands all work in preconfig state. Are their QMP equivalents all available in preconfig state?

That I don't know; I was happy to fix my list to the ones Igor recommended. If you object to some particular entries I'll be happy to change them.

Quoted 5 lines

HMP must not provide more functionality than QMP. Specifically, we may provide "info FOO" only when we also provide query-FOO.

There are exceptions to this rule. I don't think they apply here. I'm prepared to discuss them, of course.

No, that's strictly not true; HMP can provide anything that helps a human debug stuff. The requirement is that if a tool needs it then it must be provided in QMP.

Quoted 17 lines

I wish there was a way to automate "provide command in HMP when its buddy is available in QMP", but since the buddies are only connected by code, that seems infeasible.

Without such automation, the two sets of available commands need to be kept consistent manually. The larger they are, the more of a bother.

Bother is fine when it provides commensurate value to users. Options in increasing order of value provided:

(1) HMP becomes ready only after we exit preconfig state (what I

    proposed in Message-ID: <[email protected]>.

(2) HMP provides help, quit, exit-preconfig.

(3) HMP provides (a subset of) the commands QMP provides.

Quoted 8 lines
Quoted 2 lines

I figure the maintenance cost of (1) and (2) will be negligible, but (3) could be a drag. Are you sure it's worthwhile?

I'm not prepared to restrict to (2), and I'm not prepared to restrict HMP to a subset of QMP; As I said previously, if there's a command that you think is incorrect/broken that I've enabled then I'm happy to remove it.

I'd prefer #3 if we going to expose HMP at all or #1.

#3 would allow testing via HMP for those who can't use qmp-shell. we can trim HMP list to allowed-preconfig commands or audit respective QMP variants (they should work without changes) and flag them with allowed-preconfig.

Quoted 6 lines

Dave

--
Dr. David Alan Gilbert / [email protected] / Manchester, UK

#18 lore raw

Re: [Qemu-devel] [PATCH 4/6] hmp: Add info commands for preconfig

In reply to Dr. David Alan Gilbert
Quoted 62 lines · Dr. David Alan Gilbert
Quoted 61 lines · * Markus Armbruster ([email protected]) wrote:
Quoted 58 lines · Dr. David Alan Gilbert
Quoted 45 lines · * Markus Armbruster ([email protected]) wrote:
Quoted 43 lines · Dr. David Alan Gilbert
Quoted 41 lines · * Markus Armbruster ([email protected]) wrote:
Quoted 17 lines · Peter Xu
Quoted 4 lines · Dr. David Alan Gilbert (git)

From: "Dr. David Alan Gilbert" <[email protected]>

Allow a bunch of the info commands to be used in preconfig. Could probably add most of them.

I guess some of them may not work yet during preconfig. E.g.:

$ ./x86_64-softmmu/qemu-system-x86_64 -preconfig -monitor stdio
QEMU 2.12.50 monitor - type 'help' for more information
(qemu) info mtree
address-space: memory
  0000000000000000-ffffffffffffffff (prio 0, i/o): system

address-space: I/O
0000000000000000-000000000000ffff (prio 0, i/o): io

Quoted 8 lines

But it's fine to enable that I guess.

(Which "info" command would you want to use during preconfig?)

Quoted 2 lines

The reason for having -preconfig is us despairing of making -S do the right thing. We'd have to *understand* the tangled mess that is our startup, and rearrange it so QMP becomes available early enough for configuring NUMA (and other things), yet late enough for everything to work.

-preconfig is a cheap hack to avoid this headache, by bypassing almost all of "everything".

Now you bring back some of "everything". Dangerous. You better show it actually works. Until you do:

NAK

Quoted 8 lines
Quoted 3 lines

Well I did test each command in here to make sure it didn't crash/produce complete junk; but here's the output with the v2 of this patch that Igor R-b:

[...]

For the sake of the argument, let's assume these commands all work in preconfig state. Are their QMP equivalents all available in preconfig state?

That I don't know; I was happy to fix my list to the ones Igor recommended. If you object to some particular entries I'll be happy to change them.

Quoted 8 lines
Quoted 5 lines

HMP must not provide more functionality than QMP. Specifically, we may provide "info FOO" only when we also provide query-FOO.

There are exceptions to this rule. I don't think they apply here. I'm prepared to discuss them, of course.

No, that's strictly not true; HMP can provide anything that helps a human debug stuff.

Yes, but...

Quoted 2 lines

The requirement is that if a tool needs it then it
must be provided in QMP.

... it must not do that at the expense of QMP's completeness. Permitting that would be a break from how we worked since QMP became supported in 0.14 or so. Seven years, time flies.

The hard requirement for QMP from day one was "provide everything machine clients need". To avoid speculation and endless arguments about what might be needed / not needed, we resolved to approximate this by "provide everything, except stuff that's *clearly* of no use to machines". This has been spelled out on this list several times. Here are two relatively recent iterations:

Message-ID: <[email protected]>
https://lists.gnu.org/archive/html/qemu-devel/2017-04/msg05309.html

Message-ID: <[email protected]>
https://lists.gnu.org/archive/html/qemu-devel/2017-05/msg00247.html

Quoting the latter:

In general, functionality available in HMP should also available in QMP. Exceptions include functionality that makes no sense in QMP, or is of use only for human users. If you think your command is an exception, please explain why in the commit message.

If it isn't, you need to implement it for QMP (including suitable test cases), then rewrite the HMP version to reuse either the QMP command or a common core.

Example for "makes no sense in QMP": setting the current CPU[1], because a QMP monitor doesn't have a current CPU.

Examples for "is of use only for human users": HMP command "help", the integrated pocket calculator[2].

End quote.

But we're not even arguing about a new HMP command, we're arguing about making existing commands available in preconfig state. I assume that if an HMP command is useful in preconfig state, then its QMP buddy is also useful there. I therefore asked you whether their QMP equivalents are all available in preconfig state. The answer I expected was a short table of three columns: HMP command you propose to enable, QMP buddy if any, whether the QMP buddy is available in preconfig state yes/no. Estimated effort: minutes. What I got instead of this data was an argument about fundamental design decisions. Fine, reexaminating fundamentals once in a while isn't a bad idea. But may I have my data now?

[...]

#19 lore raw

Re: [Qemu-devel] [PATCH 4/6] hmp: Add info commands for preconfig

Quoted 114 lines · * Markus Armbruster ([email protected]) wrote:
Quoted 62 lines · Dr. David Alan Gilbert
Quoted 61 lines · * Markus Armbruster ([email protected]) wrote:
Quoted 58 lines · Dr. David Alan Gilbert
Quoted 45 lines · * Markus Armbruster ([email protected]) wrote:
Quoted 43 lines · Dr. David Alan Gilbert
Quoted 41 lines · * Markus Armbruster ([email protected]) wrote:
Quoted 17 lines · Peter Xu
Quoted 4 lines · Dr. David Alan Gilbert (git)

From: "Dr. David Alan Gilbert" <[email protected]>

Allow a bunch of the info commands to be used in preconfig. Could probably add most of them.

I guess some of them may not work yet during preconfig. E.g.:

$ ./x86_64-softmmu/qemu-system-x86_64 -preconfig -monitor stdio
QEMU 2.12.50 monitor - type 'help' for more information
(qemu) info mtree
address-space: memory
  0000000000000000-ffffffffffffffff (prio 0, i/o): system

address-space: I/O
0000000000000000-000000000000ffff (prio 0, i/o): io

Quoted 8 lines

But it's fine to enable that I guess.

(Which "info" command would you want to use during preconfig?)

Quoted 2 lines

The reason for having -preconfig is us despairing of making -S do the right thing. We'd have to *understand* the tangled mess that is our startup, and rearrange it so QMP becomes available early enough for configuring NUMA (and other things), yet late enough for everything to work.

-preconfig is a cheap hack to avoid this headache, by bypassing almost all of "everything".

Now you bring back some of "everything". Dangerous. You better show it actually works. Until you do:

NAK

Quoted 8 lines
Quoted 3 lines

Well I did test each command in here to make sure it didn't crash/produce complete junk; but here's the output with the v2 of this patch that Igor R-b:

[...]

For the sake of the argument, let's assume these commands all work in preconfig state. Are their QMP equivalents all available in preconfig state?

That I don't know; I was happy to fix my list to the ones Igor recommended. If you object to some particular entries I'll be happy to change them.

Quoted 8 lines
Quoted 5 lines

HMP must not provide more functionality than QMP. Specifically, we may provide "info FOO" only when we also provide query-FOO.

There are exceptions to this rule. I don't think they apply here. I'm prepared to discuss them, of course.

No, that's strictly not true; HMP can provide anything that helps a human debug stuff.

Yes, but...

Quoted 2 lines

The requirement is that if a tool needs it then it
must be provided in QMP.

... it must not do that at the expense of QMP's completeness. Permitting that would be a break from how we worked since QMP became supported in 0.14 or so. Seven years, time flies.

The hard requirement for QMP from day one was "provide everything machine clients need". To avoid speculation and endless arguments about what might be needed / not needed, we resolved to approximate this by "provide everything, except stuff that's *clearly* of no use to machines". This has been spelled out on this list several times. Here are two relatively recent iterations:

Message-ID: <[email protected]>
https://lists.gnu.org/archive/html/qemu-devel/2017-04/msg05309.html

Message-ID: <[email protected]>
https://lists.gnu.org/archive/html/qemu-devel/2017-05/msg00247.html

Quoting the latter:

In general, functionality available in HMP should also available in QMP. Exceptions include functionality that makes no sense in QMP, or is of use only for human users. If you think your command is an exception, please explain why in the commit message.

If it isn't, you need to implement it for QMP (including suitable test cases), then rewrite the HMP version to reuse either the QMP command or a common core.

Example for "makes no sense in QMP": setting the current CPU[1], because a QMP monitor doesn't have a current CPU.

Examples for "is of use only for human users": HMP command "help", the integrated pocket calculator[2].

End quote.

Quoted 11 lines

But we're not even arguing about a new HMP command, we're arguing about making existing commands available in preconfig state. I assume that if an HMP command is useful in preconfig state, then its QMP buddy is also useful there. I therefore asked you whether their QMP equivalents are all available in preconfig state. The answer I expected was a short table of three columns: HMP command you propose to enable, QMP buddy if any, whether the QMP buddy is available in preconfig state yes/no. Estimated effort: minutes. What I got instead of this data was an argument about fundamental design decisions. Fine, reexaminating fundamentals once in a while isn't a bad idea. But may I have my data now?

I believe that table is in the v3 version patch 5.

Dave

Quoted 1 line

[...]

--
Dr. David Alan Gilbert / [email protected] / Manchester, UK

#20 lore raw

Re: [Qemu-devel] [PATCH 4/6] hmp: Add info commands for preconfig

In reply to Markus Armbruster
Quoted 26 lines · On Thu, 07 Jun 2018 14:22:34 +0200 Markus Armbruster <[email protected]> wrote:
Quoted 24 lines · Peter Xu
Quoted 4 lines · Dr. David Alan Gilbert (git)

From: "Dr. David Alan Gilbert" <[email protected]>

Allow a bunch of the info commands to be used in preconfig. Could probably add most of them.

I guess some of them may not work yet during preconfig. E.g.:

$ ./x86_64-softmmu/qemu-system-x86_64 -preconfig -monitor stdio
QEMU 2.12.50 monitor - type 'help' for more information
(qemu) info mtree
address-space: memory
  0000000000000000-ffffffffffffffff (prio 0, i/o): system

address-space: I/O
0000000000000000-000000000000ffff (prio 0, i/o): io

But it's fine to enable that I guess.

(Which "info" command would you want to use during preconfig?)

Quoted 2 lines
Quoted 7 lines
Quoted 1 line

The reason for having -preconfig is us despairing of making -S do the right thing. We'd have to *understand* the tangled mess that is our startup, and rearrange it so QMP becomes available early enough for configuring NUMA (and other things), yet late enough for everything to work.

We solve concrete NUMA problem at -S time as was demonstrated by thread:
"RFC v2 0/4] enable numa configuration before machine is running from HMP/QMP" were pros and cons are were summarized. But that won't scale to other things.

Quoted 2 lines

-preconfig is a cheap hack to avoid this headache, by bypassing almost all of "everything".

hack should allow to move configuration steps to early stage one by one until the point we could obsolete -S (from configuration point) without breaking current -S users and clean up start up mess in process.

Quoted 2 lines

Now you bring back some of "everything". Dangerous. You better show it actually works. Until you do:

Tested v2, works as expected so far.

Quoted 3 lines

NAK

#21 lore raw

Re: [Qemu-devel] [PATCH 4/6] hmp: Add info commands for preconfig

Quoted 40 lines · Igor Mammedov
Quoted 26 lines · On Thu, 07 Jun 2018 14:22:34 +0200 Markus Armbruster <[email protected]> wrote:
Quoted 24 lines · Peter Xu
Quoted 4 lines · Dr. David Alan Gilbert (git)

From: "Dr. David Alan Gilbert" <[email protected]>

Allow a bunch of the info commands to be used in preconfig. Could probably add most of them.

I guess some of them may not work yet during preconfig. E.g.:

$ ./x86_64-softmmu/qemu-system-x86_64 -preconfig -monitor stdio
QEMU 2.12.50 monitor - type 'help' for more information
(qemu) info mtree
address-space: memory
  0000000000000000-ffffffffffffffff (prio 0, i/o): system

address-space: I/O
0000000000000000-000000000000ffff (prio 0, i/o): io

But it's fine to enable that I guess.

(Which "info" command would you want to use during preconfig?)

Quoted 2 lines
Quoted 7 lines
Quoted 1 line

The reason for having -preconfig is us despairing of making -S do the right thing. We'd have to *understand* the tangled mess that is our startup, and rearrange it so QMP becomes available early enough for configuring NUMA (and other things), yet late enough for everything to work.

We solve concrete NUMA problem at -S time as was demonstrated by thread:
"RFC v2 0/4] enable numa configuration before machine is running from HMP/QMP" were pros and cons are were summarized. But that won't scale to other things.

Quoted 5 lines
Quoted 2 lines

-preconfig is a cheap hack to avoid this headache, by bypassing almost all of "everything".

hack should allow to move configuration steps to early stage one by one until the point we could obsolete -S (from configuration point) without breaking current -S users and clean up start up mess in process.

Sometimes a hack is the only practical way forward.

Quoted 3 lines
Quoted 2 lines

Now you bring back some of "everything". Dangerous. You better show it actually works. Until you do:

Tested v2, works as expected so far.

See my reply to Dave.

Quoted 3 lines
Quoted 3 lines

NAK

#22 lore raw

Re: [Qemu-devel] [PATCH 4/6] hmp: Add info commands for preconfig

In reply to Dr. David Alan Gilbert (git)
Quoted 24 lines · On Tue, 5 Jun 2018 13:26:34 +0100 "Dr. David Alan Gilbert (git)"…

From: "Dr. David Alan Gilbert" <[email protected]>

Allow a bunch of the info commands to be used in preconfig. Could probably add most of them.

---
 hmp-commands-info.hx | 9 +++++++++
 hmp-commands.hx      | 1 +
 2 files changed, 10 insertions(+)
hmp-commands-info.hx +1 -0
index ddfcd5adcc..00735e7d1c 100644
@@ -19,6 +19,7 @@ ETEXI
         .params     = "",
         .help       = "show the version of QEMU",
         .cmd        = hmp_info_version,
+        .flags      = "p",
     },
 
 STEXI

hmp-commands-info.hx ETEXI · line 37

Quoted 4 lines
hmp-commands-info.hx +1 -0
@@ -33,6 +34,7 @@ ETEXI
         .params     = "",
         .help       = "show the network state",
         .cmd        = hmp_info_network,
+        .flags      = "p",

output seems to refer to frontend devices, so we probably should skip this one

Quoted 12 lines
hmp-commands-info.hx +1 -0
     },
 
 STEXI
@@ -47,6 +49,7 @@ ETEXI
         .params     = "",
         .help       = "show the character devices",
         .cmd        = hmp_info_chardev,
+        .flags      = "p",
     },
 
 STEXI

hmp-commands-info.hx ETEXI · line 69

Quoted 5 lines
hmp-commands-info.hx +1 -0
@@ -62,6 +65,7 @@ ETEXI
         .help       = "show info of one block device or all block devices "
                       "(-n: show named nodes; -v: show details)",
         .cmd        = hmp_info_block,
+        .flags      = "p",
     },

Devices (frontends) are processed after preconfig point, so there isn't point in enabling this.
At least until we could instantiate devices at that time.

hmp-commands-info.hx ETEXI · line 159

Quoted 8 lines
hmp-commands-info.hx +1 -0
 STEXI
@@ -151,6 +155,7 @@ ETEXI
         .params     = "",
         .help       = "show infos for each CPU",
         .cmd        = hmp_info_cpus,
+        .flags      = "p",
     },

this command probably shouldn't be enabled, there can't be any CPUs at this point yet.

Quoted 11 lines
hmp-commands-info.hx +1 -0
 STEXI
@@ -165,6 +170,7 @@ ETEXI
         .params     = "",
         .help       = "show the command line history",
         .cmd        = hmp_info_history,
+        .flags      = "p",
     },
 
 STEXI

hmp-commands-info.hx ETEXI · line 265

Quoted 5 lines
hmp-commands-info.hx +1 -0
@@ -255,6 +261,7 @@ ETEXI
         .help       = "show memory tree (-f: dump flat view for address spaces;"
                       "-d: dump dispatch tree, valid with -f only)",
         .cmd        = hmp_info_mtree,
+        .flags      = "p",
     },

probably we should skip this one as well

Quoted 23 lines
hmp-commands-info.hx +2 -0
 STEXI
@@ -399,6 +406,7 @@ ETEXI
         .params     = "",
         .help       = "show the current VM status (running|paused)",
         .cmd        = hmp_info_status,
+        .flags      = "p",
     },
 
 STEXI
@@ -829,6 +837,7 @@ ETEXI
         .params     = "",
         .help       = "Show information about hotpluggable CPUs",
         .cmd        = hmp_hotpluggable_cpus,
+        .flags      = "p",
     },
 
 STEXI
hmp-commands.hx +0 -0
index 8bf590ae4b..dc82ed526f 100644

hmp-commands.hx ETEXI · line 1862

Quoted 7 lines
hmp-commands.hx +1 -0
@@ -1856,6 +1856,7 @@ ETEXI
         .help       = "show various information about the system state",
         .cmd        = hmp_info_help,
         .sub_table  = info_cmds,
+        .flags      = "p",
     },
 
 STEXI

in addition to above we should be able to handle at preconfig time:

info memdev
info name
info numa
info qom-tree
info usbhost
info uuid
info iothreads

#23 lore raw

PATCH 5/6 hmp: add exit_preconfig

In reply to Dr. David Alan Gilbert (git)

From: "Dr. David Alan Gilbert" <[email protected]>

Add the exit_preconfig command to return to normality.

---
 hmp-commands.hx | 15 +++++++++++++++
 hmp.c           |  7 +++++++
 hmp.h           |  1 +
 3 files changed, 23 insertions(+)
hmp-commands.hx +15 -0
index dc82ed526f..40e2f6ca08 100644
@@ -55,6 +55,21 @@ STEXI
 @item q or quit
 @findex quit
 Quit the emulator.
+ETEXI
+
+    {
+        .name       = "exit_preconfig",
+        .args_type  = "",
+        .params     = "",
+        .help       = "exit the preconfig state",
+        .cmd        = hmp_exit_preconfig,
+        .flags      = "p",
+    },
+
+STEXI
+@item exit_preconfig
+@findex exit_preconfig
+Exit the preconfig state
 ETEXI
 
     {
hmp.c +7 -0
index ef93f4878b..c7be6ed394 100644
@@ -1065,6 +1065,13 @@ void hmp_system_powerdown(Monitor *mon, const QDict *qdict)
     qmp_system_powerdown(NULL);
 }
 
+void hmp_exit_preconfig(Monitor *mon, const QDict *qdict)
+{
+    Error *err = NULL;
+    qmp_exit_preconfig(&err);
+    hmp_handle_error(mon, &err);
+}
+
 void hmp_cpu(Monitor *mon, const QDict *qdict)
 {
     int64_t cpu_index;
hmp.h +1 -0
index 20f27439d3..33354f1bdd 100644
@@ -44,6 +44,7 @@ void hmp_quit(Monitor *mon, const QDict *qdict);
 void hmp_stop(Monitor *mon, const QDict *qdict);
 void hmp_system_reset(Monitor *mon, const QDict *qdict);
 void hmp_system_powerdown(Monitor *mon, const QDict *qdict);
+void hmp_exit_preconfig(Monitor *mon, const QDict *qdict);
 void hmp_cpu(Monitor *mon, const QDict *qdict);
 void hmp_memsave(Monitor *mon, const QDict *qdict);
 void hmp_pmemsave(Monitor *mon, const QDict *qdict);
Signature · 1 line
2.17.0
#25 lore raw

PATCH 6/6 hmp: Allow HMP in preconfig state again

In reply to Dr. David Alan Gilbert (git)

From: "Dr. David Alan Gilbert" <[email protected]>

Now we can cope with preconfig in HMP, reenable by reverting commit 71dc578e116599ea73c8a2a4e693134702ec0e83.

---
 monitor.c | 6 ------
 1 file changed, 6 deletions(-)
monitor.c +0 -6
index 9b29787a52..50bcba18db 100644
@@ -3394,12 +3394,6 @@ 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;
Signature · 1 line
2.17.0
Tested-by on the v1 series
#27 lore raw
In reply to Dr. David Alan Gilbert (git)
Quoted 8 lines · Dr. David Alan Gilbert (git)

From: "Dr. David Alan Gilbert" <[email protected]>

Reenable HMP in preconfig mode; it's pretty
easy and anyway I want to do a similar thing for OOB eventually. We'll want to enable more commands in preconfig mode to make it useful at some point.

Dave

Wanna add "quit" into the preconfig-allowed list for HMP as well?

Signature · 1 line
Peter Xu
#28 lore raw
Quoted 11 lines · * Peter Xu ([email protected]) wrote:
Quoted 8 lines · Dr. David Alan Gilbert (git)

From: "Dr. David Alan Gilbert" <[email protected]>

Reenable HMP in preconfig mode; it's pretty
easy and anyway I want to do a similar thing for OOB eventually. We'll want to enable more commands in preconfig mode to make it useful at some point.

Dave

Wanna add "quit" into the preconfig-allowed list for HMP as well?

I tried; quit triggers a disallowed state transition!

Quoted 4 lines
Signature · 1 line
Peter Xu

--
Dr. David Alan Gilbert / [email protected] / Manchester, UK

#29 lore raw
Quoted 9 lines · Dr. David Alan Gilbert
Quoted 8 lines · * Peter Xu ([email protected]) wrote:
Quoted 7 lines · Dr. David Alan Gilbert (git)

From: "Dr. David Alan Gilbert" <[email protected]>

Reenable HMP in preconfig mode; it's pretty
easy and anyway I want to do a similar thing for OOB eventually. We'll want to enable more commands in preconfig mode to make it useful at some point.

Quoted 5 lines
Quoted 3 lines
Quoted 1 line

Dave

Wanna add "quit" into the preconfig-allowed list for HMP as well?

I tried; quit triggers a disallowed state transition!

Would it be understandable if we just avoid calling qmp_quit() when during preconfig? An evil idea is, "exit()". :)

After all we have nothing there!

Signature · 1 line
Peter Xu
#30 lore raw
In reply to Peter Xu
Quoted 11 lines · On Thu, 7 Jun 2018 16:54:44 +0800 Peter Xu <[email protected]> wrote:
Quoted 8 lines · Dr. David Alan Gilbert (git)

From: "Dr. David Alan Gilbert" <[email protected]>

Reenable HMP in preconfig mode; it's pretty
easy and anyway I want to do a similar thing for OOB eventually. We'll want to enable more commands in preconfig mode to make it useful at some point.

Dave

Wanna add "quit" into the preconfig-allowed list for HMP as well?

There is exit-preconfig, but yeah it just forwards us to the next state

But for human users that just want to play with HMP 'quit' might be useful, but only to the extent of trying out things out.

Quoted 2 lines
#31 lore raw
Quoted 11 lines · Igor Mammedov
Quoted 8 lines · On Thu, 7 Jun 2018 16:54:44 +0800 Peter Xu <[email protected]> wrote:
Quoted 7 lines · Dr. David Alan Gilbert (git)

From: "Dr. David Alan Gilbert" <[email protected]>

Reenable HMP in preconfig mode; it's pretty
easy and anyway I want to do a similar thing for OOB eventually. We'll want to enable more commands in preconfig mode to make it useful at some point.

Quoted 7 lines
Quoted 3 lines
Quoted 1 line

Dave

Wanna add "quit" into the preconfig-allowed list for HMP as well?

There is exit-preconfig, but yeah it just forwards us to the next state

But for human users that just want to play with HMP 'quit' might be useful, but only to the extent of trying out things out.

Yes, actually I don't yet see a good reason to actually use HMP during preconfig mode even as a whole. But as Dave mentioned, it's too easy to achieve that so I don't have a reason to object that too.

Regards,

Signature · 1 line
Peter Xu
Reviewed-by on the v1 series
#32 lore raw
In reply to Dr. David Alan Gilbert (git)
Quoted 18 lines · On Tue, 5 Jun 2018 13:26:30 +0100 "Dr. David Alan Gilbert (git)"…

From: "Dr. David Alan Gilbert" <[email protected]>

Reenable HMP in preconfig mode; it's pretty
easy and anyway I want to do a similar thing for OOB eventually. We'll want to enable more commands in preconfig mode to make it useful at some point.

Dave

Dr. David Alan Gilbert (6):
hmp: Add flag for preconfig commands
hmp: Allow help on preconfig commands
hmp: Restrict auto-complete in preconfig
hmp: Add info commands for preconfig
hmp: add exit_preconfig
hmp: Allow HMP in preconfig state again

Quoted 7 lines
 hmp-commands-info.hx |  9 +++++++++
 hmp-commands.hx      | 17 +++++++++++++++++
 hmp.c                |  7 +++++++
 hmp.h                |  1 +
 monitor.c            | 42 +++++++++++++++++++++++++++++++++---------
 5 files changed, 67 insertions(+), 9 deletions(-)

I was trying to find out way to use QMP schema info with HMP without manual commands flagging but this looks so much simpler, so that if it is acceptable I'm all in for this version.

except 4/6 which needs a little bit amended.