Skip to contentSkip to conversation

monitor: print message when using 'help' with an unknown command

PATCH Superseded Collin Walling 4 participants 9 messages Jul 19, 2018 – Jul 20, 2018

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 monitor: print message when using 'help' with an unknown command

When typing 'help' followed by an unknown command, QEMU will not print anything to the command line to let the user know they typed a bad command. Let's fix this by printing a message to the monitor when this happens. For example:

(qemu) help xyz
unknown command: 'xyz'

---
 monitor.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
monitor.c +4 -1
index 7af1f18..7942f9f 100644
@@ -1034,9 +1034,12 @@ static void help_cmd_dump(Monitor *mon, const mon_cmd_t *cmds,
             } else {
                 help_cmd_dump_one(mon, cmd, args, arg_index);
             }
-            break;
+            return;
         }
     }
+
+    /* Entry not found */
+    monitor_printf(mon, "unknown command: '%s'\n", args[arg_index]);
 }
 
 static void help_cmd(Monitor *mon, const char *name)
Signature · 1 line
2.7.4
#1 lore raw

You neglected to cc: maintainers. Cc'ing them increases the odds your patch will be noticed and picked up. You can use scripts/get_maintainer.pl to find maintainers. You don't have to do anything for this patch; it got noticed anyway.

David, this is yours :)

Quoted 32 lines · Collin Walling

When typing 'help' followed by an unknown command, QEMU will not print anything to the command line to let the user know they typed a bad command. Let's fix this by printing a message to the monitor when this happens. For example:

(qemu) help xyz
unknown command: 'xyz'

---
 monitor.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
monitor.c +4 -1
index 7af1f18..7942f9f 100644
@@ -1034,9 +1034,12 @@ static void help_cmd_dump(Monitor *mon, const mon_cmd_t *cmds,
             } else {
                 help_cmd_dump_one(mon, cmd, args, arg_index);
             }
-            break;
+            return;
         }
     }
+
+    /* Entry not found */
+    monitor_printf(mon, "unknown command: '%s'\n", args[arg_index]);
 }
 
 static void help_cmd(Monitor *mon, const char *name)
#2 lore raw
Quoted 6 lines · Markus Armbruster

You neglected to cc: maintainers. Cc'ing them increases the odds your patch will be noticed and picked up. You can use scripts/get_maintainer.pl to find maintainers. You don't have to do anything for this patch; it got noticed anyway.

David, this is yours :)

Very true. Was a minor fix that I thought I'd just toss it out there and let anyone view it if they had the time. Will be more aware of who to CC next time around.

Thanks :)

Quoted 36 lines
Quoted 32 lines · Collin Walling

When typing 'help' followed by an unknown command, QEMU will not print anything to the command line to let the user know they typed a bad command. Let's fix this by printing a message to the monitor when this happens. For example:

(qemu) help xyz
unknown command: 'xyz'

---
 monitor.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
monitor.c +4 -1
index 7af1f18..7942f9f 100644
@@ -1034,9 +1034,12 @@ static void help_cmd_dump(Monitor *mon, const mon_cmd_t *cmds,
             } else {
                 help_cmd_dump_one(mon, cmd, args, arg_index);
             }
-            break;
+            return;
         }
     }
+
+    /* Entry not found */
+    monitor_printf(mon, "unknown command: '%s'\n", args[arg_index]);
 }
 
 static void help_cmd(Monitor *mon, const char *name)
Signature · 2 lines
Respectfully,
- Collin Walling
#5 lore raw
In reply to Markus Armbruster
Quoted 6 lines · * Markus Armbruster ([email protected]) wrote:

You neglected to cc: maintainers. Cc'ing them increases the odds your patch will be noticed and picked up. You can use scripts/get_maintainer.pl to find maintainers. You don't have to do anything for this patch; it got noticed anyway.

David, this is yours :)

Thanks!

Dave

