2
0

qmp-registry.h 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. /*
  2. * Core Definitions for QAPI/QMP Dispatch
  3. *
  4. * Copyright IBM, Corp. 2011
  5. *
  6. * Authors:
  7. * Anthony Liguori <aliguori@us.ibm.com>
  8. *
  9. * This work is licensed under the terms of the GNU LGPL, version 2.1 or later.
  10. * See the COPYING.LIB file in the top-level directory.
  11. *
  12. */
  13. #ifndef QAPI_QMP_DISPATCH_H
  14. #define QAPI_QMP_DISPATCH_H
  15. #include "monitor/monitor.h"
  16. #include "qemu/queue.h"
  17. typedef void (QmpCommandFunc)(QDict *, QObject **, Error **);
  18. typedef enum QmpCommandOptions
  19. {
  20. QCO_NO_SUCCESS_RESP = (1U << 0),
  21. QCO_ALLOW_OOB = (1U << 1),
  22. QCO_ALLOW_PRECONFIG = (1U << 2),
  23. QCO_COROUTINE = (1U << 3),
  24. } QmpCommandOptions;
  25. typedef struct QmpCommand
  26. {
  27. const char *name;
  28. /* Runs in coroutine context if QCO_COROUTINE is set */
  29. QmpCommandFunc *fn;
  30. QmpCommandOptions options;
  31. uint64_t features;
  32. QTAILQ_ENTRY(QmpCommand) node;
  33. bool enabled;
  34. const char *disable_reason;
  35. } QmpCommand;
  36. typedef QTAILQ_HEAD(QmpCommandList, QmpCommand) QmpCommandList;
  37. void qmp_register_command(QmpCommandList *cmds, const char *name,
  38. QmpCommandFunc *fn, QmpCommandOptions options,
  39. uint64_t features);
  40. const QmpCommand *qmp_find_command(const QmpCommandList *cmds,
  41. const char *name);
  42. void qmp_disable_command(QmpCommandList *cmds, const char *name,
  43. const char *err_msg);
  44. void qmp_enable_command(QmpCommandList *cmds, const char *name);
  45. bool qmp_command_is_enabled(const QmpCommand *cmd);
  46. bool qmp_command_available(const QmpCommand *cmd, Error **errp);
  47. const char *qmp_command_name(const QmpCommand *cmd);
  48. bool qmp_has_success_response(const QmpCommand *cmd);
  49. QDict *qmp_error_response(Error *err);
  50. QDict *coroutine_mixed_fn qmp_dispatch(const QmpCommandList *cmds, QObject *request,
  51. bool allow_oob, Monitor *cur_mon);
  52. bool qmp_is_oob(const QDict *dict);
  53. typedef void (*qmp_cmd_callback_fn)(const QmpCommand *cmd, void *opaque);
  54. void qmp_for_each_command(const QmpCommandList *cmds, qmp_cmd_callback_fn fn,
  55. void *opaque);
  56. #endif