public class VM extends Host {
// No need to declare a new bind variable: we use the one inherited from the super class Host
- /* Static functions */
-
private static ArrayList<VM> vms= new ArrayList<>();
private Host currentHost;
vms.add(this);
}
- public static VM[] all(){
- VM[] allvms = new VM[vms.size()];
- vms.toArray(allvms);
- return allvms;
- }
+ public native static VM[] all();
public static VM getVMByName(String name){
for (VM vm : vms){
return null;
}
- /** Kills all the actors running on that VM
+ /** Shutdown and unref the VM.
*
* Actually, this strictly equivalent to shutdown().
* In C and in libvirt, the destroy function also releases the memory associated to the VM,
*/
public void destroy() {
shutdown();
+/// vms.remove(this);
}
/* Make sure that the GC also destroys the C object */
*/
public native void shutdown();
- /** Invoke native migration routine */
- public native void internalmig(Host destination) throws Exception; // TODO add throws DoubleMigrationException (i.e. when you call migrate on a VM that is already migrating);
-
-
-
/** Change the host on which all processes are running
* (pre-copy is implemented)
*/
public void migrate(Host destination) throws HostFailureException{
try {
- this.internalmig(destination);
+ this.nativeMigration(destination);
} catch (Exception e){
Msg.info("Migration of VM "+this.getName()+" to "+destination.getName()+" is impossible ("+e.getMessage()+")");
throw new HostFailureException();
// If the migration correcly returned, then we should change the currentHost value.
this.currentHost = destination;
}
+ private native void nativeMigration(Host destination) throws Exception;
/** Immediately suspend the execution of all processes within the given VM
*