diff mbox series

[v5,8/8] qapi: New -compat deprecated-input=crash

Message ID 20200914084802.4185028-9-armbru@redhat.com
State New
Headers show
Series Configurable policy for handling deprecated interfaces | expand

Commit Message

Markus Armbruster Sept. 14, 2020, 8:48 a.m. UTC
Policy "crash" calls abort() when deprecated input is received.

Bugs in integration tests may mask the error from policy "reject".
Provide a larger hammer: crash outright.  Masking that seems unlikely.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
 qapi/compat.json             | 3 ++-
 qapi/qmp-dispatch.c          | 1 +
 qapi/qobject-input-visitor.c | 1 +
 qemu-options.hx              | 4 +++-
 4 files changed, 7 insertions(+), 2 deletions(-)

Comments

Eric Blake Sept. 14, 2020, 3:58 p.m. UTC | #1
On 9/14/20 3:48 AM, Markus Armbruster wrote:
> Policy "crash" calls abort() when deprecated input is received.
> 
> Bugs in integration tests may mask the error from policy "reject".
> Provide a larger hammer: crash outright.  Masking that seems unlikely.
> 
> Signed-off-by: Markus Armbruster <armbru@redhat.com>
> ---

> +++ b/qemu-options.hx
> @@ -3392,7 +3392,7 @@ DEFHEADING()
>   DEFHEADING(Debug/Expert options:)
>   
>   DEF("compat", HAS_ARG, QEMU_OPTION_compat,
> -    "-compat [deprecated-input=accept|reject][,deprecated-output=accept|hide]\n"
> +    "-compat [deprecated-input=accept|reject|crash][,deprecated-output=accept|hide]\n"
>       "                Policy for handling deprecated management interfaces\n",
>       QEMU_ARCH_ALL)
>   SRST
> @@ -3403,6 +3403,8 @@ SRST
>           Accept deprecated commands and arguments
>       ``deprecated-input=reject``
>           Reject deprecated commands and arguments
> +    ``deprecated-input=crash``
> +        Crash on deprecated command

Missing 'and arguments'?

Otherwise,
Reviewed-by: Eric Blake <eblake@redhat.com>
Markus Armbruster Sept. 21, 2020, 2:42 p.m. UTC | #2
Eric Blake <eblake@redhat.com> writes:

> On 9/14/20 3:48 AM, Markus Armbruster wrote:
>> Policy "crash" calls abort() when deprecated input is received.
>> Bugs in integration tests may mask the error from policy "reject".
>> Provide a larger hammer: crash outright.  Masking that seems unlikely.
>> Signed-off-by: Markus Armbruster <armbru@redhat.com>
>> ---
>
>> +++ b/qemu-options.hx
>> @@ -3392,7 +3392,7 @@ DEFHEADING()
>>   DEFHEADING(Debug/Expert options:)
>>     DEF("compat", HAS_ARG, QEMU_OPTION_compat,
>> -    "-compat [deprecated-input=accept|reject][,deprecated-output=accept|hide]\n"
>> +    "-compat [deprecated-input=accept|reject|crash][,deprecated-output=accept|hide]\n"
>>       "                Policy for handling deprecated management interfaces\n",
>>       QEMU_ARCH_ALL)
>>   SRST
>> @@ -3403,6 +3403,8 @@ SRST
>>           Accept deprecated commands and arguments
>>       ``deprecated-input=reject``
>>           Reject deprecated commands and arguments
>> +    ``deprecated-input=crash``
>> +        Crash on deprecated command
>
> Missing 'and arguments'?

Yes.

> Otherwise,
> Reviewed-by: Eric Blake <eblake@redhat.com>

Thanks!
diff mbox series

Patch

diff --git a/qapi/compat.json b/qapi/compat.json
index d2c02a21aa..936602dcc6 100644
--- a/qapi/compat.json
+++ b/qapi/compat.json
@@ -11,11 +11,12 @@ 
 #
 # @accept: Accept silently
 # @reject: Reject with an error
+# @crash: abort() the process
 #
 # Since: 5.2
 ##
 { 'enum': 'CompatPolicyInput',
-  'data': [ 'accept', 'reject' ] }
+  'data': [ 'accept', 'reject', 'crash' ] }
 
 ##
 # @CompatPolicyOutput:
diff --git a/qapi/qmp-dispatch.c b/qapi/qmp-dispatch.c
index 634e9c0a7d..9954894d95 100644
--- a/qapi/qmp-dispatch.c
+++ b/qapi/qmp-dispatch.c
@@ -139,6 +139,7 @@  QDict *qmp_dispatch(const QmpCommandList *cmds, QObject *request,
                       "Deprecated command %s disabled by policy",
                       command);
             goto out;
+        case COMPAT_POLICY_INPUT_CRASH:
         default:
             abort();
         }
diff --git a/qapi/qobject-input-visitor.c b/qapi/qobject-input-visitor.c
index 91e2d84ad2..d21ba0db8e 100644
--- a/qapi/qobject-input-visitor.c
+++ b/qapi/qobject-input-visitor.c
@@ -680,6 +680,7 @@  static bool qobject_input_deprecated_accept(Visitor *v, const char *name,
         error_setg(errp, "Deprecated parameter '%s' disabled by policy",
                    name);
         return false;
+    case COMPAT_POLICY_INPUT_CRASH:
     default:
         abort();
     }
diff --git a/qemu-options.hx b/qemu-options.hx
index bb0c6bb70e..f36d2073e5 100644
--- a/qemu-options.hx
+++ b/qemu-options.hx
@@ -3392,7 +3392,7 @@  DEFHEADING()
 DEFHEADING(Debug/Expert options:)
 
 DEF("compat", HAS_ARG, QEMU_OPTION_compat,
-    "-compat [deprecated-input=accept|reject][,deprecated-output=accept|hide]\n"
+    "-compat [deprecated-input=accept|reject|crash][,deprecated-output=accept|hide]\n"
     "                Policy for handling deprecated management interfaces\n",
     QEMU_ARCH_ALL)
 SRST
@@ -3403,6 +3403,8 @@  SRST
         Accept deprecated commands and arguments
     ``deprecated-input=reject``
         Reject deprecated commands and arguments
+    ``deprecated-input=crash``
+        Crash on deprecated command
     ``deprecated-output=accept`` (default)
         Emit deprecated command results and events
     ``deprecated-output=hide``