]> Git Repo - qemu.git/commitdiff
python/qmp.py: add QMPProtocolError
authorJohn Snow <[email protected]>
Fri, 10 Jul 2020 05:22:10 +0000 (01:22 -0400)
committerPhilippe Mathieu-Daudé <[email protected]>
Tue, 14 Jul 2020 20:22:22 +0000 (22:22 +0200)
In the case that we receive a reply but are unable to understand it,
use this exception name to indicate that case.

Signed-off-by: John Snow <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Kevin Wolf <[email protected]>
Message-Id: <20200710052220[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
python/qemu/qmp.py

index 1ae36050a42841b76c4159eff55813425254e7f8..7935dababbf62b4d025f3ce6c1e010d95c8badd6 100644 (file)
@@ -62,6 +62,12 @@ class QMPTimeoutError(QMPError):
     """
 
 
+class QMPProtocolError(QMPError):
+    """
+    QMP protocol error; unexpected response
+    """
+
+
 class QMPResponseError(QMPError):
     """
     Represents erroneous QMP monitor reply
@@ -266,6 +272,10 @@ class QEMUMonitorProtocol:
         ret = self.cmd(cmd, kwds)
         if 'error' in ret:
             raise QMPResponseError(ret)
+        if 'return' not in ret:
+            raise QMPProtocolError(
+                "'return' key not found in QMP response '{}'".format(str(ret))
+            )
         return cast(QMPReturnValue, ret['return'])
 
     def pull_event(self, wait=False):
This page took 0.028761 seconds and 4 git commands to generate.