[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 01/27] qmp-dispatch: Use CommandNotFound error for disabled comman
From: |
Markus Armbruster |
Subject: |
[PULL 01/27] qmp-dispatch: Use CommandNotFound error for disabled commands |
Date: |
Sat, 28 Sep 2019 20:39:08 +0200 |
From: Michal Privoznik <address@hidden>
If a command is disabled an error is reported. But due to usage of
error_setg() the class of the error is GenericError which does not
help callers in distinguishing this case from a case where a qmp
command fails regularly due to other reasons.
We used to use class CommandDisabled until the great error
simplification (commit de253f1491 for QMP and commit 93b91c59db for
qemu-ga, both v1.2.0).
Use CommandNotFound error class, which is close enough.
Signed-off-by: Michal Privoznik <address@hidden>
Message-Id: <address@hidden>
Reviewed-by: Eric Blake <address@hidden>
[Test update squashed in, commit message tweaked]
Signed-off-by: Markus Armbruster <address@hidden>
---
qapi/qmp-dispatch.c | 5 +++--
tests/test-qga.c | 4 ++--
2 files changed, 5 insertions(+), 4 deletions(-)
diff --git a/qapi/qmp-dispatch.c b/qapi/qmp-dispatch.c
index 3037d353a4..bc264b3c9b 100644
--- a/qapi/qmp-dispatch.c
+++ b/qapi/qmp-dispatch.c
@@ -104,8 +104,9 @@ static QObject *do_qmp_dispatch(QmpCommandList *cmds,
QObject *request,
return NULL;
}
if (!cmd->enabled) {
- error_setg(errp, "The command %s has been disabled for this instance",
- command);
+ error_set(errp, ERROR_CLASS_COMMAND_NOT_FOUND,
+ "The command %s has been disabled for this instance",
+ command);
return NULL;
}
if (oob && !(cmd->options & QCO_ALLOW_OOB)) {
diff --git a/tests/test-qga.c b/tests/test-qga.c
index 891aa3d322..1ca49bbced 100644
--- a/tests/test-qga.c
+++ b/tests/test-qga.c
@@ -668,7 +668,7 @@ static void test_qga_blacklist(gconstpointer data)
error = qdict_get_qdict(ret, "error");
class = qdict_get_try_str(error, "class");
desc = qdict_get_try_str(error, "desc");
- g_assert_cmpstr(class, ==, "GenericError");
+ g_assert_cmpstr(class, ==, "CommandNotFound");
g_assert_nonnull(g_strstr_len(desc, -1, "has been disabled"));
qobject_unref(ret);
@@ -677,7 +677,7 @@ static void test_qga_blacklist(gconstpointer data)
error = qdict_get_qdict(ret, "error");
class = qdict_get_try_str(error, "class");
desc = qdict_get_try_str(error, "desc");
- g_assert_cmpstr(class, ==, "GenericError");
+ g_assert_cmpstr(class, ==, "CommandNotFound");
g_assert_nonnull(g_strstr_len(desc, -1, "has been disabled"));
qobject_unref(ret);
--
2.21.0
- [PULL 00/27] QAPI patches for 2019-09-28, Markus Armbruster, 2019/09/28
- [PULL 01/27] qmp-dispatch: Use CommandNotFound error for disabled commands,
Markus Armbruster <=
- [PULL 02/27] qapi: Tighten QAPISchemaFOO.check() assertions, Markus Armbruster, 2019/09/28
- [PULL 14/27] qapi: Make check_type()'s array case a bit more obvious, Markus Armbruster, 2019/09/28
- [PULL 11/27] qapi: Use check_name_str() where it suffices, Markus Armbruster, 2019/09/28
- [PULL 13/27] qapi: Move check for reserved names out of add_name(), Markus Armbruster, 2019/09/28
- [PULL 10/27] qapi: Improve reporting of invalid name errors, Markus Armbruster, 2019/09/28
- [PULL 27/27] qapi: Improve source file read error handling, Markus Armbruster, 2019/09/28
- [PULL 19/27] qapi: Improve reporting of invalid 'if' errors, Markus Armbruster, 2019/09/28
- [PULL 20/27] qapi: Improve reporting of invalid flags, Markus Armbruster, 2019/09/28
- [PULL 18/27] qapi: Move context-free checking to the proper place, Markus Armbruster, 2019/09/28
- [PULL 24/27] qapi: Eliminate check_keys(), rename check_known_keys(), Markus Armbruster, 2019/09/28