qemu-devel
[Top][All Lists]
Advanced

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

[Qemu-devel] [PATCH v8 11/13] qemu.py: cleanup redundant calls in launch


From: Amador Pahim
Subject: [Qemu-devel] [PATCH v8 11/13] qemu.py: cleanup redundant calls in launch()
Date: Fri, 1 Sep 2017 13:28:27 +0200

Now that shutdown() is guaranteed to always execute self._load_io_log()
and self._post_shutdown(), their calls in 'except' became redundant and
we can safely replace it by a call to shutdown().

Due to this change, shutdown() can be now called even before the
creation of the _qemu_log_path. So, to avoid errors with _load_io_log(),
this patch makes sure we will only read the _qemu_log_path if it was
previously created by us.

Signed-off-by: Amador Pahim <address@hidden>
---
 scripts/qemu.py | 11 ++++-------
 1 file changed, 4 insertions(+), 7 deletions(-)

diff --git a/scripts/qemu.py b/scripts/qemu.py
index 87a2212b77..03e4cc34b7 100644
--- a/scripts/qemu.py
+++ b/scripts/qemu.py
@@ -115,8 +115,9 @@ class QEMUMachine(object):
         return self._popen.pid
 
     def _load_io_log(self):
-        with open(self._qemu_log_path, "r") as fh:
-            self._iolog = fh.read()
+        if self._qemu_log_path in self._created_files:
+            with open(self._qemu_log_path, "r") as fh:
+                self._iolog = fh.read()
 
     def _base_args(self):
         if isinstance(self._monitor_address, tuple):
@@ -169,11 +170,7 @@ class QEMUMachine(object):
         try:
             self._launch()
         except:
-            if self.is_running():
-                self._popen.kill()
-                self._popen.wait()
-            self._load_io_log()
-            self._post_shutdown()
+            self.shutdown()
 
             LOG.debug('Error launching VM')
             if self._qemu_full_args:
-- 
2.13.5




reply via email to

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