[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 19/21] Monitor: Audit handler return
From: |
Luiz Capitulino |
Subject: |
[Qemu-devel] [PATCH 19/21] Monitor: Audit handler return |
Date: |
Wed, 10 Feb 2010 23:50:05 -0200 |
This commit verifies the following two rules specified by
Markus Armbruster:
1. If the handler returns failure, it must have passed an error.
If it didn't, it's broken. Report an internal error to the client,
and report the bug to the programmer.
2. If the handler returns success, it must not have passed an error.
If it did, it's broken. Report the error to the client, and report
the bug to the programmer.
Signed-off-by: Luiz Capitulino <address@hidden>
---
monitor.c | 32 +++++++++++++++++++++++++++++++-
1 files changed, 31 insertions(+), 1 deletions(-)
diff --git a/monitor.c b/monitor.c
index d5b406c..2f43136 100644
--- a/monitor.c
+++ b/monitor.c
@@ -3848,12 +3848,42 @@ static int is_async_return(const QObject *data)
return 0;
}
+static void handler_audit(Monitor *mon, const mon_cmd_t *cmd, int ret)
+{
+ if (ret && !monitor_has_error(mon)) {
+ /*
+ * If it returns failure, it must have passed on error.
+ *
+ * Action: Report an internal error to the client if in QMP.
+ */
+ if (monitor_ctrl_mode(mon)) {
+ qemu_error_new(QERR_UNDEFINED_ERROR);
+ }
+ MON_DEBUG("command '%s' returned failure but did not pass an error\n",
+ cmd->name);
+ }
+
+#ifdef CONFIG_DEBUG_MONITOR
+ if (!ret && monitor_has_error(mon)) {
+ /*
+ * If it returns success, it must not have passed an error.
+ *
+ * Action: Report the passed error to the client.
+ */
+ MON_DEBUG("command '%s' returned success but passed an error\n",
+ cmd->name);
+ }
+#endif
+}
+
static void monitor_call_handler(Monitor *mon, const mon_cmd_t *cmd,
const QDict *params)
{
+ int ret;
QObject *data = NULL;
- cmd->mhandler.cmd_new(mon, params, &data);
+ ret = cmd->mhandler.cmd_new(mon, params, &data);
+ handler_audit(mon, cmd, ret);
if (is_async_return(data)) {
/*
--
1.6.6
- [Qemu-devel] [PATCH 09/21] Monitor: Convert pci_device_hot_add() to cmd_new_ret(), (continued)
- [Qemu-devel] [PATCH 09/21] Monitor: Convert pci_device_hot_add() to cmd_new_ret(), Luiz Capitulino, 2010/02/10
- [Qemu-devel] [PATCH 10/21] Monitor: Convert pci_device_hot_remove() to cmd_new_ret(), Luiz Capitulino, 2010/02/10
- [Qemu-devel] [PATCH 11/21] Monitor: Convert do_migrate() to cmd_new_ret(), Luiz Capitulino, 2010/02/10
- [Qemu-devel] [PATCH 12/21] Monitor: Convert do_memory_save() to cmd_new_ret(), Luiz Capitulino, 2010/02/10
- [Qemu-devel] [PATCH 13/21] Monitor: Convert do_physical_memory_save() to cmd_new_ret(), Luiz Capitulino, 2010/02/10
- [Qemu-devel] [PATCH 14/21] Monitor: Convert do_info() to cmd_new_ret(), Luiz Capitulino, 2010/02/10
- [Qemu-devel] [PATCH 15/21] Monitor: Convert do_change() to cmd_new_ret(), Luiz Capitulino, 2010/02/10
- [Qemu-devel] [PATCH 16/21] Monitor: Rename cmd_new_ret(), Luiz Capitulino, 2010/02/10
- [Qemu-devel] [PATCH 17/21] Monitor: Debugging support, Luiz Capitulino, 2010/02/10
- [Qemu-devel] [PATCH 18/21] Monitor: Drop the print disabling mechanism, Luiz Capitulino, 2010/02/10
- [Qemu-devel] [PATCH 19/21] Monitor: Audit handler return,
Luiz Capitulino <=
- [Qemu-devel] [PATCH 20/21] Monitor: Debug stray prints the right way, Luiz Capitulino, 2010/02/10
- [Qemu-devel] [PATCH 21/21] Monitor: Report more than one error in handlers, Luiz Capitulino, 2010/02/10
- Re: [Qemu-devel] [PATCH v0 00/21]: Monitor: improve handlers error handling, Markus Armbruster, 2010/02/11
- Re: [Qemu-devel] [PATCH v0 00/21]: Monitor: improve handlers error handling, Anthony Liguori, 2010/02/11