Quoted 33 lines
Quoted 31 lines · Collin Walling

When typing 'help' followed by an unknown command, QEMU will not print anything to the command line to let the user know they typed a bad command. Let's fix this by printing a message to the monitor when this happens. For example:

(qemu) help xyz
unknown command: 'xyz'

---
 monitor.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
monitor.c +4 -1
index 7af1f18..7942f9f 100644
@@ -1034,9 +1034,12 @@ static void help_cmd_dump(Monitor *mon, const mon_cmd_t *cmds,
             } else {
                 help_cmd_dump_one(mon, cmd, args, arg_index);
             }
-            break;
+            return;
         }
     }
+
+    /* Entry not found */
+    monitor_printf(mon, "unknown command: '%s'\n", args[arg_index]);
 }
 
Quoted 1 line

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

Quoted 1 line
monitor.c +0 -0
 static void help_cmd(Monitor *mon, const char *name)

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

#6 lore raw
In reply to Collin Walling
Quoted 19 lines · * Collin Walling ([email protected]) wrote:

When typing 'help' followed by an unknown command, QEMU will not print anything to the command line to let the user know they typed a bad command. Let's fix this by printing a message to the monitor when this happens. For example:

(qemu) help xyz
unknown command: 'xyz'

---
 monitor.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
monitor.c +0 -0
index 7af1f18..7942f9f 100644

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

Quoted 10 lines
monitor.c +4 -1
@@ -1034,9 +1034,12 @@ static void help_cmd_dump(Monitor *mon, const mon_cmd_t *cmds,
             } else {
                 help_cmd_dump_one(mon, cmd, args, arg_index);
             }
-            break;
+            return;
         }
     }
+
+    /* Entry not found */
+    monitor_printf(mon, "unknown command: '%s'\n", args[arg_index]);

Thanks, that does suffer from a similar bug to the one you fixed a few months back in 317c52cc6aa0d ('monitor: report entirety of hmp command on error'):

(qemu) help foo
unknown command: 'foo'
(qemu) help info foo
unknown command: 'foo'

Dave
(And yes, please cc me, otherwise I can miss them)

Quoted 7 lines
monitor.c +0 -0
 }
 
 static void help_cmd(Monitor *mon, const char *name)
Signature · 1 line
2.7.4

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

#7 lore raw
Quoted 35 lines · Dr. David Alan Gilbert
Quoted 19 lines · * Collin Walling ([email protected]) wrote:

When typing 'help' followed by an unknown command, QEMU will not print anything to the command line to let the user know they typed a bad command. Let's fix this by printing a message to the monitor when this happens. For example:

(qemu) help xyz
unknown command: 'xyz'

---
 monitor.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
monitor.c +0 -0
index 7af1f18..7942f9f 100644

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

Quoted 10 lines
monitor.c +4 -1
@@ -1034,9 +1034,12 @@ static void help_cmd_dump(Monitor *mon, const mon_cmd_t *cmds,
             } else {
                 help_cmd_dump_one(mon, cmd, args, arg_index);
             }
-            break;
+            return;
         }
     }
+
+    /* Entry not found */
+    monitor_printf(mon, "unknown command: '%s'\n", args[arg_index]);

Thanks, that does suffer from a similar bug to the one you fixed a few months back in 317c52cc6aa0d ('monitor: report entirety of hmp command on error'):

Quoted 4 lines

(qemu) help foo
unknown command: 'foo'
(qemu) help info foo
unknown command: 'foo'

Yeah... my thinking was that "info" is a correct command, so let's instead only report to the user just the piece that was incorrect.

If it makes better sense to include the whole "info foo" piece, it's certainly doable... whichever makes the most sense. Thoughts?

Quoted 4 lines

Dave
(And yes, please cc me, otherwise I can miss them)

Will do :)

Quoted 10 lines
Quoted 7 lines
monitor.c +0 -0
 }
 
 static void help_cmd(Monitor *mon, const char *name)
