python: add __repr__ to ConsoleSocket to aid debugging
authorAlex Bennée <alex.bennee@linaro.org>
Thu, 10 Dec 2020 19:04:14 +0000 (19:04 +0000)
committerPaolo Bonzini <pbonzini@redhat.com>
Sat, 2 Jan 2021 20:03:09 +0000 (21:03 +0100)
While attempting to debug some console weirdness I thought it would be
worth making it easier to see what it had inside.

Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Reviewed-by: John Snow <jsnow@redhat.com>
Reviewed-by: Willian Rampazzo <willianr@redhat.com>
Message-Id: <20201210190417.31673-6-alex.bennee@linaro.org>

python/qemu/console_socket.py

index f060d79e06da671a34ad575220d3bcbedf58f77a..ac21130e4463327139aafc8d9fa5f64fd9875170 100644 (file)
@@ -45,6 +45,13 @@ class ConsoleSocket(socket.socket):
         if drain:
             self._drain_thread = self._thread_start()
 
+    def __repr__(self) -> str:
+        s = super().__repr__()
+        s = s.rstrip(">")
+        s = "%s,  logfile=%s, drain_thread=%s>" % (s, self._logfile,
+                                                   self._drain_thread)
+        return s
+
     def _drain_fn(self) -> None:
         """Drains the socket and runs while the socket is open."""
         while self._open: