diff options
author | Manuel Bentele | 2021-09-01 13:25:57 +0200 |
---|---|---|
committer | Manuel Bentele | 2021-09-01 13:25:57 +0200 |
commit | 858bbfae48e98128733f885a0b5665df03ab2452 (patch) | |
tree | 832d0da6ef70d80b07df4d1ab99d87efa1f18ce2 | |
parent | [qemu] Update params of documented looking-glass-client viewer call (diff) | |
download | mltk-858bbfae48e98128733f885a0b5665df03ab2452.tar.gz mltk-858bbfae48e98128733f885a0b5665df03ab2452.tar.xz mltk-858bbfae48e98128733f885a0b5665df03ab2452.zip |
[qemu] Shutdown VM if VM viewer dies and VM remains running
-rw-r--r-- | core/modules/qemu/runvirt-plugin-qemu/src/main/java/org/openslx/runvirt/plugin/qemu/App.java | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/core/modules/qemu/runvirt-plugin-qemu/src/main/java/org/openslx/runvirt/plugin/qemu/App.java b/core/modules/qemu/runvirt-plugin-qemu/src/main/java/org/openslx/runvirt/plugin/qemu/App.java index 78292e37..e1c2e311 100644 --- a/core/modules/qemu/runvirt-plugin-qemu/src/main/java/org/openslx/runvirt/plugin/qemu/App.java +++ b/core/modules/qemu/runvirt-plugin-qemu/src/main/java/org/openslx/runvirt/plugin/qemu/App.java @@ -219,13 +219,22 @@ public class App System.exit( 8 ); } + // stop VM if VM isn't turned off already (or if VM viewer) died + try { + vm.stop(); + } catch ( LibvirtVirtualMachineException e ) { + LOGGER.error( "Failed to shutdown orphaned VM: " + e.getLocalizedMessage() ); + hypervisor.close(); + System.exit( 9 ); + } + // undefine VM after usage try { hypervisor.deregisterVm( vm ); } catch ( LibvirtHypervisorException | LibvirtVirtualMachineException e ) { LOGGER.error( "Failed to undefine VM: " + e.getLocalizedMessage() ); hypervisor.close(); - System.exit( 9 ); + System.exit( 10 ); } // close connection to hypervisor |