mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-04 00:03:54 -06:00
monitor: union for command handlers
This commits adds a new union member to mon_cmd_t for command handlers and convert monitor_handle_command() and qemu-monitor.hx to use it. This improves type safety. Patchworks-ID: 35337 Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
This commit is contained in:
parent
910df89d87
commit
af4ce882d5
2 changed files with 63 additions and 68 deletions
|
@ -71,11 +71,11 @@
|
|||
typedef struct mon_cmd_t {
|
||||
const char *name;
|
||||
const char *args_type;
|
||||
void *handler;
|
||||
const char *params;
|
||||
const char *help;
|
||||
union {
|
||||
void (*info)(Monitor *mon);
|
||||
void (*cmd)(Monitor *mon, const QDict *qdict);
|
||||
} mhandler;
|
||||
} mon_cmd_t;
|
||||
|
||||
|
@ -3014,13 +3014,8 @@ static void monitor_handle_command(Monitor *mon, const char *cmdline)
|
|||
|
||||
cmd = monitor_parse_command(mon, cmdline, qdict);
|
||||
if (cmd) {
|
||||
void (*handler)(Monitor *mon, const QDict *qdict);
|
||||
|
||||
qemu_errors_to_mon(mon);
|
||||
|
||||
handler = cmd->handler;
|
||||
handler(mon, qdict);
|
||||
|
||||
cmd->mhandler.cmd(mon, qdict);
|
||||
qemu_errors_to_previous();
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue