mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-05 16:53:55 -06:00
qapi: Implement deprecated-input=reject for QMP command arguments
This policy rejects deprecated input, and thus permits "testing the future". Implement it for QMP command arguments: reject commands with deprecated ones. Example: when QEMU is run with -compat deprecated-input=reject, then {"execute": "eject", "arguments": {"device": "cd"}} fails like this {"error": {"class": "GenericError", "desc": "Deprecated parameter 'device' disabled by policy"}} When the deprecated parameter is removed, the error will change to {"error": {"class": "GenericError", "desc": "Parameter 'device' is unexpected"}} Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Message-Id: <20210318155519.1224118-11-armbru@redhat.com>
This commit is contained in:
parent
d2032598c4
commit
db29164103
11 changed files with 101 additions and 2 deletions
|
@ -303,6 +303,29 @@ static void test_dispatch_cmd_deprecated(void)
|
|||
do_qmp_dispatch_error(false, ERROR_CLASS_COMMAND_NOT_FOUND, cmd);
|
||||
}
|
||||
|
||||
static void test_dispatch_cmd_arg_deprecated(void)
|
||||
{
|
||||
const char *cmd = "{ 'execute': 'test-features0',"
|
||||
" 'arguments': { 'fs1': { 'foo': 42 } } }";
|
||||
QDict *ret;
|
||||
|
||||
memset(&compat_policy, 0, sizeof(compat_policy));
|
||||
|
||||
/* accept */
|
||||
ret = qobject_to(QDict, do_qmp_dispatch(false, cmd));
|
||||
assert(ret && qdict_size(ret) == 1);
|
||||
qobject_unref(ret);
|
||||
|
||||
compat_policy.has_deprecated_input = true;
|
||||
compat_policy.deprecated_input = COMPAT_POLICY_INPUT_ACCEPT;
|
||||
ret = qobject_to(QDict, do_qmp_dispatch(false, cmd));
|
||||
assert(ret && qdict_size(ret) == 1);
|
||||
qobject_unref(ret);
|
||||
|
||||
compat_policy.deprecated_input = COMPAT_POLICY_INPUT_REJECT;
|
||||
do_qmp_dispatch_error(false, ERROR_CLASS_GENERIC_ERROR, cmd);
|
||||
}
|
||||
|
||||
static void test_dispatch_cmd_ret_deprecated(void)
|
||||
{
|
||||
const char *cmd = "{ 'execute': 'test-features0' }";
|
||||
|
@ -403,6 +426,8 @@ int main(int argc, char **argv)
|
|||
test_dispatch_cmd_success_response);
|
||||
g_test_add_func("/qmp/dispatch_cmd_deprecated",
|
||||
test_dispatch_cmd_deprecated);
|
||||
g_test_add_func("/qmp/dispatch_cmd_arg_deprecated",
|
||||
test_dispatch_cmd_arg_deprecated);
|
||||
g_test_add_func("/qmp/dispatch_cmd_ret_deprecated",
|
||||
test_dispatch_cmd_ret_deprecated);
|
||||
g_test_add_func("/qmp/dealloc_types", test_dealloc_types);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue