qemu-commits
[Top][All Lists]
Advanced

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

[Qemu-commits] [qemu/qemu] 3e038d: qapi: Set boolean value correctly in


From: Peter Maydell
Subject: [Qemu-commits] [qemu/qemu] 3e038d: qapi: Set boolean value correctly in examples
Date: Sun, 05 Sep 2021 07:48:40 -0700

  Branch: refs/heads/master
  Home:   https://github.com/qemu/qemu
  Commit: 3e038d7d7a2616e12a07b08df6a9c9239ff7f228
      
https://github.com/qemu/qemu/commit/3e038d7d7a2616e12a07b08df6a9c9239ff7f228
  Author: Guoyi Tu <tugy@chinatelecom.cn>
  Date:   2021-09-03 (Fri, 03 Sep 2021)

  Changed paths:
    M qapi/trace.json

  Log Message:
  -----------
  qapi: Set boolean value correctly in examples

Signed-off-by: Guoyi Tu <tugy@chinatelecom.cn>
Message-Id: <a21a2b61-2653-a2c9-4478-715e5fb19120@chinatelecom.cn>
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>


  Commit: 1889e57a7140c4f89c8fd9a217f8c3845eb48b5b
      
https://github.com/qemu/qemu/commit/1889e57a7140c4f89c8fd9a217f8c3845eb48b5b
  Author: Markus Armbruster <armbru@redhat.com>
  Date:   2021-09-03 (Fri, 03 Sep 2021)

  Changed paths:
    M scripts/qapi/gen.py
    M scripts/qapi/introspect.py
    M scripts/qapi/schema.py
    M scripts/qapi/types.py
    M scripts/qapi/visit.py

  Log Message:
  -----------
  qapi: Simplify QAPISchemaIfCond's interface for generating C

QAPISchemaIfCond.cgen() is only ever used like

    gen_if(ifcond.cgen())

and

    gen_endif(ifcond.cgen())

Simplify to

    ifcond.gen_if()

and

    ifcond.gen_endif()

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Message-Id: <20210831123809.1107782-2-armbru@redhat.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
[Import statements tidied up with isort]


  Commit: e46c930cdd68a3911ec16bd89379891c5473dd06
      
https://github.com/qemu/qemu/commit/e46c930cdd68a3911ec16bd89379891c5473dd06
  Author: Markus Armbruster <armbru@redhat.com>
  Date:   2021-09-03 (Fri, 03 Sep 2021)

  Changed paths:
    M scripts/qapi/common.py
    M scripts/qapi/schema.py

  Log Message:
  -----------
  qapi: Simplify how QAPISchemaIfCond represents "no condition"

None works fine, there is no need to replace it by {} in .__init__().

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Message-Id: <20210831123809.1107782-3-armbru@redhat.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>


  Commit: cdcc04fa035025e706fb55b2a9e4843a54177ae4
      
https://github.com/qemu/qemu/commit/cdcc04fa035025e706fb55b2a9e4843a54177ae4
  Author: Markus Armbruster <armbru@redhat.com>
  Date:   2021-09-03 (Fri, 03 Sep 2021)

  Changed paths:
    M tests/qapi-schema/qapi-schema-test.json
    M tests/qapi-schema/qapi-schema-test.out

  Log Message:
  -----------
  tests/qapi-schema: Correct two 'if' conditionals

A definition's conditional should imply the conditionals of types it
uses.  If it doesn't, some configurations won't compile.

Example (from tests/qapi-schema/qapi-schema-test.json):

    { 'union': 'TestIfUnion', 'data':
      { 'foo': 'TestStruct',
        'bar': { 'type': 'str', 'if': 'TEST_IF_UNION_BAR'} },
      'if': { 'all': ['TEST_IF_UNION', 'TEST_IF_STRUCT'] } }

    { 'command': 'test-if-union-cmd',
      'data': { 'union-cmd-arg': 'TestIfUnion' },
      'if': 'TEST_IF_UNION' }

