Registration/lookup functions for that provide a lookup table for dispatching QMP commands.
Signed-off-by: Michael Roth <mdr...@linux.vnet.ibm.com> --- qapi/qmp-registry.c | 27 +++++++++++++++++++++++++++ 1 files changed, 27 insertions(+), 0 deletions(-) create mode 100644 qapi/qmp-registry.c diff --git a/qapi/qmp-registry.c b/qapi/qmp-registry.c new file mode 100644 index 0000000..f870244 --- /dev/null +++ b/qapi/qmp-registry.c @@ -0,0 +1,27 @@ +#include "qapi/qmp-core.h" + +static QTAILQ_HEAD(, QmpCommand) qmp_commands = + QTAILQ_HEAD_INITIALIZER(qmp_commands); + +void qmp_register_command(const char *name, QmpCommandFunc *fn) +{ + QmpCommand *cmd = qemu_mallocz(sizeof(*cmd)); + + cmd->name = name; + cmd->type = QCT_NORMAL; + cmd->fn = fn; + QTAILQ_INSERT_TAIL(&qmp_commands, cmd, node); +} + +QmpCommand *qmp_find_command(const char *name) +{ + QmpCommand *i; + + QTAILQ_FOREACH(i, &qmp_commands, node) { + if (strcmp(i->name, name) == 0) { + return i; + } + } + return NULL; +} + -- 1.7.0.4