summaryrefslogtreecommitdiffstats
path: root/core/modules/qemu
diff options
context:
space:
mode:
Diffstat (limited to 'core/modules/qemu')
-rw-r--r--core/modules/qemu/runvirt-plugin-qemu/src/main/java/org/openslx/runvirt/plugin/qemu/App.java11
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