[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 17/25] python/qemu/qtest: Check before accessing _qtest
From: |
Philippe Mathieu-Daudé |
Subject: |
[PULL 17/25] python/qemu/qtest: Check before accessing _qtest |
Date: |
Sun, 31 May 2020 18:38:38 +0200 |
From: John Snow <jsnow@redhat.com>
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>
---
python/qemu/qtest.py | 14 +++++++++++---
1 file changed, 11 insertions(+), 3 deletions(-)
diff --git a/python/qemu/qtest.py b/python/qemu/qtest.py
index 4c88590eb0..888c8bd2f6 100644
--- a/python/qemu/qtest.py
+++ b/python/qemu/qtest.py
@@ -121,7 +121,8 @@ def _pre_launch(self):
super()._pre_launch()
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()
self._qtest.accept()
@@ -129,6 +130,13 @@ def _post_shutdown(self):
super()._post_shutdown()
self._remove_if_exists(self._qtest_path)
- def qtest(self, cmd):
- '''Send a qtest command to guest'''
+ def qtest(self, cmd: str) -> str:
+ """
+ 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)
--
2.21.3
- [PULL 07/25] python: remove more instances of sys.version_info, (continued)
- [PULL 07/25] python: remove more instances of sys.version_info, Philippe Mathieu-Daudé, 2020/05/31
- [PULL 08/25] python/qemu/machine: add kill() method, Philippe Mathieu-Daudé, 2020/05/31
- [PULL 09/25] python/qemu/machine: remove logging configuration, Philippe Mathieu-Daudé, 2020/05/31
- [PULL 10/25] python/qemu: delint and add pylintrc, Philippe Mathieu-Daudé, 2020/05/31
- [PULL 11/25] python/qemu: delint; add flake8 config, Philippe Mathieu-Daudé, 2020/05/31
- [PULL 12/25] python/qemu: remove Python2 style super() calls, Philippe Mathieu-Daudé, 2020/05/31
- [PULL 13/25] python/qemu: fix socket.makefile() typing, Philippe Mathieu-Daudé, 2020/05/31
- [PULL 14/25] python/qemu: Adjust traceback typing, Philippe Mathieu-Daudé, 2020/05/31
- [PULL 15/25] python/qemu/qmp: use True/False for non/blocking modes, Philippe Mathieu-Daudé, 2020/05/31
- [PULL 16/25] python/qemu/qmp: assert sockfile is not None, Philippe Mathieu-Daudé, 2020/05/31
- [PULL 17/25] python/qemu/qtest: Check before accessing _qtest,
Philippe Mathieu-Daudé <=
- [PULL 18/25] tests/vm: Pass --debug through for vm-boot-ssh, Philippe Mathieu-Daudé, 2020/05/31
- [PULL 19/25] tests/vm: Add ability to select QEMU from current build, Philippe Mathieu-Daudé, 2020/05/31
- [PULL 20/25] tests/vm: allow wait_ssh() to specify command, Philippe Mathieu-Daudé, 2020/05/31
- [PULL 21/25] tests/migration/guestperf: Use Python 3 interpreter, Philippe Mathieu-Daudé, 2020/05/31
- [PULL 22/25] tests/acceptance/migration.py: Wait for both sides, Philippe Mathieu-Daudé, 2020/05/31
- [PULL 23/25] tests/acceptance: allow console interaction with specific VMs, Philippe Mathieu-Daudé, 2020/05/31
- [PULL 24/25] tests/acceptance: refactor boot_linux_console test to allow code reuse, Philippe Mathieu-Daudé, 2020/05/31
- [PULL 25/25] tests/acceptance: refactor boot_linux to allow code reuse, Philippe Mathieu-Daudé, 2020/05/31