From: Kevin Wolf <kwolf@redhat.com>
To: qemu-devel@nongnu.org
Cc: kwolf@redhat.com, berrange@redhat.com, qemu-block@nongnu.org,
armbru@redhat.com, dgilbert@redhat.com
Subject: [Qemu-devel] [PATCH v3 06/15] monitor: Rename HMP command type and tables
Date: Thu, 13 Jun 2019 17:33:56 +0200 [thread overview]
Message-ID: <20190613153405.24769-7-kwolf@redhat.com> (raw)
In-Reply-To: <20190613153405.24769-1-kwolf@redhat.com>
This renames the type for HMP monitor commands and the tables holding
the commands to make clear that they are related to HMP and to allow
making them public later:
* mon_cmd_t -> HMPCommand (fixing use of a reserved name, too)
* mon_cmds -> hmp_cmds
* info_cmds -> hmp_info_cmds
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
monitor.c | 68 ++++++++++++++++++++++++-------------------------
hmp-commands.hx | 2 +-
2 files changed, 35 insertions(+), 35 deletions(-)
diff --git a/monitor.c b/monitor.c
index 5eacaa48a6..006c650761 100644
--- a/monitor.c
+++ b/monitor.c
@@ -127,7 +127,7 @@
*
*/
-typedef struct mon_cmd_t {
+typedef struct HMPCommand {
const char *name;
const char *args_type;
const char *params;
@@ -138,9 +138,9 @@ typedef struct mon_cmd_t {
* cmd should be used. If it exists, sub_table[?].cmd should be
* used, and cmd of 1st level plays the role of help function.
*/
- struct mon_cmd_t *sub_table;
+ struct HMPCommand *sub_table;
void (*command_completion)(ReadLineState *rs, int nb_args, const char *str);
-} mon_cmd_t;
+} HMPCommand;
/* file descriptors passed via SCM_RIGHTS */
typedef struct mon_fd_t mon_fd_t;
@@ -277,8 +277,8 @@ static QLIST_HEAD(, MonFdset) mon_fdsets;
static int mon_refcount;
-static mon_cmd_t mon_cmds[];
-static mon_cmd_t info_cmds[];
+static HMPCommand hmp_cmds[];
+static HMPCommand hmp_info_cmds[];
QmpCommandList qmp_commands, qmp_cap_negotiation_commands;
@@ -935,7 +935,7 @@ static int parse_cmdline(const char *cmdline,
/*
* Can command @cmd be executed in preconfig state?
*/
-static bool cmd_can_preconfig(const mon_cmd_t *cmd)
+static bool cmd_can_preconfig(const HMPCommand *cmd)
{
if (!cmd->flags) {
return false;
@@ -945,7 +945,7 @@ static bool cmd_can_preconfig(const mon_cmd_t *cmd)
}
static void help_cmd_dump_one(Monitor *mon,
- const mon_cmd_t *cmd,
+ const HMPCommand *cmd,
char **prefix_args,
int prefix_args_nb)
{
@@ -962,10 +962,10 @@ static void help_cmd_dump_one(Monitor *mon,
}
/* @args[@arg_index] is the valid command need to find in @cmds */
-static void help_cmd_dump(Monitor *mon, const mon_cmd_t *cmds,
+static void help_cmd_dump(Monitor *mon, const HMPCommand *cmds,
char **args, int nb_args, int arg_index)
{
- const mon_cmd_t *cmd;
+ const HMPCommand *cmd;
size_t i;
/* No valid arg need to compare with, dump all in *cmds */
@@ -1023,7 +1023,7 @@ static void help_cmd(Monitor *mon, const char *name)
}
/* 2. dump the contents according to parsed args */
- help_cmd_dump(mon, mon_cmds, args, nb_args, 0);
+ help_cmd_dump(mon, hmp_cmds, args, nb_args, 0);
free_cmdline_args(args, nb_args);
}
@@ -2691,13 +2691,13 @@ int monitor_fd_param(Monitor *mon, const char *fdname, Error **errp)
}
/* Please update hmp-commands.hx when adding or changing commands */
-static mon_cmd_t info_cmds[] = {
+static HMPCommand hmp_info_cmds[] = {
#include "hmp-commands-info.h"
{ NULL, NULL, },
};
-/* mon_cmds and info_cmds would be sorted at runtime */
-static mon_cmd_t mon_cmds[] = {
+/* hmp_cmds and hmp_info_cmds would be sorted at runtime */
+static HMPCommand hmp_cmds[] = {
#include "hmp-commands.h"
{ NULL, NULL, },
};
@@ -3039,10 +3039,10 @@ static int is_valid_option(const char *c, const char *typestr)
return (typestr != NULL);
}
-static const mon_cmd_t *search_dispatch_table(const mon_cmd_t *disp_table,
- const char *cmdname)
+static const HMPCommand *search_dispatch_table(const HMPCommand *disp_table,
+ const char *cmdname)
{
- const mon_cmd_t *cmd;
+ const HMPCommand *cmd;
for (cmd = disp_table; cmd->name != NULL; cmd++) {
if (compare_cmd(cmdname, cmd->name)) {
@@ -3063,14 +3063,14 @@ static const mon_cmd_t *search_dispatch_table(const mon_cmd_t *disp_table,
* Do not assume the return value points into @table! It doesn't when
* the command is found in a sub-command table.
*/
-static const mon_cmd_t *monitor_parse_command(MonitorHMP *hmp_mon,
- const char *cmdp_start,
- const char **cmdp,
- mon_cmd_t *table)
+static const HMPCommand *monitor_parse_command(MonitorHMP *hmp_mon,
+ const char *cmdp_start,
+ const char **cmdp,
+ HMPCommand *table)
{
Monitor *mon = &hmp_mon->common;
const char *p;
- const mon_cmd_t *cmd;
+ const HMPCommand *cmd;
char cmdname[256];
/* extract the command name */
@@ -3114,7 +3114,7 @@ static const mon_cmd_t *monitor_parse_command(MonitorHMP *hmp_mon,
static QDict *monitor_parse_arguments(Monitor *mon,
const char **endp,
- const mon_cmd_t *cmd)
+ const HMPCommand *cmd)
{
const char *typestr;
char *key;
@@ -3479,12 +3479,12 @@ fail:
static void handle_hmp_command(MonitorHMP *mon, const char *cmdline)
{
QDict *qdict;
- const mon_cmd_t *cmd;
+ const HMPCommand *cmd;
const char *cmd_start = cmdline;
trace_handle_hmp_command(mon, cmdline);
- cmd = monitor_parse_command(mon, cmdline, &cmdline, mon_cmds);
+ cmd = monitor_parse_command(mon, cmdline, &cmdline, hmp_cmds);
if (!cmd) {
return;
}
@@ -4017,14 +4017,14 @@ void loadvm_completion(ReadLineState *rs, int nb_args, const char *str)
}
static void monitor_find_completion_by_table(MonitorHMP *mon,
- const mon_cmd_t *cmd_table,
+ const HMPCommand *cmd_table,
char **args,
int nb_args)
{
const char *cmdname;
int i;
const char *ptype, *old_ptype, *str, *name;
- const mon_cmd_t *cmd;
+ const HMPCommand *cmd;
BlockBackend *blk = NULL;
if (nb_args <= 1) {
@@ -4131,7 +4131,7 @@ static void monitor_find_completion(void *opaque,
}
/* 2. auto complete according to args */
- monitor_find_completion_by_table(mon, mon_cmds, args, nb_args);
+ monitor_find_completion_by_table(mon, hmp_cmds, args, nb_args);
cleanup:
free_cmdline_args(args, nb_args);
@@ -4531,20 +4531,20 @@ static void monitor_event(void *opaque, int event)
static int
compare_mon_cmd(const void *a, const void *b)
{
- return strcmp(((const mon_cmd_t *)a)->name,
- ((const mon_cmd_t *)b)->name);
+ return strcmp(((const HMPCommand *)a)->name,
+ ((const HMPCommand *)b)->name);
}
static void sortcmdlist(void)
{
int array_num;
- int elem_size = sizeof(mon_cmd_t);
+ int elem_size = sizeof(HMPCommand);
- array_num = sizeof(mon_cmds)/elem_size-1;
- qsort((void *)mon_cmds, array_num, elem_size, compare_mon_cmd);
+ array_num = sizeof(hmp_cmds)/elem_size-1;
+ qsort((void *)hmp_cmds, array_num, elem_size, compare_mon_cmd);
- array_num = sizeof(info_cmds)/elem_size-1;
- qsort((void *)info_cmds, array_num, elem_size, compare_mon_cmd);
+ array_num = sizeof(hmp_info_cmds)/elem_size-1;
+ qsort((void *)hmp_info_cmds, array_num, elem_size, compare_mon_cmd);
}
static void monitor_iothread_init(void)
diff --git a/hmp-commands.hx b/hmp-commands.hx
index a2c3ffc218..8b7aec3e8d 100644
--- a/hmp-commands.hx
+++ b/hmp-commands.hx
@@ -1934,7 +1934,7 @@ ETEXI
.params = "[subcommand]",
.help = "show various information about the system state",
.cmd = hmp_info_help,
- .sub_table = info_cmds,
+ .sub_table = hmp_info_cmds,
.flags = "p",
},
--
2.20.1
next prev parent reply other threads:[~2019-06-13 16:46 UTC|newest]
Thread overview: 40+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-06-13 15:33 [Qemu-devel] [PATCH v3 00/15] monitor: Split monitor.c in core/HMP/QMP/misc Kevin Wolf
2019-06-13 15:33 ` [Qemu-devel] [PATCH v3 01/15] monitor: Remove unused password prompting fields Kevin Wolf
2019-06-13 15:33 ` [Qemu-devel] [PATCH v3 02/15] monitor: Split monitor_init in HMP and QMP function Kevin Wolf
2019-06-14 8:51 ` Markus Armbruster
2019-06-13 15:33 ` [Qemu-devel] [PATCH v3 03/15] monitor: Make MonitorQMP a child class of Monitor Kevin Wolf
2019-06-14 8:54 ` Markus Armbruster
2019-06-13 15:33 ` [Qemu-devel] [PATCH v3 04/15] monitor: Create MonitorHMP with readline state Kevin Wolf
2019-06-14 8:55 ` Markus Armbruster
2019-06-13 15:33 ` [Qemu-devel] [PATCH v3 05/15] monitor: Remove Monitor.cmd_table indirection Kevin Wolf
2019-06-14 5:51 ` Markus Armbruster
2019-06-13 15:33 ` Kevin Wolf [this message]
2019-06-14 5:52 ` [Qemu-devel] [PATCH v3 06/15] monitor: Rename HMP command type and tables Markus Armbruster
2019-06-14 6:01 ` Markus Armbruster
2019-06-13 15:33 ` [Qemu-devel] [PATCH v3 07/15] Move monitor.c to monitor/misc.c Kevin Wolf
2019-06-14 6:04 ` Markus Armbruster
2019-06-14 6:25 ` Markus Armbruster
2019-06-13 15:33 ` [Qemu-devel] [PATCH v3 08/15] monitor: Move {hmp, qmp}.c to monitor/{hmp, qmp}-cmds.c Kevin Wolf
2019-06-13 15:33 ` [Qemu-devel] [PATCH v3 09/15] monitor: Create monitor-internal.h with common definitions Kevin Wolf
2019-06-14 6:37 ` Markus Armbruster
2019-06-14 8:47 ` Kevin Wolf
2019-06-13 15:34 ` [Qemu-devel] [PATCH v3 10/15] monitor: Split out monitor/qmp.c Kevin Wolf
2019-06-14 6:46 ` Markus Armbruster
2019-06-13 15:34 ` [Qemu-devel] [PATCH v3 11/15] monitor: Split out monitor/hmp.c Kevin Wolf
2019-06-14 8:23 ` Markus Armbruster
2019-06-14 9:17 ` Dr. David Alan Gilbert
2019-06-13 15:34 ` [Qemu-devel] [PATCH v3 12/15] monitor: Split out monitor/monitor.c Kevin Wolf
2019-06-14 8:29 ` Markus Armbruster
2019-06-13 15:34 ` [Qemu-devel] [PATCH v3 13/15] monitor: Split Monitor.flags into separate bools Kevin Wolf
2019-06-14 8:48 ` Markus Armbruster
2019-06-13 15:34 ` [Qemu-devel] [PATCH v3 14/15] monitor: Replace monitor_init() with monitor_init_{hmp, qmp}() Kevin Wolf
2019-06-14 8:50 ` Markus Armbruster
2019-06-13 15:34 ` [Qemu-devel] [PATCH v3 15/15] vl: Deprecate -mon pretty=... for HMP monitors Kevin Wolf
2019-06-14 9:01 ` Markus Armbruster
2019-06-14 9:13 ` Kevin Wolf
2019-06-14 11:14 ` Markus Armbruster
2019-06-13 17:31 ` [Qemu-devel] [PATCH v3 00/15] monitor: Split monitor.c in core/HMP/QMP/misc no-reply
2019-06-14 9:06 ` Markus Armbruster
2019-06-14 9:32 ` Kevin Wolf
2019-06-15 20:31 ` Markus Armbruster
2019-06-17 8:53 ` Kevin Wolf
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190613153405.24769-7-kwolf@redhat.com \
--to=kwolf@redhat.com \
--cc=armbru@redhat.com \
--cc=berrange@redhat.com \
--cc=dgilbert@redhat.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.