[v11,6/8] qemu.py: cleanup redundant calls in launch()

Message ID 20171114102246.22221-7-apahim@redhat.com
State New
Headers show
Series
  • scripts/qemu.py fixes and cleanups
Related show

Commit Message

Amador Pahim Nov. 14, 2017, 10:22 a.m.
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().

Reviewed-by: Fam Zheng <famz@redhat.com>
Signed-off-by: Amador Pahim <apahim@redhat.com>
---
 scripts/qemu.py | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)

Comments

Eduardo Habkost Jan. 19, 2018, 5:37 p.m. | #1
On Tue, Nov 14, 2017 at 11:22:44AM +0100, Amador Pahim wrote:
> 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().
> 
> Reviewed-by: Fam Zheng <famz@redhat.com>
> Signed-off-by: Amador Pahim <apahim@redhat.com>

Reviewed-by: Eduardo Habkost <ehabkost@redhat.com>

> ---
>  scripts/qemu.py | 6 +-----
>  1 file changed, 1 insertion(+), 5 deletions(-)
> 
> diff --git a/scripts/qemu.py b/scripts/qemu.py
> index d3824a7a0b..305d7bd098 100644
> --- a/scripts/qemu.py
> +++ b/scripts/qemu.py
> @@ -212,11 +212,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.6
> 
>

Patch

diff --git a/scripts/qemu.py b/scripts/qemu.py
index d3824a7a0b..305d7bd098 100644
--- a/scripts/qemu.py
+++ b/scripts/qemu.py
@@ -212,11 +212,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: