[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH v2] target/mips: implement QMP query-cpu-definit

From: Markus Armbruster
Subject: Re: [Qemu-devel] [PATCH v2] target/mips: implement QMP query-cpu-definitions command
Date: Wed, 20 Feb 2019 04:56:08 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux)

Eric Blake <address@hidden> writes:

> On 2/19/19 1:15 PM, Aleksandar Markovic wrote:
>> From: Pavel Dovgalyuk <address@hidden>
>> This patch enables QMP-based querying of the available CPU types for
>> MIPS and MIPS64 platforms.
>> Signed-off-by: Pavel Dovgalyuk <address@hidden>
>> Signed-off-by: Aleksandar Markovic <address@hidden>
>> Reviewed-by: Philippe Mathieu-Daudé <address@hidden>
>> Tested-by: Philippe Mathieu-Daudé <address@hidden>
>> ---
>> +++ b/qapi/target.json
>> @@ -499,7 +499,7 @@
>>              'static': 'bool',
>>              '*unavailable-features': [ 'str' ],
>>              'typename': 'str' },
>> -  'if': 'defined(TARGET_PPC) || defined(TARGET_ARM) || defined(TARGET_I386) 
>> || defined(TARGET_S390X)' }
>> +  'if': 'defined(TARGET_PPC) || defined(TARGET_ARM) || defined(TARGET_I386) 
>> || defined(TARGET_S390X) || defined(TARGET_MIPS)' }
> Hmm. Long line; however, the argument to 'if' is pasted literally to an
> #if directive, which would break if we added newlines in the middle.
> And we can't use literal newlines in the middle of a JSON string.  About
> the only thing I could think of that might allow for more manageable
> line lengths would be permitting:
> 'if': [ 'defined(TARGET_PPC)',
>         'defined(TARGET_ARM)' ...]
> where the QAPI generator would in turn form the disjunction of supplying
> the || between each term when the 'if' is an array of strings. But that
> feels like a lot of effort for little gain compared to just living with
> the long lines.

I hate long lines as much as anyone, but we already burned the list
syntax on conjunction:


    === Configuring the schema ===

    The 'struct', 'enum', 'union', 'alternate', 'command' and 'event'
    top-level expressions can take an 'if' key.  Its value must be a string
    or a list of strings.  A string is shorthand for a list containing just
    that string.  The code generated for the top-level expression will then
    be guarded by #if COND for each COND in the list.

    Example: a conditional struct

     { 'struct': 'IfStruct', 'data': { 'foo': 'int' },
       'if': ['defined(CONFIG_FOO)', 'defined(HAVE_BAR)'] }

    gets its generated code guarded like this:

     #if defined(CONFIG_FOO)
     #if defined(HAVE_BAR)
     ... generated code ...
     #endif /* defined(HAVE_BAR) */
     #endif /* defined(CONFIG_FOO) */

The problem of long strings requiring long lines is not limited to 'if'.
The common solution in programming languages is to concatenate adjacent
string literals.  A more user-friendly QAPI language would support
something like that.  By choosing JSON, a language designed "for the
serialization of structured data" (RFC 4627, 7159, 8259), we opted
against user-friendly.  We then admitted our regrets halfheartedly by
making our version of JSON incompatible enough to defeat tools like
javascript-mode.  Correcting our fundamental mistake now would be a lot
of churn.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]