qemu-devel
[Top][All Lists]
Advanced

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

[Qemu-devel] [PATCH v5 5/6] qemu.py: make sure shutdown() is called befo


From: Amador Pahim
Subject: [Qemu-devel] [PATCH v5 5/6] qemu.py: make sure shutdown() is called before launching again
Date: Tue, 25 Jul 2017 19:10:13 +0200

If launch() is called twice or if the VM is terminated not using
shutdown(), the new call to launch() will fail due to the dirty
environment, with files from the previous instance laying around.

This patch add to launch() the ability to check whether shutdown() was
called after a previous launch(), calling it when applies.

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

diff --git a/scripts/qemu.py b/scripts/qemu.py
index 45a63e8e9d..e18e8ec657 100644
--- a/scripts/qemu.py
+++ b/scripts/qemu.py
@@ -39,6 +39,7 @@ class QEMUMachine(object):
         self._iolog = None
         self._socket_scm_helper = socket_scm_helper
         self._debug = debug
+        self._shutdown_pending = False
 
     # This can be used to add an unused monitor instance.
     def add_monitor_telnet(self, ip, port):
@@ -135,8 +136,14 @@ class QEMUMachine(object):
         if self.is_running():
             return
 
+        if self._shutdown_pending:
+            sys.stderr.write('shutdown() was not called after previous '
+                             'launch(). Calling now.\n')
+            self.shutdown()
+
         try:
             self._launch()
+            self._shutdown_pending = True
         except:
             self.shutdown()
             raise
@@ -166,6 +173,7 @@ class QEMUMachine(object):
 
         self._load_io_log()
         self._post_shutdown()
+        self._shutdown_pending = False
 
     underscore_to_dash = string.maketrans('_', '-')
     def qmp(self, cmd, conv_keys=True, **args):
-- 
2.13.3




reply via email to

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