All of lore.kernel.org
 help / color / mirror / Atom feed
* python/qemu/ too picky with QMP responses?
@ 2026-11-18  7:35 Markus Armbruster
  0 siblings, 0 replies; only message in thread
From: Markus Armbruster @ 2026-11-18  7:35 UTC (permalink / raw)
  To: John Snow, Cleber Rosa; +Cc: Marc-André Lureau, qemu-devel

Marc-André and I broke python/qemu/utils/qom_common.py in commit
0eee31cf1085 (qapi/qom: add qapi-type to qom-list, qom-list-properties,
qom-list-get):

    $ bld/run qom-list -s ../images/test-qmp /chardevs
    Traceback (most recent call last):
      File "/work/armbru/qemu/bld/pyvenv/bin/qom-list", line 8, in <module>
        sys.exit(QOMList.entry_point())
                 ~~~~~~~~~~~~~~~~~~~^^
      File "/work/armbru/qemu/python/qemu/utils/qom_common.py", line 230, in entry_point
        return cls.command_runner(args)
               ~~~~~~~~~~~~~~~~~~^^^^^^
      File "/work/armbru/qemu/python/qemu/utils/qom_common.py", line 215, in command_runner
        return cmd.run()
               ~~~~~~~^^
      File "/work/armbru/qemu/python/qemu/utils/qom.py", line 179, in run
        rsp = self.qom_list(self.path)
      File "/work/armbru/qemu/python/qemu/utils/qom_common.py", line 192, in qom_list
        return [ObjectPropertyInfo.make(x) for x in rsp]
                ~~~~~~~~~~~~~~~~~~~~~~~^^^
      File "/work/armbru/qemu/python/qemu/utils/qom_common.py", line 52, in make
        assert value.keys() <= {'name', 'type', 'description', 'default-value'}
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    AssertionError

Needs fixing for 11.2.  I can take care of it, but I have questions.

Here's what breaks:

    @classmethod
    def make(cls, value: Dict[str, Any]) -> 'ObjectPropertyInfo':
        """
        Build an ObjectPropertyInfo from a Dict with an unknown shape.
        """
        assert value.keys() >= {'name', 'type'}
--->    assert value.keys() <= {'name', 'type', 'description', 'default-value'}
        return cls(value['name'], value['type'],
                   value.get('description'),
                   value.get('default-value'))

The first assertion checks we got the members we actually require.

The second assertion checks we got no members we don't know.

The commit I quoted added member @qapi-type without updating the second
assertion.

Adding it to the set of members we know would be easy enough.  But is it
appropriate?  docs/devel/qapi-code-gen.rst section "Compatibility
considerations":

    Clients are expected to ignore [members] they don't know.

Shouldn't we do that here?

Any objections to me hunting down and deleting such assertions?


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2026-11-18  7:35 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-18  7:35 python/qemu/ too picky with QMP responses? Markus Armbruster

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.