HMP: allow parsing for sub command
v5 cover HMP: allow parsing for sub command
These patches enhance HMP to allow it parse 2nd level of commands, such
as info sub command list, which means foldered command with parameter is possible now.
V2:
Follow the way supposed by Markus, which make the infrastructure knows
there is possible a 2nd level of command exist, instead of a hack. In this way extention of command folder level is easy.
Moved function declaration and better doc according to comments. Removed the patch about info snapshots, which will goto another serial.
V3:
Split out code moving patch.
V4:
Removed change of qmp_find_cmd().
Removed name change of monitor_parse_command().
v5:
Eliminate 'info' in mhandler for that it have same format with 'cmd' and info
is not a special case but a sub-command now.
Split out patch that checking for space before check for sub-command. Better comments for monitor_parse_command().
Add parameter start for better error tips in sub-command case. Add comments about how sub_table and mhandler interact.
Better commit message and tips that "info <unknowns>" show error now.
Wenchao Xia (6):
HMP: add QDict to info callback handler
HMP: delete info handler
HMP: add infrastructure for sub command
HMP: filter out space before check of sub-command
HMP: move define of mon_cmds
HMP: add sub command table to info
hmp-commands.hx | 3 +- hmp.c | 36 ++++---- hmp.h | 36 ++++---- hw/i8259.c | 4 +- hw/lm32_pic.c | 4 +- hw/lm32_pic.h | 4 +- hw/loader.c | 2 +- hw/loader.h | 3 +- hw/pc.h | 4 +- hw/pcmcia.h | 2 +- hw/qdev-monitor.c | 4 +- hw/qdev-monitor.h | 4 +- hw/sun4m.c | 4 +- hw/sun4m.h | 4 +- hw/usb.h | 2 +- hw/usb/bus.c | 2 +- hw/usb/host-bsd.c | 2 +- hw/usb/host-linux.c | 2 +- include/net/net.h | 2 +- include/net/slirp.h | 2 +- include/sysemu/sysemu.h | 4 +- monitor.c | 202 ++++++++++++++++++++++++---------------------- net/net.c | 2 +- net/slirp.c | 2 +- savevm.c | 2 +- vl.c | 2 +- 26 files changed, 175 insertions(+), 165 deletions(-)
PATCH v5 2/6 HMP: delete info handler
Now cmd and info handler have same format, so delete info handler.
--- monitor.c | 91 ++++++++++++++++++++++++++++++------------------------------- 1 files changed, 45 insertions(+), 46 deletions(-)
monitor.c +45 -46
@@ -123,7 +123,6 @@ typedef struct mon_cmd_t {const char *help;void (*user_print)(Monitor *mon,const QObject *data);union { -void (*info)(Monitor *mon,const QDict *qdict);void (*cmd)(Monitor *mon,const QDict *qdict);int (*cmd_new)(Monitor *mon,const QDict *params,QObject **ret_data); int (*cmd_async)(Monitor *mon, const QDict *params,
@@ -824,7 +823,7 @@ static void do_info(Monitor *mon, const QDict *qdict) goto help; } - cmd->mhandler.info (mon,NULL ); + cmd->mhandler.cmd (mon,NULL );return ; help:
@@ -2434,63 +2433,63 @@ static mon_cmd_t info_cmds[] = { .args_type = "", .params = "", .help = "show the version of QEMU", - .mhandler.info = hmp_info_version, + .mhandler.cmd = hmp_info_version, }, { .name = "network", .args_type = "", .params = "", .help = "show the network state", - .mhandler.info = do_info_network, + .mhandler.cmd = do_info_network, }, { .name = "chardev", .args_type = "", .params = "", .help = "show the character devices", - .mhandler.info = hmp_info_chardev, + .mhandler.cmd = hmp_info_chardev, }, { .name = "block", .args_type = "", .params = "", .help = "show the block devices", - .mhandler.info = hmp_info_block, + .mhandler.cmd = hmp_info_block, }, { .name = "blockstats", .args_type = "", .params = "", .help = "show block device statistics", - .mhandler.info = hmp_info_blockstats, + .mhandler.cmd = hmp_info_blockstats, }, { .name = "block-jobs", .args_type = "", .params = "", .help = "show progress of ongoing block device operations", - .mhandler.info = hmp_info_block_jobs, + .mhandler.cmd = hmp_info_block_jobs, }, { .name = "registers", .args_type = "", .params = "", .help = "show the cpu registers", - .mhandler.info = do_info_registers, + .mhandler.cmd = do_info_registers, }, { .name = "cpus", .args_type = "", .params = "", .help = "show infos for each CPU", - .mhandler.info = hmp_info_cpus, + .mhandler.cmd = hmp_info_cpus, }, { .name = "history", .args_type = "", .params = "", .help = "show the command line history", - .mhandler.info = do_info_history, + .mhandler.cmd = do_info_history, }, #if defined(TARGET_I386) || defined(TARGET_PPC) || defined(TARGET_MIPS) || \ defined(TARGET_LM32) || (defined(TARGET_SPARC) && !defined(TARGET_SPARC64))
@@ -2500,11 +2499,11 @@ static mon_cmd_t info_cmds[] = { .params = "", .help = "show the interrupts statistics (if available)", #ifdef TARGET_SPARC - .mhandler.info = sun4m_irq_info, + .mhandler.cmd = sun4m_irq_info,#elif defined(TARGET_LM32) - .mhandler.info = lm32_irq_info, + .mhandler.cmd = lm32_irq_info, #else - .mhandler.info = irq_info, + .mhandler.cmd = irq_info,#endif }, {
@@ -2513,11 +2512,11 @@ static mon_cmd_t info_cmds[] = { .params = "", .help = "show i8259 (PIC) state", #ifdef TARGET_SPARC - .mhandler.info = sun4m_pic_info, + .mhandler.cmd = sun4m_pic_info,#elif defined(TARGET_LM32 ) - .mhandler.info = lm32_do_pic_info, + .mhandler.cmd = lm32_do_pic_info, #else - .mhandler.info = pic_info, + .mhandler.cmd = pic_info,#endif }, #endif
@@ -2526,7 +2525,7 @@ static mon_cmd_t info_cmds[] = { .args_type = "", .params = "", .help = "show PCI info", - .mhandler.info = hmp_info_pci, + .mhandler.cmd = hmp_info_pci, },#if defined(TARGET_I386 ) || defined(TARGET_SH4 ) || defined(TARGET_SPARC ) || \ defined(TARGET_PPC ) || defined(TARGET_XTENSA )
@@ -2535,7 +2534,7 @@ static mon_cmd_t info_cmds[] = { .args_type = "", .params = "", .help = "show virtual to physical memory mappings", - .mhandler.info = tlb_info, + .mhandler.cmd = tlb_info, },#endif #if defined(TARGET_I386 )
@@ -2544,7 +2543,7 @@ static mon_cmd_t info_cmds[] = { .args_type = "", .params = "", .help = "show the active virtual memory mappings", - .mhandler.info = mem_info, + .mhandler.cmd = mem_info, },#endif {
@@ -2552,91 +2551,91 @@ static mon_cmd_t info_cmds[] = { .args_type = "", .params = "", .help = "show memory tree", - .mhandler.info = do_info_mtree, + .mhandler.cmd = do_info_mtree, }, { .name = "jit", .args_type = "", .params = "", .help = "show dynamic compiler info", - .mhandler.info = do_info_jit, + .mhandler.cmd = do_info_jit, }, { .name = "kvm", .args_type = "", .params = "", .help = "show KVM information", - .mhandler.info = hmp_info_kvm, + .mhandler.cmd = hmp_info_kvm, }, { .name = "numa", .args_type = "", .params = "", .help = "show NUMA information", - .mhandler.info = do_info_numa, + .mhandler.cmd = do_info_numa, }, { .name = "usb", .args_type = "", .params = "", .help = "show guest USB devices", - .mhandler.info = usb_info, + .mhandler.cmd = usb_info, }, { .name = "usbhost", .args_type = "", .params = "", .help = "show host USB devices", - .mhandler.info = usb_host_info, + .mhandler.cmd = usb_host_info, }, { .name = "profile", .args_type = "", .params = "", .help = "show profiling information", - .mhandler.info = do_info_profile, + .mhandler.cmd = do_info_profile, }, { .name = "capture", .args_type = "", .params = "", .help = "show capture information", - .mhandler.info = do_info_capture, + .mhandler.cmd = do_info_capture, }, { .name = "snapshots", .args_type = "", .params = "", .help = "show the currently saved VM snapshots", - .mhandler.info = do_info_snapshots, + .mhandler.cmd = do_info_snapshots, }, { .name = "status", .args_type = "", .params = "", .help = "show the current VM status (running|paused)", - .mhandler.info = hmp_info_status, + .mhandler.cmd = hmp_info_status, }, { .name = "pcmcia", .args_type = "", .params = "", .help = "show guest PCMCIA status", - .mhandler.info = pcmcia_info, + .mhandler.cmd = pcmcia_info, }, { .name = "mice", .args_type = "", .params = "", .help = "show which guest mouse is receiving events", - .mhandler.info = hmp_info_mice, + .mhandler.cmd = hmp_info_mice, }, { .name = "vnc", .args_type = "", .params = "", .help = "show the vnc server status", - .mhandler.info = hmp_info_vnc, + .mhandler.cmd = hmp_info_vnc, }, #if defined(CONFIG_SPICE) {
@@ -2644,7 +2643,7 @@ static mon_cmd_t info_cmds[] = { .args_type = "", .params = "", .help = "show the spice server status", - .mhandler.info = hmp_info_spice, + .mhandler.cmd = hmp_info_spice, },#endif {
@@ -2652,14 +2651,14 @@ static mon_cmd_t info_cmds[] = { .args_type = "", .params = "", .help = "show the current VM name", - .mhandler.info = hmp_info_name, + .mhandler.cmd = hmp_info_name, }, { .name = "uuid", .args_type = "", .params = "", .help = "show the current VM UUID", - .mhandler.info = hmp_info_uuid, + .mhandler.cmd = hmp_info_uuid, }, #if defined(TARGET_PPC) {
@@ -2667,7 +2666,7 @@ static mon_cmd_t info_cmds[] = { .args_type = "", .params = "", .help = "show CPU statistics", - .mhandler.info = do_info_cpu_stats, + .mhandler.cmd = do_info_cpu_stats, },#endif #if defined(CONFIG_SLIRP )
@@ -2676,7 +2675,7 @@ static mon_cmd_t info_cmds[] = { .args_type = "", .params = "", .help = "show user network stack connection states", - .mhandler.info = do_info_usernet, + .mhandler.cmd = do_info_usernet, },#endif {
@@ -2684,56 +2683,56 @@ static mon_cmd_t info_cmds[] = { .args_type = "", .params = "", .help = "show migration status", - .mhandler.info = hmp_info_migrate, + .mhandler.cmd = hmp_info_migrate, }, { .name = "migrate_capabilities", .args_type = "", .params = "", .help = "show current migration capabilities", - .mhandler.info = hmp_info_migrate_capabilities, + .mhandler.cmd = hmp_info_migrate_capabilities, }, { .name = "migrate_cache_size", .args_type = "", .params = "", .help = "show current migration xbzrle cache size", - .mhandler.info = hmp_info_migrate_cache_size, + .mhandler.cmd = hmp_info_migrate_cache_size, }, { .name = "balloon", .args_type = "", .params = "", .help = "show balloon information", - .mhandler.info = hmp_info_balloon, + .mhandler.cmd = hmp_info_balloon, }, { .name = "qtree", .args_type = "", .params = "", .help = "show device tree", - .mhandler.info = do_info_qtree, + .mhandler.cmd = do_info_qtree, }, { .name = "qdm", .args_type = "", .params = "", .help = "show qdev device model list", - .mhandler.info = do_info_qdm, + .mhandler.cmd = do_info_qdm, }, { .name = "roms", .args_type = "", .params = "", .help = "show roms", - .mhandler.info = do_info_roms, + .mhandler.cmd = do_info_roms, }, { .name = "trace-events", .args_type = "", .params = "", .help = "show available trace-events & their state", - .mhandler.info = do_trace_print_events, + .mhandler.cmd = do_trace_print_events, }, { .name = NULL,
Signature · 1 line
1.7.1
PATCH v5 5/6 HMP: move define of mon_cmds
In reply to Wenchao Xia Because mon_cmds may use info_cmds, so adjust the declare sequence
of them.
--- monitor.c | 12 ++++++------ 1 files changed, 6 insertions(+), 6 deletions(-)
monitor.c +6 -6
@@ -2425,12 +2425,6 @@ int monitor_handle_fd_param(Monitor *mon, const char *fdname)return fd; } -/* mon_cmds and info_cmds would be sorted at runtime */ -static mon_cmd_t mon_cmds[] = { -#include "hmp-commands.h" - {NULL ,NULL , }, -}; -/* Please update hmp-commands.hx when adding or changing commands */ static mon_cmd_t info_cmds[] = { {
@@ -2744,6 +2738,12 @@ static mon_cmd_t info_cmds[] = { }, }; +/* mon_cmds and info_cmds would be sorted at runtime */ +static mon_cmd_t mon_cmds[] = { +#include "hmp-commands.h" + {NULL ,NULL , }, +}; +static const mon_cmd_t qmp_cmds[] = { #include "qmp-commands-old.h" {/* NULL */ },
Signature · 1 line
1.7.1
PATCH v5 4/6 HMP: filter out space before check of sub-command
In reply to Wenchao Xia This fix the case when user input "@command ". Original
it will return NULL for monitor_parse_command(), now it will return the @command related instance.
--- monitor.c | 3 +++ 1 files changed, 3 insertions(+), 0 deletions(-)
monitor.c +3 -0
@@ -3588,6 +3588,9 @@ static const mon_cmd_t *monitor_parse_command(Monitor *mon,if (cmd->sub_table !=NULL ) { p1 = p;/* check if user set additional command */ +while (qemu_isspace (*p1)) { + p1++; + }if (*p1 =='\0' ) {return cmd; }
Signature · 1 line
1.7.1
PATCH v5 3/6 HMP: add infrastructure for sub command
In reply to Wenchao Xia This patch make parsing of hmp command aware of that it may
have sub command. Also discard simple encapsulation function monitor_find_command().
--- monitor.c | 48 +++++++++++++++++++++++++++++++++++++----------- 1 files changed, 37 insertions(+), 11 deletions(-)
monitor.c +37 -11
@@ -129,6 +129,11 @@ typedef struct mon_cmd_t { MonitorCompletion *cb, void *opaque); } mhandler;int flags; +/* @sub_table is a list of 2nd level of commands. If it do not exist, +* mhandler should be used. If it exist, sub_table[?].mhandler should be +* used, and mhandler of 1st level plays the role of help function. +*/ +struct mon_cmd_t *sub_table; } mon_cmd_t;/* file descriptors passed via SCM_RIGHTS */
@@ -3533,21 +3538,30 @@ static const mon_cmd_t *search_dispatch_table(const mon_cmd_t *disp_table,return NULL ; } -static const mon_cmd_t *monitor_find_command (const char *cmdname) -{ -return search_dispatch_table (mon_cmds, cmdname); -} -static const mon_cmd_t *qmp_find_cmd (const char *cmdname) {return search_dispatch_table (qmp_cmds, cmdname); } +/* +* Parse @cmdline according to command table @table. +* If @cmdline is blank, return NULL. +* If it can't be parsed, report to @mon, and return NULL. +* Else, insert command arguments into @qdict, and return the command. +* If sub-command table exist, and if @cmdline contains addtional string for +* sub-command, this function will try search sub-command table. if no +* addtional string for sub-command exist, this function will return the found +* one in @table. +* Do not assume the returned command points into @table! It doesn't +* when the command is a sub-command. +*/ static const mon_cmd_t *monitor_parse_command (Monitor *mon,const char *cmdline, +int start, +mon_cmd_t *table,QDict *qdict) { -const char *p, *typestr; +const char *p, *p1, *typestr;int c;const mon_cmd_t *cmd;char cmdname[256 ];
@@ -3555,20 +3569,32 @@ static const mon_cmd_t *monitor_parse_command(Monitor *mon,char *key;#ifdef DEBUG -monitor_printf (mon,"command='%s'\n" , cmdline); +monitor_printf (mon,"command='%s', start='%d'\n" , cmdline, start);#endif /* extract the command name */ - p =get_command_name (cmdline, cmdname,sizeof (cmdname)); + p =get_command_name (cmdline + start, cmdname,sizeof (cmdname));if (!p)return NULL ; - cmd =monitor_find_command (cmdname); + cmd =search_dispatch_table (table, cmdname);if (!cmd) { -monitor_printf (mon,"unknown command: '%s'\n" , cmdname); +monitor_printf (mon,"unknown command: '%.*s'\n" , + (int )(p - cmdline), cmdline);return NULL ; } +/* search sub command */ +if (cmd->sub_table !=NULL ) { + p1 = p; +/* check if user set additional command */ +if (*p1 =='\0' ) { +return cmd; + } +return monitor_parse_command (mon, cmdline, p1 - cmdline, + cmd->sub_table, qdict); + } +/* parse the parameters */ typestr = cmd->args_type;for (;;) {
@@ -3924,7 +3950,7 @@ static void handle_user_command(Monitor *mon, const char *cmdline) qdict =qdict_new (); - cmd =monitor_parse_command (mon, cmdline, qdict); + cmd =monitor_parse_command (mon, cmdline,0 , mon_cmds, qdict);if (!cmd) goto out;
Signature · 1 line
1.7.1
PATCH v5 6/6 HMP: add sub command table to info
In reply to Wenchao Xia Now info command takes a table of sub info commands,
and changed do_info() to do_info_help() to do help funtion only.
Note that now "info <unknown-topic>" returns error instead
of list of info topics.
--- hmp-commands.hx | 3 ++- monitor.c | 22 +--------------------- 2 files changed, 3 insertions(+), 22 deletions(-)
hmp-commands.hx +2 -1
@@ -1489,7 +1489,8 @@ ETEXI .args_type = "item:s?", .params = "[subcommand]", .help = "show various information about the system state", - .mhandler.cmd = do_info, + .mhandler.cmd = do_info_help, + .sub_table = info_cmds, }, STEXI
monitor.c +1 -21
@@ -810,28 +810,8 @@ static void user_async_cmd_handler(Monitor *mon, const mon_cmd_t *cmd, } } -static void do_info (Monitor *mon,const QDict *qdict) +static void do_info_help (Monitor *mon,const QDict *qdict) { -const mon_cmd_t *cmd; -const char *item =qdict_get_try_str (qdict,"item" ); - -if (!item) { - goto help; - } - -for (cmd = info_cmds; cmd->name !=NULL ; cmd++) { -if (compare_cmd (item, cmd->name)) -break ; - } - -if (cmd->name ==NULL ) { - goto help; - } - - cmd->mhandler.cmd (mon,NULL ); -return ; - -help:help_cmd (mon,"info" ); }
Signature · 1 line
1.7.1
PATCH v5 1/6 HMP: add QDict to info callback handler
In reply to Wenchao Xia This patch change all info call back function to take
additional QDict * parameter, which allow those command take parameter. Now it is set to NULL at default case.
--- hmp.c | 36 ++++++++++++++++++------------------ hmp.h | 36 ++++++++++++++++++------------------ hw/i8259.c | 4 ++-- hw/lm32_pic.c | 4 ++-- hw/lm32_pic.h | 4 ++-- hw/loader.c | 2 +- hw/loader.h | 3 ++- hw/pc.h | 4 ++-- hw/pcmcia.h | 2 +- hw/qdev-monitor.c | 4 ++-- hw/qdev-monitor.h | 4 ++-- hw/sun4m.c | 4 ++-- hw/sun4m.h | 4 ++-- hw/usb.h | 2 +- hw/usb/bus.c | 2 +- hw/usb/host-bsd.c | 2 +- hw/usb/host-linux.c | 2 +- include/net/net.h | 2 +- include/net/slirp.h | 2 +- include/sysemu/sysemu.h | 4 ++-- monitor.c | 32 ++++++++++++++++---------------- net/net.c | 2 +- net/slirp.c | 2 +- savevm.c | 2 +- vl.c | 2 +- 25 files changed, 84 insertions(+), 83 deletions(-)
hmp.c +18 -18
@@ -31,7 +31,7 @@ static void hmp_handle_error(Monitor *mon, Error **errp) } } -void hmp_info_name (Monitor *mon) +void hmp_info_name (Monitor *mon,const QDict *qdict) {NameInfo *info;
@@ -42,7 +42,7 @@ void hmp_info_name(Monitor *mon)qapi_free_NameInfo (info); } -void hmp_info_version (Monitor *mon) +void hmp_info_version (Monitor *mon,const QDict *qdict) {VersionInfo *info;
@@ -55,7 +55,7 @@ void hmp_info_version(Monitor *mon)qapi_free_VersionInfo (info); } -void hmp_info_kvm (Monitor *mon) +void hmp_info_kvm (Monitor *mon,const QDict *qdict) {KvmInfo *info;
@@ -70,7 +70,7 @@ void hmp_info_kvm(Monitor *mon)qapi_free_KvmInfo (info); } -void hmp_info_status (Monitor *mon) +void hmp_info_status (Monitor *mon,const QDict *qdict) {StatusInfo *info;
@@ -89,7 +89,7 @@ void hmp_info_status(Monitor *mon)qapi_free_StatusInfo (info); } -void hmp_info_uuid (Monitor *mon) +void hmp_info_uuid (Monitor *mon,const QDict *qdict) {UuidInfo *info;
@@ -98,7 +98,7 @@ void hmp_info_uuid(Monitor *mon)qapi_free_UuidInfo (info); } -void hmp_info_chardev (Monitor *mon) +void hmp_info_chardev (Monitor *mon,const QDict *qdict) {ChardevInfoList *char_info, *info;
@@ -111,7 +111,7 @@ void hmp_info_chardev(Monitor *mon)qapi_free_ChardevInfoList (char_info); } -void hmp_info_mice (Monitor *mon) +void hmp_info_mice (Monitor *mon,const QDict *qdict) {MouseInfoList *mice_list, *mouse;
@@ -131,7 +131,7 @@ void hmp_info_mice(Monitor *mon)qapi_free_MouseInfoList (mice_list); } -void hmp_info_migrate (Monitor *mon) +void hmp_info_migrate (Monitor *mon,const QDict *qdict) {MigrationInfo *info;MigrationCapabilityStatusList *caps, *cap;
@@ -209,7 +209,7 @@ void hmp_info_migrate(Monitor *mon)qapi_free_MigrationCapabilityStatusList (caps); } -void hmp_info_migrate_capabilities (Monitor *mon) +void hmp_info_migrate_capabilities (Monitor *mon,const QDict *qdict) {MigrationCapabilityStatusList *caps, *cap;
@@ -228,13 +228,13 @@ void hmp_info_migrate_capabilities(Monitor *mon)qapi_free_MigrationCapabilityStatusList (caps); } -void hmp_info_migrate_cache_size (Monitor *mon) +void hmp_info_migrate_cache_size (Monitor *mon,const QDict *qdict) {monitor_printf (mon,"xbzrel cache size: %" PRId64" kbytes\n" ,qmp_query_migrate_cache_size (NULL ) >>10 ); } -void hmp_info_cpus (Monitor *mon) +void hmp_info_cpus (Monitor *mon,const QDict *qdict) {CpuInfoList *cpu_list, *cpu;
@@ -272,7 +272,7 @@ void hmp_info_cpus(Monitor *mon)qapi_free_CpuInfoList (cpu_list); } -void hmp_info_block (Monitor *mon) +void hmp_info_block (Monitor *mon,const QDict *qdict) {BlockInfoList *block_list, *info;
@@ -326,7 +326,7 @@ void hmp_info_block(Monitor *mon)qapi_free_BlockInfoList (block_list); } -void hmp_info_blockstats (Monitor *mon) +void hmp_info_blockstats (Monitor *mon,const QDict *qdict) {BlockStatsList *stats_list, *stats;
@@ -360,7 +360,7 @@ void hmp_info_blockstats(Monitor *mon)qapi_free_BlockStatsList (stats_list); } -void hmp_info_vnc (Monitor *mon) +void hmp_info_vnc (Monitor *mon,const QDict *qdict) {VncInfo *info;Error *err =NULL ;
@@ -406,7 +406,7 @@ out:qapi_free_VncInfo (info); } -void hmp_info_spice (Monitor *mon) +void hmp_info_spice (Monitor *mon,const QDict *qdict) {SpiceChannelList *chan;SpiceInfo *info;
@@ -453,7 +453,7 @@ out:qapi_free_SpiceInfo (info); } -void hmp_info_balloon (Monitor *mon) +void hmp_info_balloon (Monitor *mon,const QDict *qdict) {BalloonInfo *info;Error *err =NULL ;
@@ -570,7 +570,7 @@ static void hmp_info_pci_device(Monitor *mon, const PciDeviceInfo *dev) } } -void hmp_info_pci (Monitor *mon) +void hmp_info_pci (Monitor *mon,const QDict *qdict) {PciInfoList *info_list, *info;Error *err =NULL ;
@@ -593,7 +593,7 @@ void hmp_info_pci(Monitor *mon)qapi_free_PciInfoList (info_list); } -void hmp_info_block_jobs (Monitor *mon) +void hmp_info_block_jobs (Monitor *mon,const QDict *qdict) {BlockJobInfoList *list;Error *err =NULL ;
hmp.h +18 -18
@@ -18,24 +18,24 @@#include "qapi-types.h" #include "qapi/qmp/qdict.h" -void hmp_info_name (Monitor *mon); -void hmp_info_version (Monitor *mon); -void hmp_info_kvm (Monitor *mon); -void hmp_info_status (Monitor *mon); -void hmp_info_uuid (Monitor *mon); -void hmp_info_chardev (Monitor *mon); -void hmp_info_mice (Monitor *mon); -void hmp_info_migrate (Monitor *mon); -void hmp_info_migrate_capabilities (Monitor *mon); -void hmp_info_migrate_cache_size (Monitor *mon); -void hmp_info_cpus (Monitor *mon); -void hmp_info_block (Monitor *mon); -void hmp_info_blockstats (Monitor *mon); -void hmp_info_vnc (Monitor *mon); -void hmp_info_spice (Monitor *mon); -void hmp_info_balloon (Monitor *mon); -void hmp_info_pci (Monitor *mon); -void hmp_info_block_jobs (Monitor *mon); +void hmp_info_name (Monitor *mon,const QDict *qdict); +void hmp_info_version (Monitor *mon,const QDict *qdict); +void hmp_info_kvm (Monitor *mon,const QDict *qdict); +void hmp_info_status (Monitor *mon,const QDict *qdict); +void hmp_info_uuid (Monitor *mon,const QDict *qdict); +void hmp_info_chardev (Monitor *mon,const QDict *qdict); +void hmp_info_mice (Monitor *mon,const QDict *qdict); +void hmp_info_migrate (Monitor *mon,const QDict *qdict); +void hmp_info_migrate_capabilities (Monitor *mon,const QDict *qdict); +void hmp_info_migrate_cache_size (Monitor *mon,const QDict *qdict); +void hmp_info_cpus (Monitor *mon,const QDict *qdict); +void hmp_info_block (Monitor *mon,const QDict *qdict); +void hmp_info_blockstats (Monitor *mon,const QDict *qdict); +void hmp_info_vnc (Monitor *mon,const QDict *qdict); +void hmp_info_spice (Monitor *mon,const QDict *qdict); +void hmp_info_balloon (Monitor *mon,const QDict *qdict); +void hmp_info_pci (Monitor *mon,const QDict *qdict); +void hmp_info_block_jobs (Monitor *mon,const QDict *qdict);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);
hw/i8259.c +2 -2
@@ -407,7 +407,7 @@ static void pic_init(PICCommonState *s)qdev_init_gpio_in (&s->dev.qdev, pic_set_irq,8 ); } -void pic_info (Monitor *mon) +void pic_info (Monitor *mon,const QDict *qdict) {int i;PICCommonState *s;
@@ -425,7 +425,7 @@ void pic_info(Monitor *mon) } } -void irq_info (Monitor *mon) +void irq_info (Monitor *mon,const QDict *qdict) {#ifndef DEBUG_IRQ_COUNT monitor_printf (mon,"irq statistic code not compiled.\n" );
hw/lm32_pic.c +2 -2
@@ -39,7 +39,7 @@ struct LM32PicState {typedef struct LM32PicState LM32PicState ;static LM32PicState *pic; -void lm32_do_pic_info (Monitor *mon) +void lm32_do_pic_info (Monitor *mon,const QDict *qdict) {if (pic ==NULL ) {return ;
@@ -49,7 +49,7 @@ void lm32_do_pic_info(Monitor *mon) pic->im, pic->ip, pic->irq_state); } -void lm32_irq_info (Monitor *mon) +void lm32_irq_info (Monitor *mon,const QDict *qdict) {int i;uint32_t count;
hw/lm32_pic.h +2 -2
@@ -8,7 +8,7 @@ uint32_t lm32_pic_get_im(DeviceState *d);void lm32_pic_set_ip (DeviceState *d,uint32_t ip);void lm32_pic_set_im (DeviceState *d,uint32_t im); -void lm32_do_pic_info (Monitor *mon); -void lm32_irq_info (Monitor *mon); +void lm32_do_pic_info (Monitor *mon,const QDict *qdict); +void lm32_irq_info (Monitor *mon,const QDict *qdict);#endif /* QEMU_HW_LM32_PIC_H */
hw/loader.c +1 -1
@@ -778,7 +778,7 @@ void *rom_ptr(hwaddr addr)return rom->data + (addr - rom->addr); } -void do_info_roms (Monitor *mon) +void do_info_roms (Monitor *mon,const QDict *qdict) {Rom *rom;
hw/loader.h +2 -1
@@ -1,5 +1,6 @@#ifndef LOADER_H #define LOADER_H +#include "qapi/qmp/qdict.h" /* loader.c */ int get_image_size (const char *filename);
@@ -30,7 +31,7 @@ int rom_load_all(void);void rom_set_fw (void *f);int rom_copy (uint8_t *dest,hwaddr addr,size_t size);void *rom_ptr (hwaddr addr); -void do_info_roms (Monitor *mon); +void do_info_roms (Monitor *mon,const QDict *qdict);#define rom_add_file_fixed (_f, _a, _i) \ rom_add_file(_f, NULL, _a, _i)
hw/pc.h +2 -2
@@ -40,8 +40,8 @@ qemu_irq *i8259_init(ISABus *bus, qemu_irq parent_irq);qemu_irq *kvm_i8259_init (ISABus *bus);int pic_read_irq (DeviceState *d);int pic_get_output (DeviceState *d); -void pic_info (Monitor *mon); -void irq_info (Monitor *mon); +void pic_info (Monitor *mon,const QDict *qdict); +void irq_info (Monitor *mon,const QDict *qdict);/* Global System Interrupts */
hw/pcmcia.h +1 -1
@@ -14,7 +14,7 @@ typedef struct {void pcmcia_socket_register (PCMCIASocket *socket);void pcmcia_socket_unregister (PCMCIASocket *socket); -void pcmcia_info (Monitor *mon); +void pcmcia_info (Monitor *mon,const QDict *qdict);struct PCMCIACardState {void *state;
hw/qdev-monitor.c +2 -2
@@ -564,13 +564,13 @@ static void qbus_print(Monitor *mon, BusState *bus, int indent) }#undef qdev_printf -void do_info_qtree (Monitor *mon) +void do_info_qtree (Monitor *mon,const QDict *qdict) {if (sysbus_get_default ())qbus_print (mon,sysbus_get_default (),0 ); } -void do_info_qdm (Monitor *mon) +void do_info_qdm (Monitor *mon,const QDict *qdict) {object_class_foreach (qdev_print_devinfo,TYPE_DEVICE , false,NULL ); }
hw/qdev-monitor.h +2 -2
@@ -6,8 +6,8 @@/*** monitor commands ***/ -void do_info_qtree (Monitor *mon); -void do_info_qdm (Monitor *mon); +void do_info_qtree (Monitor *mon,const QDict *qdict); +void do_info_qdm (Monitor *mon,const QDict *qdict);int do_device_add (Monitor *mon,const QDict *qdict,QObject **ret_data);int do_device_del (Monitor *mon,const QDict *qdict,QObject **ret_data);int qdev_device_help (QemuOpts *opts);
hw/sun4m.c +2 -2
@@ -216,13 +216,13 @@ static void nvram_init(M48t59State *nvram, uint8_t *macaddr,static DeviceState *slavio_intctl; -void sun4m_pic_info (Monitor *mon) +void sun4m_pic_info (Monitor *mon,const QDict *qdict) {if (slavio_intctl)slavio_pic_info (mon, slavio_intctl); } -void sun4m_irq_info (Monitor *mon) +void sun4m_irq_info (Monitor *mon,const QDict *qdict) {if (slavio_intctl)slavio_irq_info (mon, slavio_intctl);
hw/sun4m.h +2 -2
@@ -27,8 +27,8 @@ void slavio_pic_info(Monitor *mon, DeviceState *dev);void slavio_irq_info (Monitor *mon,DeviceState *dev);/* sun4m.c */ -void sun4m_pic_info (Monitor *mon); -void sun4m_irq_info (Monitor *mon); +void sun4m_pic_info (Monitor *mon,const QDict *qdict); +void sun4m_irq_info (Monitor *mon,const QDict *qdict);/* sparc32_dma.c */ #include "sparc32_dma.h"
hw/usb.h +1 -1
@@ -435,7 +435,7 @@ int set_usb_string(uint8_t *buf, const char *str);/* usb-linux.c */ USBDevice *usb_host_device_open (USBBus *bus,const char *devname);int usb_host_device_close (const char *devname); -void usb_host_info (Monitor *mon); +void usb_host_info (Monitor *mon,const QDict *qdict);/* usb-bt.c */ USBDevice *usb_bt_init (USBBus *bus,HCIInfo *hci);
hw/usb/bus.c +1 -1
@@ -542,7 +542,7 @@ static char *usb_get_fw_dev_path(DeviceState *qdev)return fw_path; } -void usb_info (Monitor *mon) +void usb_info (Monitor *mon,const QDict *qdict) {USBBus *bus;USBDevice *dev;
hw/usb/host-bsd.c +1 -1
@@ -633,7 +633,7 @@ static int usb_host_info_device(void *opaque,return 0 ; } -void usb_host_info (Monitor *mon) +void usb_host_info (Monitor *mon,const QDict *qdict) {usb_host_scan (mon, usb_host_info_device); }
hw/usb/host-linux.c +1 -1
@@ -1998,7 +1998,7 @@ static void hex2str(int val, char *str, size_t size) } } -void usb_host_info (Monitor *mon) +void usb_host_info (Monitor *mon,const QDict *qdict) {struct USBAutoFilter *f;struct USBHostDevice *s;
include/net/net.h +1 -1
@@ -112,7 +112,7 @@ ssize_t qemu_deliver_packet_iov(NetClientState *sender, void *opaque);void print_net_client (Monitor *mon,NetClientState *nc); -void do_info_network (Monitor *mon); +void do_info_network (Monitor *mon,const QDict *qdict);/* NIC info */
include/net/slirp.h +1 -1
@@ -40,7 +40,7 @@ int net_slirp_parse_legacy(QemuOptsList *opts_list, const char *optarg, int *retint net_slirp_smb (const char *exported_dir); -void do_info_usernet (Monitor *mon); +void do_info_usernet (Monitor *mon,const QDict *qdict);#endif
include/sysemu/sysemu.h +2 -2
@@ -68,7 +68,7 @@ void qemu_add_machine_init_done_notifier(Notifier *notify);void do_savevm (Monitor *mon,const QDict *qdict);int load_vmstate (const char *name);void do_delvm (Monitor *mon,const QDict *qdict); -void do_info_snapshots (Monitor *mon); +void do_info_snapshots (Monitor *mon,const QDict *qdict);void qemu_announce_self (void );
@@ -171,7 +171,7 @@ extern CharDriverState *parallel_hds[MAX_PARALLEL_PORTS];void do_usb_add (Monitor *mon,const QDict *qdict);void do_usb_del (Monitor *mon,const QDict *qdict); -void usb_info (Monitor *mon); +void usb_info (Monitor *mon,const QDict *qdict);void rtc_change_mon_event (struct tm *tm);
monitor.c +16 -16
@@ -123,7 +123,7 @@ typedef struct mon_cmd_t {const char *help;void (*user_print)(Monitor *mon,const QObject *data);union { -void (*info)(Monitor *mon); +void (*info)(Monitor *mon,const QDict *qdict);void (*cmd)(Monitor *mon,const QDict *qdict);int (*cmd_new)(Monitor *mon,const QDict *params,QObject **ret_data); int (*cmd_async)(Monitor *mon, const QDict *params,
@@ -824,7 +824,7 @@ static void do_info(Monitor *mon, const QDict *qdict) goto help; } - cmd->mhandler.info (mon); + cmd->mhandler.info (mon,NULL );return ; help:
@@ -895,19 +895,19 @@ int monitor_get_cpu_index(void)return mon_get_cpu ()->cpu_index; } -static void do_info_registers (Monitor *mon) +static void do_info_registers (Monitor *mon,const QDict *qdict) {CPUArchState *env; env =mon_get_cpu ();cpu_dump_state (env, (FILE *)mon, monitor_fprintf,CPU_DUMP_FPU ); } -static void do_info_jit (Monitor *mon) +static void do_info_jit (Monitor *mon,const QDict *qdict) {dump_exec_info ((FILE *)mon, monitor_fprintf); } -static void do_info_history (Monitor *mon) +static void do_info_history (Monitor *mon,const QDict *qdict) {int i;const char *str;
@@ -926,7 +926,7 @@ static void do_info_history(Monitor *mon)#if defined(TARGET_PPC )/* XXX: not implemented in other targets */ -static void do_info_cpu_stats (Monitor *mon) +static void do_info_cpu_stats (Monitor *mon,const QDict *qdict) {CPUArchState *env;
@@ -935,7 +935,7 @@ static void do_info_cpu_stats(Monitor *mon) }#endif -static void do_trace_print_events (Monitor *mon) +static void do_trace_print_events (Monitor *mon,const QDict *qdict) {trace_print_events ((FILE *)mon, &monitor_fprintf); }
@@ -1487,7 +1487,7 @@ static void tlb_info_64(Monitor *mon, CPUArchState *env) }#endif -static void tlb_info (Monitor *mon) +static void tlb_info (Monitor *mon,const QDict *qdict) {CPUArchState *env;
@@ -1710,7 +1710,7 @@ static void mem_info_64(Monitor *mon, CPUArchState *env) }#endif -static void mem_info (Monitor *mon) +static void mem_info (Monitor *mon,const QDict *qdict) {CPUArchState *env;
@@ -1749,7 +1749,7 @@ static void print_tlb(Monitor *mon, int idx, tlb_t *tlb) tlb->d, tlb->wt); } -static void tlb_info (Monitor *mon) +static void tlb_info (Monitor *mon,const QDict *qdict) {CPUArchState *env =mon_get_cpu ();int i;
@@ -1765,7 +1765,7 @@ static void tlb_info(Monitor *mon)#endif #if defined(TARGET_SPARC ) || defined(TARGET_PPC ) || defined(TARGET_XTENSA ) -static void tlb_info (Monitor *mon) +static void tlb_info (Monitor *mon,const QDict *qdict) {CPUArchState *env1 =mon_get_cpu ();
@@ -1773,12 +1773,12 @@ static void tlb_info(Monitor *mon) }#endif -static void do_info_mtree (Monitor *mon) +static void do_info_mtree (Monitor *mon,const QDict *qdict) {mtree_info ((fprintf_function )monitor_printf, mon); } -static void do_info_numa (Monitor *mon) +static void do_info_numa (Monitor *mon,const QDict *qdict) {int i;CPUArchState *env;
@@ -1802,7 +1802,7 @@ static void do_info_numa(Monitor *mon)int64_t qemu_time;int64_t dev_time; -static void do_info_profile (Monitor *mon) +static void do_info_profile (Monitor *mon,const QDict *qdict) {int64_t total; total = qemu_time;
@@ -1816,7 +1816,7 @@ static void do_info_profile(Monitor *mon) dev_time = 0; }#else -static void do_info_profile (Monitor *mon) +static void do_info_profile (Monitor *mon,const QDict *qdict) {monitor_printf (mon,"Internal profiler not compiled\n" ); }
@@ -1825,7 +1825,7 @@ static void do_info_profile(Monitor *mon)/* Capture support */ static QLIST_HEAD (capture_list_head, CaptureState) capture_head; -static void do_info_capture (Monitor *mon) +static void do_info_capture (Monitor *mon,const QDict *qdict) {int i;CaptureState *s;
net/net.c +1 -1
@@ -852,7 +852,7 @@ void print_net_client(Monitor *mon, NetClientState *nc) NetClientOptionsKind_lookup[nc->info->type], nc->info_str); } -void do_info_network (Monitor *mon) +void do_info_network (Monitor *mon,const QDict *qdict) {NetClientState *nc, *peer;NetClientOptionsKind type;
net/slirp.c +1 -1
@@ -670,7 +670,7 @@ static int slirp_guestfwd(SlirpState *s, const char *config_str,return -1 ; } -void do_info_usernet (Monitor *mon) +void do_info_usernet (Monitor *mon,const QDict *qdict) {SlirpState *s;
savevm.c +1 -1
@@ -2333,7 +2333,7 @@ void do_delvm(Monitor *mon, const QDict *qdict) } } -void do_info_snapshots (Monitor *mon) +void do_info_snapshots (Monitor *mon,const QDict *qdict) {BlockDriverState *bs, *bs1;QEMUSnapshotInfo *sn_tab, *sn, s, *sn_info = &s;
vl.c +1 -1
@@ -1263,7 +1263,7 @@ void pcmcia_socket_unregister(PCMCIASocket *socket) } } -void pcmcia_info (Monitor *mon) +void pcmcia_info (Monitor *mon,const QDict *qdict) {struct pcmcia_socket_entry_s *iter;
Signature · 1 line
1.7.1
Re: [Qemu-devel] [PATCH V5 4/6] HMP: filter out space before check of sub-command
In reply to Wenchao XiaQuoted 14 lines · On Fri, 11 Jan 2013 17:14:03 +0800 Wenchao Xia <[email protected]>…
This fix the case when user input "@command ". Original
it will return NULL formonitor_parse_command(), now it will return the @command related instance.Signed-off-by Wenchao Xia <[email protected]>--- monitor.c | 3 +++ 1 files changed, 3 insertions(+), 0 deletions(-)monitor.c +0
-0
monitor.c static const mon_cmd_t *monitor_parse_command(Monitor *mon, · line 3593
Quoted 6 lines
monitor.c +3
-0@@ -3588,6 +3588,9 @@ static const mon_cmd_t *monitor_parse_command(Monitor *mon,if (cmd->sub_table !=NULL ) { p1 = p;/* check if user set additional command */ +while (qemu_isspace (*p1)) { + p1++; + }
Is there a reason for this to be in a different patch? I mean, why don't you squash this into the previous patch?
Actually, I guess that you could skip the spaces after the search_dispatch_table() call (using p) and drop p1. But please test it before doing so :)
Otherwise series looks good to me.
Quoted 3 lines
monitor.c +0
-0if (*p1 =='\0' ) {return cmd; }
Re: [Qemu-devel] [PATCH V5 4/6] HMP: filter out space before check of sub-command
Quoted 12 lines · Luiz Capitulino
Quoted 9 lines · On Fri, 11 Jan 2013 17:14:03 +0800 Wenchao Xia <[email protected]>…
This fix the case when user input "@command ". Original
it will return NULL formonitor_parse_command(), now it will return the @command related instance.Signed-off-by Wenchao Xia <[email protected]>--- monitor.c | 3 +++ 1 files changed, 3 insertions(+), 0 deletions(-)
Quoted 15 lines
monitor.c static const mon_cmd_t *monitor_parse_command(Monitor *mon, · line 3593
Quoted 11 lines
monitor.c +3
-0@@ -3588,6 +3588,9 @@ static const mon_cmd_t *monitor_parse_command(Monitor *mon,if (cmd->sub_table !=NULL ) { p1 = p;/* check if user set additional command */ +while (qemu_isspace (*p1)) { + p1++; + }Is there a reason for this to be in a different patch? I mean, why don't you squash this into the previous patch?
Markus suggest to do it and I think this make things clear. I am OK
to merge it and drop p1.
Quoted 10 lines
Actually, I guess that you could skip the spaces after the
search_dispatch_table()call (using p) and drop p1. But please test it before doing so :)Otherwise series looks good to me.
Quoted 3 lines
monitor.c +0
-0if (*p1 =='\0' ) {return cmd; }
Signature · 3 lines
Best Regards Wenchao Xia
Re: [Qemu-devel] [PATCH V5 4/6] HMP: filter out space before check of sub-command
Quoted 28 lines · Wenchao Xia
Quoted 12 lines · Luiz Capitulino
Quoted 9 lines · On Fri, 11 Jan 2013 17:14:03 +0800 Wenchao Xia <[email protected]>…
This fix the case when user input "@command ". Original
it will return NULL formonitor_parse_command(), now it will return the @command related instance.Signed-off-by Wenchao Xia <[email protected]>--- monitor.c | 3 +++ 1 files changed, 3 insertions(+), 0 deletions(-)Quoted 15 lines
monitor.c static const mon_cmd_t *monitor_parse_command(Monitor *mon, · line 3593
Quoted 11 lines
monitor.c +3
-0@@ -3588,6 +3588,9 @@ static const mon_cmd_t *monitor_parse_command(Monitor *mon,if (cmd->sub_table !=NULL ) { p1 = p;/* check if user set additional command */ +while (qemu_isspace (*p1)) { + p1++; + }Is there a reason for this to be in a different patch? I mean, why don't you squash this into the previous patch?
Quoted 1 line
Markus suggest to do it
Misunderstanding, sorry. My point was we skip over whitespace twice:
first here, and then again in monitor_parse_command(). Quote:
The check whether non-space characters follow is awkward. We need it only because we want to handle "@cmdline is blank" differently than "it can't be parsed", but monitor_parse_command() returns NULL for both cases.
Merely an observation, not a request to do anything about it in this series:
If we care, we can try to do better in a follow-up patch.
A possible way to do better is to have a handler for command "", to be invoked for entirely blank lines. In table info_cmds, the handler would be do_info_help. Then prefix commands don't need their handler anymore (it's in the sub_table), and sub_table can go into the mhandler union.
We'd need to suppress the "unknown command" error for cmdname "".
If this isn't clear, but you want to understand it, I can write a patch on top.
Quoted 2 lines
and I think this make things clear. I am OK
to merge it and drop p1.
I'm not sure it makes things clearer. It makes behavior of "info" without argument change twice in the series, though, in the preceding patch, and in this one. I think I agree with Luiz it's better to squash the two together again.
[...]
Re: [Qemu-devel] [PATCH V5 4/6] HMP: filter out space before check of sub-command
Quoted 30 lines · On Mon, 14 Jan 2013 14:46:35 +0100 Markus Armbruster <[email protected]> wrote:
Quoted 28 lines · Wenchao Xia
Quoted 27 lines · Luiz Capitulino
Quoted 14 lines · On Fri, 11 Jan 2013 17:14:03 +0800 Wenchao Xia <[email protected]>…
This fix the case when user input "@command ". Original
it will return NULL formonitor_parse_command(), now it will return the @command related instance.Signed-off-by Wenchao Xia <[email protected]>--- monitor.c | 3 +++ 1 files changed, 3 insertions(+), 0 deletions(-)monitor.c +0
-0monitor.c static const mon_cmd_t *monitor_parse_command(Monitor *mon, · line 3593
Quoted 6 lines
monitor.c +3
-0@@ -3588,6 +3588,9 @@ static const mon_cmd_t *monitor_parse_command(Monitor *mon,if (cmd->sub_table !=NULL ) { p1 = p;/* check if user set additional command */ +while (qemu_isspace (*p1)) { + p1++; + }Is there a reason for this to be in a different patch? I mean, why don't you squash this into the previous patch?
Quoted 4 lines
Quoted 1 line
Markus suggest to do it
Misunderstanding, sorry. My point was we skip over whitespace twice:
first here, and then again inmonitor_parse_command(). Quote:
That was my point in my second paragraph (which cut out).
Re: [Qemu-devel] [PATCH V5 4/6] HMP: filter out space before check of sub-command
In reply to Markus ArmbrusterQuoted 43 lines · Markus Armbruster
Quoted 28 lines · Wenchao Xia
Quoted 12 lines · Luiz Capitulino
Quoted 9 lines · On Fri, 11 Jan 2013 17:14:03 +0800 Wenchao Xia <[email protected]>…
This fix the case when user input "@command ". Original
it will return NULL formonitor_parse_command(), now it will return the @command related instance.Signed-off-by Wenchao Xia <[email protected]>--- monitor.c | 3 +++ 1 files changed, 3 insertions(+), 0 deletions(-)Quoted 15 lines
monitor.c static const mon_cmd_t *monitor_parse_command(Monitor *mon, · line 3593
Quoted 11 lines
monitor.c +3
-0@@ -3588,6 +3588,9 @@ static const mon_cmd_t *monitor_parse_command(Monitor *mon,if (cmd->sub_table !=NULL ) { p1 = p;/* check if user set additional command */ +while (qemu_isspace (*p1)) { + p1++; + }Is there a reason for this to be in a different patch? I mean, why don't you squash this into the previous patch?
Quoted 1 line
Markus suggest to do it
Misunderstanding, sorry. My point was we skip over whitespace twice:
first here, and then again inmonitor_parse_command(). Quote:The check whether non-space characters follow is awkward. We need it only because we want to handle "@cmdline is blank" differently than "it can't be parsed", but
monitor_parse_command()returns NULL for both cases.Merely an observation, not a request to do anything about it in this series:
Quoted 7 lines
If we care, we can try to do better in a follow-up patch.
A possible way to do better is to have a handler for command "", to be invoked for entirely blank lines. In table
info_cmds, the handler would bedo_info_help. Then prefix commands don't need their handler anymore (it's in thesub_table), andsub_tablecan go into the mhandler union.
Thanks for the declaration. Have a handler for command "" seems good,
but need a careful check about the parsing code since '\0' is a key value. *sub_table plays an extra role of tagging if it have sub-commands so I think it is better to not folder it into mhandler union.
Quoted 15 lines
We'd need to suppress the "unknown command" error for cmdname "".
If this isn't clear, but you want to understand it, I can write a patch on top.
Quoted 2 lines
and I think this make things clear. I am OK
to merge it and drop p1.I'm not sure it makes things clearer. It makes behavior of "info" without argument change twice in the series, though, in the preceding patch, and in this one. I think I agree with Luiz it's better to squash the two together again.
[...]
Signature · 3 lines
Best Regards Wenchao Xia