} catch( Exception e ) {}
}
- stopVM() ;
+ stopVM( 1 ) ;
}
if( ! ret )
{
sema.release() ;
- stopVM() ;
+ stopVM( 1 ) ;
return 1 ;
} else {
retry++ ;
System.err.println( "Unable to check VM!" ) ;
sema.release() ;
- stopVM() ;
+ stopVM( 1 ) ;
return 1 ;
}
System.out.println( "Retrying (" + retry + ") ... " ) ;
} catch( IOException e ) {
e.printStackTrace() ;
sema.release() ;
- stopVM() ;
+ stopVM( 1 ) ;
return 1 ;
} catch( InterruptedException e ) {
e.printStackTrace() ;
sema.release() ;
- stopVM() ;
+ stopVM( 1 ) ;
return 1 ;
}
sema.release() ;
- stopVM() ;
+ stopVM( 1 ) ;
return 1 ;
} else {
} catch( IOException e1 ) {
e1.printStackTrace() ;
sema.release() ;
- stopVM() ;
+ stopVM( 1 ) ;
return 1 ;
}
if( ! ret )
{
sema.release() ;
- stopVM() ;
+ stopVM( 1 ) ;
return 1 ;
} else {
retry++ ;
System.err.println( "Unable to send information to VM!" ) ;
sema.release() ;
- stopVM() ;
+ stopVM( 1 ) ;
return 1 ;
}
System.err.println( "Error during execution of runScriptInGuest command: " ) ;
e.printStackTrace() ;
sema.release() ;
- stopVM() ;
+ stopVM( 1 ) ;
return 1 ;
} catch( InterruptedException e) {
e.printStackTrace() ;
sema.release() ;
- stopVM() ;
+ stopVM( 1 ) ;
return 1 ;
}
}
} catch( IOException e1 ) {
e1.printStackTrace() ;
sema.release() ;
- stopVM() ;
+ stopVM( 1 ) ;
return 1 ;
}
if( ! ret )
{
sema.release() ;
- stopVM() ;
+ stopVM( 1 ) ;
return 1 ;
} else {
retry++ ;
System.err.println( "Unable to send information to VM!" ) ;
sema.release() ;
- stopVM() ;
+ stopVM( 1 ) ;
return 1 ;
}
System.err.println( "Error during execution of runScriptInGuest command: " ) ;
e.printStackTrace() ;
sema.release() ;
- stopVM() ;
+ stopVM( 1 ) ;
return 1 ;
} catch( InterruptedException e ) {
e.printStackTrace() ;
sema.release() ;
- stopVM() ;
+ stopVM( 1 ) ;
return 1 ;
}
}
@Override
- public int stopVM()
+ public int stopVM( int _mode )
{
if( machine != null && machine.getStatus().equalsIgnoreCase( "stopped" ) )
{
int retry = 0 ;
machine.setStatus( "undefined" ) ;
+ if( _mode == 0 )
try {
LocalHost.Instance().getServerStub().changeStatus(
LocalHost.Instance().getIP(), "undefined" ) ;
}
machine.setStatus( "stopped" ) ;
+ if( _mode == 0 )
try {
LocalHost.Instance().getServerStub().changeStatus(
LocalHost.Instance().getIP(), "stopped" ) ;
e.printStackTrace() ;
}
- if( stopVM() == 0 )
+ if( stopVM( 1 ) == 0 )
{
if( machine.deployLastSave() == 0 )
{
return 0 ;
}
} else {
- stopVM() ;
+ stopVM( 1 ) ;
}
}
}
while( (line = br.readLine()) != null )
{
System.err.println( line ) ;
- if( line.contains( "egmentation" ) )
+ if( line.contains( "egmentation" ) || _p.exitValue() == 139 )
{
ret = true ;
}
return ret ;
}
+
+ @Override
+ public int echo()
+ {
+ return 0 ;
+ }
+
@Override
public int start()
} catch( RemoteException e1 ) {
System.err.println( "Unable to ping the server!" ) ;
e1.printStackTrace() ;
+ yield() ;
}
try {
sleep( 2000 ) ;
} catch( InterruptedException e ) {
e.printStackTrace() ;
+ yield() ;
}
}
}
serverSocket.close() ;
} catch( IOException e ) {
e.printStackTrace() ;
+ yield() ;
}
}
}
} catch( IOException e ) {
System.err.println( "Unable to launch the SocketServer on port " + dialog_port + "!" ) ;
e.printStackTrace() ;
-
- go = false ;
+ System.exit( 1 ) ;
}
while( go )
} catch( IOException e ) {
System.err.println( "Problem with the accept function!" ) ;
e.printStackTrace() ;
+ yield() ;
}
}
}
reader = new BufferedReader( new InputStreamReader( socket.getInputStream() ) ) ;
} catch( IOException e ) {
System.err.println( "Unable to open a dialog socket with the VM!" ) ;
- e.printStackTrace();
+ e.printStackTrace() ;
+ yield() ;
}
try {
saveRequest.setStatus( false ) ;
/* Requesting the VM save */
- saveVM() ;
+ if( saveVM() == 1 )
+ {
+ System.err.println( "Problem while saving. Exiting ..." ) ;
+ pingServer.stopPing() ;
+ emergencyStop() ;
+ System.exit( 1 ) ;
+ }
} else {
sendSaveOkVM() ;
}
reader.close() ; reader = null ;
socket.close() ; socket = null ;
- stopVM() ;
+ stopVM( 0 ) ;
machine.setStatus( "connected" ) ;
try {
/* Close streams */
reader.close() ; reader = null ;
socket.close() ; socket = null ;
+ System.out.println( "Application is starting." ) ;
try {
LocalHost.Instance().getServerStub().goApplication() ;
} catch( IOException e ) {
e.printStackTrace() ;
+ yield() ;
}
}
}
@Override
public void stop()
{
- stopVM() ;
+ stopVM( 0 ) ;
pingServer.stopPing() ;