Signature · 1 line
2.7.4

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

Signature · 2 lines
Respectfully,
- Collin Walling
#3 lore raw
In reply to Collin Walling
Quoted 11 lines · Collin Walling
Quoted 6 lines · Markus Armbruster

You neglected to cc: maintainers. Cc'ing them increases the odds your patch will be noticed and picked up. You can use scripts/get_maintainer.pl to find maintainers. You don't have to do anything for this patch; it got noticed anyway.

David, this is yours :)

Very true. Was a minor fix that I thought I'd just toss it out there and let anyone view it if they had the time. Will be more aware of who to CC next time around.

Or automate it: https://wiki.qemu.org/Contribute/SubmitAPatch#CC_the_relevant_maintainer suggests:

git config sendemail.cccmd 'scripts/get_maintainer.pl --nogit-fallback'

Signature · 3 lines
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3266
Virtualization:  qemu.org | libvirt.org
#8 lore raw
In reply to Collin Walling
Quoted 41 lines · * Collin Walling ([email protected]) wrote:
Quoted 35 lines · Dr. David Alan Gilbert
Quoted 19 lines · * Collin Walling ([email protected]) wrote:

When typing 'help' followed by an unknown command, QEMU will not print anything to the command line to let the user know they typed a bad command. Let's fix this by printing a message to the monitor when this happens. For example:

(qemu) help xyz
unknown command: 'xyz'

---
 monitor.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
monitor.c +0 -0
index 7af1f18..7942f9f 100644

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

Quoted 10 lines
monitor.c +4 -1
@@ -1034,9 +1034,12 @@ static void help_cmd_dump(Monitor *mon, const mon_cmd_t *cmds,
             } else {
                 help_cmd_dump_one(mon, cmd, args, arg_index);
             }
-            break;
+            return;
         }
     }
+
+    /* Entry not found */
+    monitor_printf(mon, "unknown command: '%s'\n", args[arg_index]);

Thanks, that does suffer from a similar bug to the one you fixed a few months back in 317c52cc6aa0d ('monitor: report entirety of hmp command on error'):

Quoted 4 lines

(qemu) help foo
unknown command: 'foo'
(qemu) help info foo
unknown command: 'foo'

Quoted 5 lines

Yeah... my thinking was that "info" is a correct command, so let's instead only report to the user just the piece that was incorrect.

If it makes better sense to include the whole "info foo" piece, it's certainly doable... whichever makes the most sense. Thoughts?

Yes, I'd prefer the full version; unless it makes it particularly complicated.

Quoted 6 lines
Quoted 4 lines

Dave
(And yes, please cc me, otherwise I can miss them)

Will do :)

Thanks,

Dave

Quoted 16 lines
Quoted 10 lines
Quoted 7 lines
monitor.c +0 -0
 }
 
 static void help_cmd(Monitor *mon, const char *name)
Signature · 1 line
2.7.4

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

Signature · 2 lines
Respectfully,
- Collin Walling

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

#4 lore raw
In reply to Eric Blake
Quoted 9 lines · Eric Blake
Quoted 8 lines · Collin Walling
Quoted 6 lines · Markus Armbruster

You neglected to cc: maintainers.  Cc'ing them increases the odds your patch will be noticed and picked up.  You can use scripts/get_maintainer.pl to find maintainers.  You don't have to do anything for this patch; it got noticed anyway.

David, this is yours :)

Quoted 8 lines
Quoted 3 lines

Very true. Was a minor fix that I thought I'd just toss it out there and let anyone view it if they had the time. Will be more aware of who to CC next time around.

Or automate it: https://wiki.qemu.org/Contribute/SubmitAPatch#CC_the_relevant_maintainer suggests:

git config sendemail.cccmd 'scripts/get_maintainer.pl --nogit-fallback'

This is very helpful, thank you.

Signature · 2 lines
Respectfully,
- Collin Walling