qemu-devel
[Top][All Lists]
Advanced

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

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


From: Eduardo Habkost
Subject: Re: [Qemu-devel] [PATCH v5 5/6] qemu.py: make sure shutdown() is called before launching again
Date: Tue, 25 Jul 2017 16:58:35 -0300
User-agent: Mutt/1.8.0 (2017-02-23)

On Tue, Jul 25, 2017 at 07:10:13PM +0200, Amador Pahim wrote:
> 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()
> +

This looks like obviously invalid API usage.  Why not raise an
Exception?

>          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
> 

-- 
Eduardo



reply via email to

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