public ISession ensureMachineIsLaunched(String vmName) {
ISession session = null;
IMachine machine = manager.get().getVBox().findMachine(vmName);
while (!machine.getState().equals(MachineState.Running)) {
try {
session = machineUtils.applyForMachine(vmName, new LaunchMachineIfNotAlreadyRunning(manager.get(),
executionType, ""));
} catch (RuntimeException e) {
if (e.getMessage().contains(
"org.virtualbox_4_2.VBoxException: VirtualBox error: The given session is busy (0x80BB0007)")) {
throw e;