[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH 06/21] qmp: Drop duplicated QMP command object c
From: |
Eric Blake |
Subject: |
Re: [Qemu-devel] [PATCH 06/21] qmp: Drop duplicated QMP command object checks |
Date: |
Fri, 24 Feb 2017 17:03:54 -0600 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.7.0 |
On 02/23/2017 03:45 PM, Markus Armbruster wrote:
> qmp_check_input_obj() duplicates qmp_dispatch_check_obj(), except the
> latter screws up an error message. handle_qmp_command() runs first
> the former, then the latter via qmp_dispatch(), masking the screwup.
>
> qemu-ga also masks the screwup, because it also duplicates checks,
> just differently.
Cleaning up the duplication is a win in my book.
>
> qmp_check_input_obj() exists because handle_qmp_command() needs to
> examine the command before dispatching it. The previous commit got
> rid of this need, except for a tracepoint, and a bit of "id" code that
> relies on qdict not being null.
>
> Fix up the error message in qmp_dispatch_check_obj(), drop
> qmp_check_input_obj() and the tracepoint. Protect the "id" code with
> a conditional.
>
> Signed-off-by: Markus Armbruster <address@hidden>
> ---
> monitor.c | 74
> +++++------------------------------------------------
> qapi/qmp-dispatch.c | 3 +--
> trace-events | 1 -
> 3 files changed, 7 insertions(+), 71 deletions(-)
>
> diff --git a/monitor.c b/monitor.c
> index dcf2de7..d83888d 100644
> --- a/monitor.c
> +++ b/monitor.c
> @@ -3697,67 +3697,10 @@ static int monitor_can_read(void *opaque)
> return (mon->suspend_cnt == 0) ? 1 : 0;
> }
>
> -/*
> - * Input object checking rules
> - *
> - * 1. Input object must be a dict
> - * 2. The "execute" key must exist
> - * 3. The "execute" key must be a string
> - * 4. If the "arguments" key exists, it must be a dict
> - * 5. If the "id" key exists, it can be anything (ie. json-value)
> - * 6. Any argument not listed above is considered invalid
You know, with just a little tweak, we could add something to the .json
file, and let generated code do all the checks of even the top-level
entities:
{ 'struct': 'WireCommand',
'data': { 'execute': 'str', '*arguments': 'dict', '*id': 'any' } }
if we had a way to force 'dict' as a subset of 'any' but where it must
be a QDict. (If we had a 'dict' recognized by the QAPI code generators,
we could probably also fix 'object-add' to use '*props':'dict' instead
of its current use of 'any')
But that sounds like a bit much to ask for in the 2.9 timeframe, so it
doesn't hold up this patch.
We lose a trace, but I don't think that's fatal.
Reviewed-by: Eric Blake <address@hidden>
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
signature.asc
Description: OpenPGP digital signature
- Re: [Qemu-devel] [PATCH 08/21] qmp: Improve QMP dispatch error messages, (continued)
- [Qemu-devel] [PATCH 02/21] libqtest: Work around a "QMP wants a newline" bug, Markus Armbruster, 2017/02/23
- [Qemu-devel] [PATCH 05/21] qmp: Clean up how we enforce capability negotiation, Markus Armbruster, 2017/02/23
- [Qemu-devel] [PATCH 16/21] test-qobject-input-visitor: Use strict visitor, Markus Armbruster, 2017/02/23
- [Qemu-devel] [PATCH 07/21] qmp: Eliminate silly QERR_QMP_* macros, Markus Armbruster, 2017/02/23
- [Qemu-devel] [PATCH 06/21] qmp: Drop duplicated QMP command object checks, Markus Armbruster, 2017/02/23
- Re: [Qemu-devel] [PATCH 06/21] qmp: Drop duplicated QMP command object checks,
Eric Blake <=
- [Qemu-devel] [PATCH 20/21] qapi: Make input visitors detect unvisited list tails, Markus Armbruster, 2017/02/23
- [Qemu-devel] [PATCH 15/21] qom: Make object_property_set_qobject()'s input visitor strict, Markus Armbruster, 2017/02/23
- [Qemu-devel] [PATCH 19/21] tests: Cover partial input visit of list, Markus Armbruster, 2017/02/23
- [Qemu-devel] [PATCH 10/21] qapi: Clean up after commit 3d344c2, Markus Armbruster, 2017/02/23
- [Qemu-devel] [PATCH 13/21] qapi: Drop string input visitor method optional(), Markus Armbruster, 2017/02/23
- [Qemu-devel] [PATCH 21/21] qapi: Improve qobject visitor documentation, Markus Armbruster, 2017/02/23