mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-07-27 20:33:54 -06:00
python/qemu/qtest: Check before accessing _qtest
It can be None; so add assertions or exceptions where appropriate to guard the access accordingly. Signed-off-by: John Snow <jsnow@redhat.com> Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> Message-Id: <20200514055403.18902-30-jsnow@redhat.com> Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
This commit is contained in:
parent
de210ec53c
commit
c95dddce49
1 changed files with 11 additions and 3 deletions
|
@ -121,7 +121,8 @@ class QEMUQtestMachine(QEMUMachine):
|
||||||
super()._pre_launch()
|
super()._pre_launch()
|
||||||
self._qtest = QEMUQtestProtocol(self._qtest_path, server=True)
|
self._qtest = QEMUQtestProtocol(self._qtest_path, server=True)
|
||||||
|
|
||||||
def _post_launch(self):
|
def _post_launch(self) -> None:
|
||||||
|
assert self._qtest is not None
|
||||||
super()._post_launch()
|
super()._post_launch()
|
||||||
self._qtest.accept()
|
self._qtest.accept()
|
||||||
|
|
||||||
|
@ -129,6 +130,13 @@ class QEMUQtestMachine(QEMUMachine):
|
||||||
super()._post_shutdown()
|
super()._post_shutdown()
|
||||||
self._remove_if_exists(self._qtest_path)
|
self._remove_if_exists(self._qtest_path)
|
||||||
|
|
||||||
def qtest(self, cmd):
|
def qtest(self, cmd: str) -> str:
|
||||||
'''Send a qtest command to guest'''
|
"""
|
||||||
|
Send a qtest command to the guest.
|
||||||
|
|
||||||
|
:param cmd: qtest command to send
|
||||||
|
:return: qtest server response
|
||||||
|
"""
|
||||||
|
if self._qtest is None:
|
||||||
|
raise RuntimeError("qtest socket not available")
|
||||||
return self._qtest.cmd(cmd)
|
return self._qtest.cmd(cmd)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue