Skip to content
  • Daniel P. Berrangé's avatar
    5c66d7d8
    python: support recording QMP session to a file · 5c66d7d8
    Daniel P. Berrangé authored
    
    
    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: default avatarPhilippe Mathieu-Daudé <f4bug@amsat.org>
    Signed-off-by: default avatarDaniel P. Berrangé <berrange@redhat.com>
    Message-id: 20220128161157.36261-3-berrange@redhat.com
    Signed-off-by: default avatarJohn Snow <jsnow@redhat.com>
    5c66d7d8
    python: support recording QMP session to a file
    Daniel P. Berrangé authored
    
    
    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: default avatarPhilippe Mathieu-Daudé <f4bug@amsat.org>
    Signed-off-by: default avatarDaniel P. Berrangé <berrange@redhat.com>
    Message-id: 20220128161157.36261-3-berrange@redhat.com
    Signed-off-by: default avatarJohn Snow <jsnow@redhat.com>
Loading