generates

    #if (defined(TEST_IF_UNION)) && (defined(TEST_IF_STRUCT))
    typedef struct TestIfUnion TestIfUnion;
    #endif /* (defined(TEST_IF_UNION)) && (defined(TEST_IF_STRUCT)) */

and

    #if defined(TEST_IF_UNION)
    void qmp_test_if_union_cmd(TestIfUnion *union_cmd_arg, Error **errp);
    void qmp_marshal_test_if_union_cmd(QDict *args, QObject **ret, Error 
**errp);
    #endif /* defined(TEST_IF_UNION) */

which doesn't compile when !defined(TEST_IF_STRUCT).

Messed up in f8c4fdd6ae "tests/qapi: Cover commands with 'if' and
union / alternate 'data'", v4.0.0.  Harmless, as we don't actually use
this configuration.  Correct it anyway, along with another instance.

This loses coverage for 'not'.  The next commit will bring it back.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Message-Id: <20210831123809.1107782-4-armbru@redhat.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>


  Commit: dd044023e6c1000e384c511e2d8f4c9d1a2a3e91
      
https://github.com/qemu/qemu/commit/dd044023e6c1000e384c511e2d8f4c9d1a2a3e91
  Author: Markus Armbruster <armbru@redhat.com>
  Date:   2021-09-03 (Fri, 03 Sep 2021)

  Changed paths:
    M tests/qapi-schema/doc-good.json
    M tests/qapi-schema/doc-good.out
    M tests/qapi-schema/doc-good.txt
    M tests/qapi-schema/qapi-schema-test.json
    M tests/qapi-schema/qapi-schema-test.out

  Log Message:
  -----------
  tests/qapi-schema: Demonstrate broken C code for 'if'

The C code generated for 'if' conditionals is incorrectly
parenthesized.  For instance,

    'if': { 'not': { 'any': [ { 'not': 'TEST_IF_EVT' },
                              { 'not': 'TEST_IF_STRUCT' } ] } } }

generates

    #if !(!defined(TEST_IF_EVT)) || (!defined(TEST_IF_STRUCT))

This is wrong.  Correct would be:

    #if !(!defined(TEST_IF_EVT) || !defined(TEST_IF_STRUCT))

Cover the issue in qapi-schema-test.json.  This generates bad #if in
tests/test-qapi-events.h and other files.

Add a similar condition to doc-good.json.  The generated documentation
is fine.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Message-Id: <20210831123809.1107782-5-armbru@redhat.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>


  Commit: 82ca72c023b42ee4061e092fd9d4750c756c0475
      
https://github.com/qemu/qemu/commit/82ca72c023b42ee4061e092fd9d4750c756c0475
  Author: Markus Armbruster <armbru@redhat.com>
  Date:   2021-09-03 (Fri, 03 Sep 2021)

  Changed paths:
    M scripts/qapi/common.py
    M tests/qapi-schema/qapi-schema-test.json

  Log Message:
  -----------
  qapi: Fix C code generation for 'if'

When commit 5d83b9a130 "qapi: replace if condition list with dict
{'all': [...]}" made cgen_ifcond() and docgen_ifcond() recursive, it
messed up parenthesises in the former, and got them right in the
latter, as the previous commit demonstrates.

To fix, adopt the latter's working code for the former.  This
generates the correct code from the previous commit's commit message.

Fixes: 5d83b9a130690f879d5f33e991beabe69cb88bc8
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Message-Id: <20210831123809.1107782-6-armbru@redhat.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>


  Commit: ccea6a8637a08585433aa04ce2a25480f205afff
      
https://github.com/qemu/qemu/commit/ccea6a8637a08585433aa04ce2a25480f205afff
  Author: Markus Armbruster <armbru@redhat.com>
  Date:   2021-09-03 (Fri, 03 Sep 2021)

  Changed paths:
    M scripts/qapi/common.py

  Log Message:
  -----------
  qapi: Factor common recursion out of cgen_ifcond(), docgen_ifcond()

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Message-Id: <20210831123809.1107782-7-armbru@redhat.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>


  Commit: a7987799d1373d2408565d09823946ec28df4521
      
