[elbe-devel] [PATCH] initvmaction: Fix initvm command stop

Bastian Germann bage at linutronix.de
Tue Aug 4 16:29:44 CEST 2020


Am 04.08.20 um 15:28 schrieb Olivier Dion:
> This should fix problems that some users had with elbe-initvm-stop.
> 
> Signed-off-by: Olivier Dion <dion at linutronix.de>
> ---
>  elbepack/initvmaction.py | 25 +++++++++++++++----------
>  1 file changed, 15 insertions(+), 10 deletions(-)
> 
> diff --git a/elbepack/initvmaction.py b/elbepack/initvmaction.py
> index a0b76e15..898e7a33 100644
> --- a/elbepack/initvmaction.py
> +++ b/elbepack/initvmaction.py
> @@ -200,19 +200,24 @@ class StopAction(InitVMAction):
>              sys.exit(20)
>          else:
>              while True:
> -                try:
> -                    self.initvm.shutdown()
> -                except libvirt.libvirtError as e:
> -                    # 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):
> +
> +                state = self.initvm_state()
> +
> +                if state == libvirt.VIR_DOMAIN_SHUTDOWN:
> +                    pass
> +
> +                elif state == libvirt.VIR_DOMAIN_SHUTOFF:
> +                    print("\nInitvm shutoff")
> +                    break
> +
> +                else:
> +                    try:
> +                        ret = self.initvm.shutdown()

You do not use (return) the ret var.

> +                    except libvirt.libvirtError as e:
>                          raise e
> +
>                  sys.stdout.write("*")
>                  sys.stdout.flush()
> -                if self.initvm_state() == libvirt.VIR_DOMAIN_SHUTOFF:
> -                    print("\nInitvm shut off.")
> -                    break
>                  time.sleep(1)
>  
>  
> 


More information about the elbe-devel mailing list