diff --git a/org.jdrupes.vmoperator.runner.qemu/src/org/jdrupes/vmoperator/runner/qemu/Runner.java b/org.jdrupes.vmoperator.runner.qemu/src/org/jdrupes/vmoperator/runner/qemu/Runner.java index 8a136ad..c076409 100644 --- a/org.jdrupes.vmoperator.runner.qemu/src/org/jdrupes/vmoperator/runner/qemu/Runner.java +++ b/org.jdrupes.vmoperator.runner.qemu/src/org/jdrupes/vmoperator/runner/qemu/Runner.java @@ -132,6 +132,8 @@ import org.jgrapes.util.events.WatchFile; * } * * Running --> qemuPowerdown: Stop + * Running --> which2: ProcessExited[process qemu] + * * terminated --> [*] * * @enduml @@ -356,7 +358,7 @@ public class Runner extends Component { } private boolean startProcess(CommandDefinition toStart) { - logger.fine( + logger.info( () -> "Starting process: " + String.join(" ", toStart.command)); fire(new StartProcess(toStart.command) .setAssociated(CommandDefinition.class, toStart)); @@ -446,7 +448,14 @@ public class Runner extends Component { */ @Handler public void onProcessExited(ProcessExited event, ProcessChannel channel) { - int i = 0; + channel.associated(CommandDefinition.class).ifPresent(procDef -> { + if (procDef.equals(qemuDefinition) + && state.get() == State.RUNNING) { + fire(new Stop()); + } + logger.info(() -> "Process " + procDef.name + + " has exited with value " + event.exitValue()); + }); } /** diff --git a/org.jdrupes.vmoperator.runner.qemu/src/org/jdrupes/vmoperator/runner/qemu/StateController.java b/org.jdrupes.vmoperator.runner.qemu/src/org/jdrupes/vmoperator/runner/qemu/StateController.java index 3709fcb..fdc3a4d 100644 --- a/org.jdrupes.vmoperator.runner.qemu/src/org/jdrupes/vmoperator/runner/qemu/StateController.java +++ b/org.jdrupes.vmoperator.runner.qemu/src/org/jdrupes/vmoperator/runner/qemu/StateController.java @@ -34,6 +34,11 @@ package org.jdrupes.vmoperator.runner.qemu; private State state = State.INITIALIZING; + /** + * Instantiates a new state controller. + * + * @param runner the runner + */ public StateController(Runner runner) { this.runner = runner; } @@ -47,6 +52,15 @@ package org.jdrupes.vmoperator.runner.qemu; this.state = state; } + /** + * Returns the state. + * + * @return the state + */ + public State get() { + return state; + } + @Override public String toString() { return "StateController [state=" + state + "]";