qmp-core.h 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  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 QMP_CORE_H
  14. #define QMP_CORE_H
  15. #include "qobject.h"
  16. #include "qdict.h"
  17. #include "error.h"
  18. typedef void (QmpCommandFunc)(QDict *, QObject **, Error **);
  19. typedef enum QmpCommandType
  20. {
  21. QCT_NORMAL,
  22. } QmpCommandType;
  23. typedef enum QmpCommandOptions
  24. {
  25. QCO_NO_OPTIONS = 0x0,
  26. QCO_NO_SUCCESS_RESP = 0x1,
  27. } QmpCommandOptions;
  28. typedef struct QmpCommand
  29. {
  30. const char *name;
  31. QmpCommandType type;
  32. QmpCommandFunc *fn;
  33. QmpCommandOptions options;
  34. QTAILQ_ENTRY(QmpCommand) node;
  35. bool enabled;
  36. } QmpCommand;
  37. void qmp_register_command(const char *name, QmpCommandFunc *fn,
  38. QmpCommandOptions options);
  39. QmpCommand *qmp_find_command(const char *name);
  40. QObject *qmp_dispatch(QObject *request);
  41. void qmp_disable_command(const char *name);
  42. void qmp_enable_command(const char *name);
  43. bool qmp_command_is_enabled(const char *name);
  44. char **qmp_get_command_list(void);
  45. QObject *qmp_build_error_object(Error *errp);
  46. #endif