qemu-e2k/python/qemu/aqmp
Daniel P. Berrangé 5c66d7d8de python: support recording QMP session to a file
When running QMP commands with very large response payloads, it is often
not easy to spot the info you want. If we can save the response to a
file then tools like 'grep' or 'jq' can be used to extract information.

For convenience of processing, we merge the QMP command and response
dictionaries together:

  {
      "arguments": {},
      "execute": "query-kvm",
      "return": {
          "enabled": false,
          "present": true
      }
  }

Example usage

  $ ./scripts/qmp/qmp-shell-wrap -l q.log -p -- ./build/qemu-system-x86_64 -display none
  Welcome to the QMP low-level shell!
  Connected
  (QEMU) query-kvm
  {
      "return": {
          "enabled": false,
          "present": true
      }
  }
  (QEMU) query-mice
  {
      "return": [
          {
              "absolute": false,
              "current": true,
              "index": 2,
              "name": "QEMU PS/2 Mouse"
          }
      ]
  }

 $ jq --slurp '. | to_entries[] | select(.value.execute == "query-kvm") |
               .value.return.enabled' < q.log
   false

Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
Message-id: 20220128161157.36261-3-berrange@redhat.com
Signed-off-by: John Snow <jsnow@redhat.com>
2022-02-23 17:07:26 -05:00
..
__init__.py python/aqmp: rename AQMPError to QMPError 2022-01-21 16:01:31 -05:00
aqmp_tui.py python/aqmp: use absolute import statement 2022-01-10 18:22:33 -05:00
error.py python/aqmp: rename AQMPError to QMPError 2022-01-21 16:01:31 -05:00
events.py python/aqmp: rename AQMPError to QMPError 2022-01-21 16:01:31 -05:00
legacy.py python/aqmp: add socket bind step to legacy.py 2022-02-02 14:12:22 -05:00
message.py python/aqmp: add QMP Message format 2021-09-27 12:10:29 -04:00
models.py python/aqmp: Add dict conversion method to Greeting object 2021-10-12 12:22:10 -04:00
protocol.py python/aqmp: add socket bind step to legacy.py 2022-02-02 14:12:22 -05:00
py.typed python/aqmp: add asynchronous QMP (AQMP) subpackage 2021-09-27 12:10:27 -04:00
qmp_client.py python/aqmp: Fix negotiation with pre-"oob" QEMU 2022-02-02 14:12:22 -05:00
qmp_shell.py python: support recording QMP session to a file 2022-02-23 17:07:26 -05:00
util.py python/aqmp: add asyncio_run compatibility wrapper 2021-09-27 12:10:29 -04:00