https://github.com/qemu/qemu/commit/a7987799d1373d2408565d09823946ec28df4521
  Author: Markus Armbruster <armbru@redhat.com>
  Date:   2021-09-03 (Fri, 03 Sep 2021)

  Changed paths:
    M scripts/qapi/common.py
    M tests/qapi-schema/doc-good.txt

  Log Message:
  -----------
  qapi: Avoid redundant parens in code generated for conditionals

Commit 6cc2e4817f "qapi: introduce QAPISchemaIfCond.cgen()" caused a
minor regression: redundant parenthesis.  Subsequent commits
eliminated of many of them, but not all.  Get rid of the rest now.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Message-Id: <20210831123809.1107782-8-armbru@redhat.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>


  Commit: d0830ee443f2e27b62c40c9ac2d20b19c399ca4b
      
https://github.com/qemu/qemu/commit/d0830ee443f2e27b62c40c9ac2d20b19c399ca4b
  Author: Markus Armbruster <armbru@redhat.com>
  Date:   2021-09-03 (Fri, 03 Sep 2021)

  Changed paths:
    M scripts/qapi/common.py
    M tests/qapi-schema/doc-good.txt

  Log Message:
  -----------
  qapi: Use "not COND" instead of "!COND" for generated documentation

Generated documentation uses operators "and", "or", and "!".  Change
the latter to "not".

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Message-Id: <20210831123809.1107782-9-armbru@redhat.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>


  Commit: 555dd1aaa6b654d0ad62da9660c32835ab493678
      
https://github.com/qemu/qemu/commit/555dd1aaa6b654d0ad62da9660c32835ab493678
  Author: Markus Armbruster <armbru@redhat.com>
  Date:   2021-09-03 (Fri, 03 Sep 2021)

  Changed paths:
    M scripts/qapi/expr.py

  Log Message:
  -----------
  qapi: Use re.fullmatch() where appropriate

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Message-Id: <20210831123809.1107782-10-armbru@redhat.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>


  Commit: 9c629fa8340792cd30758b65f0593d93d7a383d7
      
https://github.com/qemu/qemu/commit/9c629fa8340792cd30758b65f0593d93d7a383d7
  Author: Markus Armbruster <armbru@redhat.com>
  Date:   2021-09-03 (Fri, 03 Sep 2021)

  Changed paths:
    M tests/qapi-schema/doc-good.out
    M tests/qapi-schema/qapi-schema-test.out
    M tests/qapi-schema/test-qapi.py

  Log Message:
  -----------
  tests/qapi-schema: Hide OrderedDict in test output

Since commit 5d83b9a130 "qapi: replace if condition list with dict
{'all': [...]}", we represent if conditionals as trees consisting of
OrderedDict, list and str.  This results in less than legible test
output.  For instance:

    if OrderedDict([('not', OrderedDict([('any', [OrderedDict([('not', 
'TEST_IF_EVT')]), OrderedDict([('not', 'TEST_IF_STRUCT')])])]))])

We intend to replace OrderedDict by dict when we get Python 3.7, which
will result in more legible output:

    if {'not': {'any': [{'not': 'TEST_IF_EVT'}, {'not': 'TEST_IF_STRUCT'}]}}

Can't wait: put in a hack to get that now, with a comment to revert it
when we replace OrderedDict.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Message-Id: <20210831123809.1107782-11-armbru@redhat.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>


  Commit: 6dcf03719acc4db6db7dc307359ff67d05e74451
      
