[elbe-devel] [PATCH] initvm stop: execute libvirt stop more than once

Torben Hohn torben.hohn at linutronix.de
Wed Aug 1 13:13:38 CEST 2018


On Wed, Aug 01, 2018 at 12:53:37PM +0200, Manuel Traut wrote:
> If initvm is just booting, the stop command is ignored.
> Therefore issue the command in the while loop.
> Hitting the poweroff button more than once shouldn't be evil.
> However an exception is raised by libvirt if the target is already
> shutdown. This can be safely ignored.
> 
> Signed-off-by: Manuel Traut <manut at linutronix.de>

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

> ---
>  elbepack/initvmaction.py | 9 +++++++--
>  1 file changed, 7 insertions(+), 2 deletions(-)
> 
> diff --git a/elbepack/initvmaction.py b/elbepack/initvmaction.py
> index a55a211f..73eda552 100644
> --- a/elbepack/initvmaction.py
> +++ b/elbepack/initvmaction.py
> @@ -176,9 +176,14 @@ class StopAction(InitVMAction):
>              print('Initvm is not running.')
>              sys.exit(20)
>          else:
> -            # Shutdown initvm
> -            self.initvm.shutdown()
>              while(True):
> +                try:
> +                    self.initvm.shutdown()
> +                except libvirt.libvirtError as e:
> +                    # ignore that initvm is already shutdown but raise all
> +                    # other errors
> +                    if self.initvm_state() != 5:
> +                        raise e
>                  sys.stdout.write("*")
>                  sys.stdout.flush()
>                  if self.initvm_state() == 5:
> -- 
> 2.18.0
> 

-- 
Mit freundlichen Grüßen
Torben Hohn

Linutronix GmbH

Standort: Bremen

Phone: +49 7556 25 999 18; Fax.: +49 7556 25 999 99

Firmensitz / Registered Office: D-88690 Uhldingen, Bahnhofstr. 3
Registergericht / Local District Court: Amtsgericht Freiburg i. Br.; HRB
Nr. / Trade register no.: 700 806

Geschäftsführer / Managing Directors: Heinz Egger, Thomas Gleixner

Eine Bitte von uns: Sollten Sie diese E-Mail irrtümlich erhalten haben,
benachrichtigen Sie uns in diesem Falle bitte sobald wie es Ihnen
möglich ist, durch Antwort-Mail. Vielen Dank!
-------------- 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/20180801/0e086a29/attachment.sig>


More information about the elbe-devel mailing list