[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH 1/6] Python: close the log file kept by QEMUMachine before re

From: Wainer dos Santos Moschetta
Subject: Re: [PATCH 1/6] Python: close the log file kept by QEMUMachine before reading it
Date: Wed, 17 Feb 2021 16:53:42 -0300
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.7.0

On 2/15/21 11:34 PM, Cleber Rosa wrote:
On Mon, Feb 15, 2021 at 03:30:16PM -0300, Wainer dos Santos Moschetta wrote:

On 2/11/21 7:01 PM, Cleber Rosa wrote:
Closing a file that is open for writing, and then reading from it
sounds like a better idea than the opposite, given that the content
will be flushed.

Reference: https://docs.python.org/3/library/io.html#io.IOBase.close
Signed-off-by: Cleber Rosa <crosa@redhat.com>
   python/qemu/machine.py | 4 ++--
   1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/python/qemu/machine.py b/python/qemu/machine.py
index 7a40f4604b..6e44bda337 100644
--- a/python/qemu/machine.py
+++ b/python/qemu/machine.py
@@ -337,12 +337,12 @@ class QEMUMachine:
               self._qmp_connection = None
-        self._load_io_log()
           if self._qemu_log_file is not None:
               self._qemu_log_file = None
+        self._load_io_log()

IMO it's a too fragile fix. It needs the `self._qemu_log_file.close()` being
called before `self._load_io_log()` but a future change can make this
condition unmet again. Maybe you could document that in the code. Or change
the `_load_io_log()` to close the log file if it is open (also document it
in code).

- Wainer

I'm glad you see this is needed... and then something else.  I'll investigate
making this more robust as time allows it.

Question is: do you ack/nack this change?

hmm... /me thinking hmmm... okay, good deal. :)

Acked-by: Wainer dos Santos Moschetta <wainersm@redhat.com>

- Cleber.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]