From: Daniel P. Berrangé Date: Mon, 18 Nov 2024 15:12:35 +0000 (+0100) Subject: qapi: Move and rename qapi/qmp/dispatch.h to qapi/qmp-registry.h X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=153b0989d8ec7e8ef660ed9a614964f3dbdf231f;p=qemu.git qapi: Move and rename qapi/qmp/dispatch.h to qapi/qmp-registry.h The general expectation is that header files should follow the same file/path naming scheme as the corresponding source file. There are various historical exceptions to this practice in QEMU, with one of the most notable being the include/qapi/qmp/ directory. include/qapi/qmp/dispatch.h corresponds mostly to qapi/qmp-registry.c. Move and rename it to include/qapi/qmp-registry.h. Now just qerror.h is left in include/qapi/qmp/. Since it's deprecated & (slowly) getting eliminated anyway, it isn't worth moving. Signed-off-by: Daniel P. Berrangé Reviewed-by: Zhao Liu Signed-off-by: Markus Armbruster Message-ID: <20241118151235.2665921-3-armbru@redhat.com> --- diff --git a/docs/devel/qapi-code-gen.rst b/docs/devel/qapi-code-gen.rst index 259d6b10c3..9fa94251b0 100644 --- a/docs/devel/qapi-code-gen.rst +++ b/docs/devel/qapi-code-gen.rst @@ -1855,7 +1855,7 @@ Example:: #ifndef EXAMPLE_QAPI_INIT_COMMANDS_H #define EXAMPLE_QAPI_INIT_COMMANDS_H - #include "qapi/qmp/dispatch.h" + #include "qapi/qmp-registry.h" void example_qmp_init_marshal(QmpCommandList *cmds); diff --git a/include/qapi/qmp-registry.h b/include/qapi/qmp-registry.h new file mode 100644 index 0000000000..f2e956813a --- /dev/null +++ b/include/qapi/qmp-registry.h @@ -0,0 +1,67 @@ +/* + * Core Definitions for QAPI/QMP Dispatch + * + * Copyright IBM, Corp. 2011 + * + * Authors: + * Anthony Liguori + * + * This work is licensed under the terms of the GNU LGPL, version 2.1 or later. + * See the COPYING.LIB file in the top-level directory. + * + */ + +#ifndef QAPI_QMP_DISPATCH_H +#define QAPI_QMP_DISPATCH_H + +#include "monitor/monitor.h" +#include "qemu/queue.h" + +typedef void (QmpCommandFunc)(QDict *, QObject **, Error **); + +typedef enum QmpCommandOptions +{ + QCO_NO_SUCCESS_RESP = (1U << 0), + QCO_ALLOW_OOB = (1U << 1), + QCO_ALLOW_PRECONFIG = (1U << 2), + QCO_COROUTINE = (1U << 3), +} QmpCommandOptions; + +typedef struct QmpCommand +{ + const char *name; + /* Runs in coroutine context if QCO_COROUTINE is set */ + QmpCommandFunc *fn; + QmpCommandOptions options; + unsigned special_features; + QTAILQ_ENTRY(QmpCommand) node; + bool enabled; + const char *disable_reason; +} QmpCommand; + +typedef QTAILQ_HEAD(QmpCommandList, QmpCommand) QmpCommandList; + +void qmp_register_command(QmpCommandList *cmds, const char *name, + QmpCommandFunc *fn, QmpCommandOptions options, + unsigned special_features); +const QmpCommand *qmp_find_command(const QmpCommandList *cmds, + const char *name); +void qmp_disable_command(QmpCommandList *cmds, const char *name, + const char *err_msg); +void qmp_enable_command(QmpCommandList *cmds, const char *name); + +bool qmp_command_is_enabled(const QmpCommand *cmd); +bool qmp_command_available(const QmpCommand *cmd, Error **errp); +const char *qmp_command_name(const QmpCommand *cmd); +bool qmp_has_success_response(const QmpCommand *cmd); +QDict *qmp_error_response(Error *err); +QDict *coroutine_mixed_fn qmp_dispatch(const QmpCommandList *cmds, QObject *request, + bool allow_oob, Monitor *cur_mon); +bool qmp_is_oob(const QDict *dict); + +typedef void (*qmp_cmd_callback_fn)(const QmpCommand *cmd, void *opaque); + +void qmp_for_each_command(const QmpCommandList *cmds, qmp_cmd_callback_fn fn, + void *opaque); + +#endif diff --git a/include/qapi/qmp/dispatch.h b/include/qapi/qmp/dispatch.h deleted file mode 100644 index f2e956813a..0000000000 --- a/include/qapi/qmp/dispatch.h +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Core Definitions for QAPI/QMP Dispatch - * - * Copyright IBM, Corp. 2011 - * - * Authors: - * Anthony Liguori - * - * This work is licensed under the terms of the GNU LGPL, version 2.1 or later. - * See the COPYING.LIB file in the top-level directory. - * - */ - -#ifndef QAPI_QMP_DISPATCH_H -#define QAPI_QMP_DISPATCH_H - -#include "monitor/monitor.h" -#include "qemu/queue.h" - -typedef void (QmpCommandFunc)(QDict *, QObject **, Error **); - -typedef enum QmpCommandOptions -{ - QCO_NO_SUCCESS_RESP = (1U << 0), - QCO_ALLOW_OOB = (1U << 1), - QCO_ALLOW_PRECONFIG = (1U << 2), - QCO_COROUTINE = (1U << 3), -} QmpCommandOptions; - -typedef struct QmpCommand -{ - const char *name; - /* Runs in coroutine context if QCO_COROUTINE is set */ - QmpCommandFunc *fn; - QmpCommandOptions options; - unsigned special_features; - QTAILQ_ENTRY(QmpCommand) node; - bool enabled; - const char *disable_reason; -} QmpCommand; - -typedef QTAILQ_HEAD(QmpCommandList, QmpCommand) QmpCommandList; - -void qmp_register_command(QmpCommandList *cmds, const char *name, - QmpCommandFunc *fn, QmpCommandOptions options, - unsigned special_features); -const QmpCommand *qmp_find_command(const QmpCommandList *cmds, - const char *name); -void qmp_disable_command(QmpCommandList *cmds, const char *name, - const char *err_msg); -void qmp_enable_command(QmpCommandList *cmds, const char *name); - -bool qmp_command_is_enabled(const QmpCommand *cmd); -bool qmp_command_available(const QmpCommand *cmd, Error **errp); -const char *qmp_command_name(const QmpCommand *cmd); -bool qmp_has_success_response(const QmpCommand *cmd); -QDict *qmp_error_response(Error *err); -QDict *coroutine_mixed_fn qmp_dispatch(const QmpCommandList *cmds, QObject *request, - bool allow_oob, Monitor *cur_mon); -bool qmp_is_oob(const QDict *dict); - -typedef void (*qmp_cmd_callback_fn)(const QmpCommand *cmd, void *opaque); - -void qmp_for_each_command(const QmpCommandList *cmds, qmp_cmd_callback_fn fn, - void *opaque); - -#endif diff --git a/monitor/monitor-internal.h b/monitor/monitor-internal.h index 72cab703eb..5676eb334e 100644 --- a/monitor/monitor-internal.h +++ b/monitor/monitor-internal.h @@ -28,7 +28,7 @@ #include "chardev/char-fe.h" #include "monitor/monitor.h" #include "qapi/qapi-types-control.h" -#include "qapi/qmp/dispatch.h" +#include "qapi/qmp-registry.h" #include "qobject/json-parser.h" #include "qemu/readline.h" #include "system/iothread.h" diff --git a/qapi/qmp-dispatch.c b/qapi/qmp-dispatch.c index e24ba9f0b6..fa95fcceac 100644 --- a/qapi/qmp-dispatch.c +++ b/qapi/qmp-dispatch.c @@ -16,7 +16,7 @@ #include "block/aio.h" #include "qapi/compat-policy.h" #include "qapi/error.h" -#include "qapi/qmp/dispatch.h" +#include "qapi/qmp-registry.h" #include "qobject/qdict.h" #include "qobject/qjson.h" #include "qapi/qobject-input-visitor.h" diff --git a/qapi/qmp-registry.c b/qapi/qmp-registry.c index 485bc5e6fc..ac989074ed 100644 --- a/qapi/qmp-registry.c +++ b/qapi/qmp-registry.c @@ -13,7 +13,7 @@ */ #include "qemu/osdep.h" -#include "qapi/qmp/dispatch.h" +#include "qapi/qmp-registry.h" void qmp_register_command(QmpCommandList *cmds, const char *name, QmpCommandFunc *fn, QmpCommandOptions options, diff --git a/qga/guest-agent-core.h b/qga/guest-agent-core.h index b4e7c52c61..a536d07d0d 100644 --- a/qga/guest-agent-core.h +++ b/qga/guest-agent-core.h @@ -13,7 +13,7 @@ #ifndef GUEST_AGENT_CORE_H #define GUEST_AGENT_CORE_H -#include "qapi/qmp/dispatch.h" +#include "qapi/qmp-registry.h" #include "qga-qapi-types.h" #define QGA_READ_COUNT_DEFAULT 4096 diff --git a/scripts/qapi/commands.py b/scripts/qapi/commands.py index f0aa13b5cf..74f341b2c7 100644 --- a/scripts/qapi/commands.py +++ b/scripts/qapi/commands.py @@ -346,7 +346,7 @@ class QAPISchemaGenCommandVisitor(QAPISchemaModularCVisitor): def visit_begin(self, schema: QAPISchema) -> None: self._add_module('./init', ' * QAPI Commands initialization') self._genh.add(mcgen(''' -#include "qapi/qmp/dispatch.h" +#include "qapi/qmp-registry.h" void %(c_prefix)sqmp_init_marshal(QmpCommandList *cmds); ''', diff --git a/stubs/qmp-command-available.c b/stubs/qmp-command-available.c index 46540af7bf..8851faced1 100644 --- a/stubs/qmp-command-available.c +++ b/stubs/qmp-command-available.c @@ -1,5 +1,5 @@ #include "qemu/osdep.h" -#include "qapi/qmp/dispatch.h" +#include "qapi/qmp-registry.h" bool qmp_command_available(const QmpCommand *cmd, Error **errp) { diff --git a/stubs/qmp-quit.c b/stubs/qmp-quit.c index a3ff47f7bd..8fb523e905 100644 --- a/stubs/qmp-quit.c +++ b/stubs/qmp-quit.c @@ -1,6 +1,6 @@ #include "qemu/osdep.h" #include "qapi/qapi-commands-control.h" -#include "qapi/qmp/dispatch.h" +#include "qapi/qmp-registry.h" void qmp_quit(Error **errp) { diff --git a/system/qdev-monitor.c b/system/qdev-monitor.c index 81fe531bd6..856c9e8c32 100644 --- a/system/qdev-monitor.c +++ b/system/qdev-monitor.c @@ -26,7 +26,7 @@ #include "system/runstate.h" #include "qapi/error.h" #include "qapi/qapi-commands-qdev.h" -#include "qapi/qmp/dispatch.h" +#include "qapi/qmp-registry.h" #include "qobject/qdict.h" #include "qapi/qmp/qerror.h" #include "qobject/qstring.h"