diff options
author | John Snow <jsnow@redhat.com> | 2020-07-10 01:22:10 -0400 |
---|---|---|
committer | Philippe Mathieu-Daudé <philmd@redhat.com> | 2020-07-14 22:22:22 +0200 |
commit | 84dcdf0887cdaaba7300442482c99e5064865a2d (patch) | |
tree | 05de5aee0d27e60fd56b58f76ed491b683f11895 /python | |
parent | 2e2d93051753067fc5b888fdc18831127a4a900e (diff) |
python/qmp.py: add QMPProtocolError
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 <jsnow@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
Message-Id: <20200710052220.3306-7-jsnow@redhat.com>
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Diffstat (limited to 'python')
-rw-r--r-- | python/qemu/qmp.py | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/python/qemu/qmp.py b/python/qemu/qmp.py index 1ae36050a4..7935dababb 100644 --- a/python/qemu/qmp.py +++ b/python/qemu/qmp.py @@ -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): |