diff mbox series

[RFC,v2,01/11] python: qemu: add timer parameter for qmp.accept socket

Message ID 20210407135021.48330-2-eesposit@redhat.com (mailing list archive)
State New, archived
Headers show
Series qemu_iotests: improve debugging options | expand

Commit Message

Emanuele Giuseppe Esposito April 7, 2021, 1:50 p.m. UTC
Extend the _post_launch function to include the timer as
parameter instead of defaulting to 15 sec.

Signed-off-by: Emanuele Giuseppe Esposito <eesposit@redhat.com>
---
 python/qemu/machine.py | 4 ++--
 python/qemu/qtest.py   | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

Comments

John Snow April 8, 2021, 7:51 p.m. UTC | #1
On 4/7/21 9:50 AM, Emanuele Giuseppe Esposito wrote:
> Extend the _post_launch function to include the timer as
> parameter instead of defaulting to 15 sec.
> 
> Signed-off-by: Emanuele Giuseppe Esposito <eesposit@redhat.com>
> ---
>   python/qemu/machine.py | 4 ++--
>   python/qemu/qtest.py   | 4 ++--
>   2 files changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/python/qemu/machine.py b/python/qemu/machine.py
> index 6e44bda337..c721e07d63 100644
> --- a/python/qemu/machine.py
> +++ b/python/qemu/machine.py
> @@ -321,9 +321,9 @@ def _pre_launch(self) -> None:
>                   nickname=self._name
>               )
>   
> -    def _post_launch(self) -> None:
> +    def _post_launch(self, timer) -> None:
>           if self._qmp_connection:
> -            self._qmp.accept()
> +            self._qmp.accept(timer)
>   
>       def _post_shutdown(self) -> None:
>           """
> diff --git a/python/qemu/qtest.py b/python/qemu/qtest.py
> index 39a0cf62fe..0d01715086 100644
> --- a/python/qemu/qtest.py
> +++ b/python/qemu/qtest.py
> @@ -138,9 +138,9 @@ def _pre_launch(self) -> None:
>           super()._pre_launch()
>           self._qtest = QEMUQtestProtocol(self._qtest_path, server=True)
>   
> -    def _post_launch(self) -> None:
> +    def _post_launch(self, timer) -> None:
>           assert self._qtest is not None
> -        super()._post_launch()
> +        super()._post_launch(timer)
>           self._qtest.accept()
>   
>       def _post_shutdown(self) -> None:
> 

Are you forgetting to change _launch() to provide some default value for 
what timer needs to be?

I think for the "event" callbacks here, I'd prefer configuring the 
behavior as a property instead of passing it around as a parameter.

(Also, we have an awful lot of timeouts now... is it time to think about 
rewriting this using asyncio so that we can allow the callers to specify 
their own timeouts in with context blocks? Just a thought for later; we 
have an awful lot of timeouts scattered throughout machine.py, qmp.py, etc.)

--js
Emanuele Giuseppe Esposito April 9, 2021, 4:01 p.m. UTC | #2
>> --- a/python/qemu/qtest.py
>> +++ b/python/qemu/qtest.py
>> @@ -138,9 +138,9 @@ def _pre_launch(self) -> None:
>>           super()._pre_launch()
>>           self._qtest = QEMUQtestProtocol(self._qtest_path, server=True)
>> -    def _post_launch(self) -> None:
>> +    def _post_launch(self, timer) -> None:
>>           assert self._qtest is not None
>> -        super()._post_launch()
>> +        super()._post_launch(timer)
>>           self._qtest.accept()
>>       def _post_shutdown(self) -> None:
>>
> 
> Are you forgetting to change _launch() to provide some default value for 
> what timer needs to be?
> 
> I think for the "event" callbacks here, I'd prefer configuring the 
> behavior as a property instead of passing it around as a parameter.

I agree, I changed it in a field of the QEMUMachine class called 
_qmp_timer that defaults to 15 seconds.

Emanuele
diff mbox series

Patch

diff --git a/python/qemu/machine.py b/python/qemu/machine.py
index 6e44bda337..c721e07d63 100644
--- a/python/qemu/machine.py
+++ b/python/qemu/machine.py
@@ -321,9 +321,9 @@  def _pre_launch(self) -> None:
                 nickname=self._name
             )
 
-    def _post_launch(self) -> None:
+    def _post_launch(self, timer) -> None:
         if self._qmp_connection:
-            self._qmp.accept()
+            self._qmp.accept(timer)
 
     def _post_shutdown(self) -> None:
         """
diff --git a/python/qemu/qtest.py b/python/qemu/qtest.py
index 39a0cf62fe..0d01715086 100644
--- a/python/qemu/qtest.py
+++ b/python/qemu/qtest.py
@@ -138,9 +138,9 @@  def _pre_launch(self) -> None:
         super()._pre_launch()
         self._qtest = QEMUQtestProtocol(self._qtest_path, server=True)
 
-    def _post_launch(self) -> None:
+    def _post_launch(self, timer) -> None:
         assert self._qtest is not None
-        super()._post_launch()
+        super()._post_launch(timer)
         self._qtest.accept()
 
     def _post_shutdown(self) -> None: