[elbe-devel] [PATCH 3/3] initvmaction: fix race condition during initvm shutdown

Torben Hohn torben.hohn at linutronix.de
Wed Mar 13 18:02:23 CET 2019


On Wed, Mar 13, 2019 at 05:56:50PM +0100, Manuel Traut wrote:
> Sometimes "elbe initvm stop" fails:
> 
> Traceback (most recent call last):
>   File "/usr/bin/elbe", line 55, in <module>
>     cmdmod.run_command(sys.argv[2:])
>   File "/usr/lib/python2.7/dist-packages/elbepack/commands/initvm.py", line 91, in run_command
>     action.execute(directory, opt, args[1:])
>   File "/usr/lib/python2.7/dist-packages/elbepack/initvmaction.py", line 188, in execute
>     raise e
> libvirt.libvirtError: Requested operation is not valid: domain is not running
> 
> There are two states in libvirt. SHUTOFF that is used if the machine is
> off and SHUTDOWN during the machine is going down.
> 
> The code sends a "shutdown" commmand to the machine in a loop.
> After sending the shutdown command a machine is expected to be in the state
> SHUTDOWN and than in the state SHUTOFF. Currently the code expects the
> machine only to be in the SHUTOFF state, but not in the SHUTDOWN state.
> 
> Don't raise an error if the machine is in the SHUTDOWN state.
> 
> Signed-off-by: Manuel Traut <manut at linutronix.de>

Reviewed-by: Torben Hohn <torben.hohn at linutronix.de>

> ---
>  elbepack/initvmaction.py | 7 ++++---
>  1 file changed, 4 insertions(+), 3 deletions(-)
> 
> diff --git a/elbepack/initvmaction.py b/elbepack/initvmaction.py
> index 98ccdd00..f15b65cd 100644
> --- a/elbepack/initvmaction.py
> +++ b/elbepack/initvmaction.py
> @@ -182,9 +182,10 @@ class StopAction(InitVMAction):
>                  try:
>                      self.initvm.shutdown()
>                  except libvirt.libvirtError as e:
> -                    # ignore that initvm is already shutdown but raise all
> -                    # other errors
> -                    if self.initvm_state() != libvirt.VIR_DOMAIN_SHUTOFF:
> +                    # ignore that initvm is already shutoff or is currently
> +                    # shutting down but raise all other errors
> +                    if (self.initvm_state() != libvirt.VIR_DOMAIN_SHUTOFF and
> +                        self.initvm_state() != libvirt.VIR_DOMAIN_SHUTDOWN):
>                          raise e
>                  sys.stdout.write("*")
>                  sys.stdout.flush()
> -- 
> 2.20.1
> 

-- 
Torben Hohn
Linutronix GmbH | Bahnhofstrasse 3 | D-88690 Uhldingen-Mühlhofen
Phone: +49 7556 25 999 18; Fax.: +49 7556 25 999 99

Hinweise zum Datenschutz finden Sie hier (Informations on data privacy 
can be found here): https://linutronix.de/kontakt/Datenschutz.php

Linutronix GmbH | Firmensitz (Registered Office): Uhldingen-Mühlhofen | 
Registergericht (Registration Court): Amtsgericht Freiburg i.Br., HRB700 
806 | Geschäftsführer (Managing Directors): Heinz Egger, Thomas Gleixner
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 488 bytes
Desc: not available
URL: <http://lists.linutronix.de/pipermail/elbe-devel/attachments/20190313/97d267ef/attachment.sig>


More information about the elbe-devel mailing list