https://github.com/qemu/qemu/commit/6dcf03719acc4db6db7dc307359ff67d05e74451
  Author: Markus Armbruster <armbru@redhat.com>
  Date:   2021-09-03 (Fri, 03 Sep 2021)

  Changed paths:
    M scripts/qapi/expr.py
    M tests/qapi-schema/double-type.err
    M tests/qapi-schema/missing-type.err

  Log Message:
  -----------
  qapi: Tweak error messages for missing / conflicting meta-type

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Message-Id: <20210831123809.1107782-12-armbru@redhat.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>


  Commit: 34f7b25e575a93182b7c0a3558caac34e26227cf
      
https://github.com/qemu/qemu/commit/34f7b25e575a93182b7c0a3558caac34e26227cf
  Author: Markus Armbruster <armbru@redhat.com>
  Date:   2021-09-03 (Fri, 03 Sep 2021)

  Changed paths:
    M scripts/qapi/expr.py
    M tests/qapi-schema/bad-if-key.err
    M tests/qapi-schema/bad-if-keys.err
    M tests/qapi-schema/enum-if-invalid.err

  Log Message:
  -----------
  qapi: Tweak error messages for unknown / conflicting 'if' keys

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Message-Id: <20210831123809.1107782-13-armbru@redhat.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>


  Commit: 31ebff513fad11f315377f6b07447169be8d9f86
      
https://github.com/qemu/qemu/commit/31ebff513fad11f315377f6b07447169be8d9f86
  Author: Peter Maydell <peter.maydell@linaro.org>
  Date:   2021-09-04 (Sat, 04 Sep 2021)

  Changed paths:
    M qapi/trace.json
    M scripts/qapi/common.py
    M scripts/qapi/expr.py
    M scripts/qapi/gen.py
    M scripts/qapi/introspect.py
    M scripts/qapi/schema.py
    M scripts/qapi/types.py
    M scripts/qapi/visit.py
    M tests/qapi-schema/bad-if-key.err
    M tests/qapi-schema/bad-if-keys.err
    M tests/qapi-schema/doc-good.json
    M tests/qapi-schema/doc-good.out
    M tests/qapi-schema/doc-good.txt
    M tests/qapi-schema/double-type.err
    M tests/qapi-schema/enum-if-invalid.err
    M tests/qapi-schema/missing-type.err
    M tests/qapi-schema/qapi-schema-test.json
    M tests/qapi-schema/qapi-schema-test.out
    M tests/qapi-schema/test-qapi.py

  Log Message:
  -----------
  Merge remote-tracking branch 'remotes/armbru/tags/pull-qapi-2021-09-03' into 
staging

QAPI patches patches for 2021-09-03

# gpg: Signature made Fri 03 Sep 2021 16:20:49 BST
# gpg:                using RSA key 354BC8B3D7EB2A6B68674E5F3870B400EB918653
# gpg:                issuer "armbru@redhat.com"
# gpg: Good signature from "Markus Armbruster <armbru@redhat.com>" [full]
# gpg:                 aka "Markus Armbruster <armbru@pond.sub.org>" [full]
# Primary key fingerprint: 354B C8B3 D7EB 2A6B 6867  4E5F 3870 B400 EB91 8653

* remotes/armbru/tags/pull-qapi-2021-09-03:
  qapi: Tweak error messages for unknown / conflicting 'if' keys
  qapi: Tweak error messages for missing / conflicting meta-type
  tests/qapi-schema: Hide OrderedDict in test output
  qapi: Use re.fullmatch() where appropriate
  qapi: Use "not COND" instead of "!COND" for generated documentation
  qapi: Avoid redundant parens in code generated for conditionals
  qapi: Factor common recursion out of cgen_ifcond(), docgen_ifcond()
  qapi: Fix C code generation for 'if'
  tests/qapi-schema: Demonstrate broken C code for 'if'
  tests/qapi-schema: Correct two 'if' conditionals
  qapi: Simplify how QAPISchemaIfCond represents "no condition"
  qapi: Simplify QAPISchemaIfCond's interface for generating C
  qapi: Set boolean value correctly in examples

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>


Compare: https://github.com/qemu/qemu/compare/9c03aa87e525...31ebff513fad



reply via email to

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