2 * Core Definitions for QAPI/QMP Dispatch
4 * Copyright IBM, Corp. 2011
7 * Anthony Liguori <aliguori@us.ibm.com>
8 * Michael Roth <mdroth@us.ibm.com>
10 * This work is licensed under the terms of the GNU LGPL, version 2.1 or later.
11 * See the COPYING.LIB file in the top-level directory.
15 #include "qemu/osdep.h"
16 #include "qapi/qmp/dispatch.h"
18 void qmp_register_command(QmpCommandList
*cmds
, const char *name
,
19 QmpCommandFunc
*fn
, QmpCommandOptions options
)
21 QmpCommand
*cmd
= g_malloc0(sizeof(*cmd
));
26 cmd
->options
= options
;
27 QTAILQ_INSERT_TAIL(cmds
, cmd
, node
);
30 QmpCommand
*qmp_find_command(QmpCommandList
*cmds
, const char *name
)
34 QTAILQ_FOREACH(cmd
, cmds
, node
) {
35 if (strcmp(cmd
->name
, name
) == 0) {
42 static void qmp_toggle_command(QmpCommandList
*cmds
, const char *name
,
47 QTAILQ_FOREACH(cmd
, cmds
, node
) {
48 if (strcmp(cmd
->name
, name
) == 0) {
49 cmd
->enabled
= enabled
;
55 void qmp_disable_command(QmpCommandList
*cmds
, const char *name
)
57 qmp_toggle_command(cmds
, name
, false);
60 void qmp_enable_command(QmpCommandList
*cmds
, const char *name
)
62 qmp_toggle_command(cmds
, name
, true);
65 bool qmp_command_is_enabled(const QmpCommand
*cmd
)
70 const char *qmp_command_name(const QmpCommand
*cmd
)
75 bool qmp_has_success_response(const QmpCommand
*cmd
)
77 return !(cmd
->options
& QCO_NO_SUCCESS_RESP
);
80 void qmp_for_each_command(QmpCommandList
*cmds
, qmp_cmd_callback_fn fn
,
85 QTAILQ_FOREACH(cmd
, cmds
, node
) {