return null;
}
+ /** 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,
+ * but this is not the way it goes in Java. The VM will only get destroyed by the garbage
+ * collector when it is not referenced anymore by your variables. So, to see the VM really
+ * destroyed, don't call this function but simply release any ref you have on it.
+ */
public void destroy() {
- nativeFinalize();
+ shutdown();
+/// vms.remove(this);
}
- private native void nativeFinalize();
-
- /* JNI / Native code */
+ /* Make sure that the GC also destroys the C object */
+ protected void finalize() throws Throwable {
+ nativeFinalize();
+ }
+ public native void nativeFinalize();
/** Returns whether the given VM is currently suspended */
public native int isCreated();
/** Returns whether the given VM is currently suspended */
public native int isSuspended();
- /** Returns whether the given VM is currently saving */
- public native int isSaving();
-
- /** Returns whether the given VM is currently saved */
- public native int isSaved();
-
- /** Returns whether the given VM is currently restoring its state */
- public native boolean isRestoring();
-
/**
* Natively implemented method create the VM.
* @param ramSize size of the RAM that should be allocated (in MB)
*/
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);
-
-
+ /** native migration routine */
+ private native void nativeMigration(Host destination) throws Exception;
/** 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();
*/
public native void resume();
- /** Immediately suspend the execution of all processes within the given VM
- * and save its state on the persistent HDD
- * Not yet implemented (for the moment it behaves like suspend)
- * No suspension cost occurs. If you want to simulate this too, you want to
- * use a \ref File.write() before or after, depending on the exact semantic
- * of VM suspend to you.
- */
- public native void save();
-
- /** Immediately resumes the execution of all processes previously saved
- * within the given VM
- * Not yet implemented (for the moment it behaves like resume)
- *
- * No resume cost occurs. If you want to simulate this too, you want to
- * use a \ref File.read() before or after, depending on the exact semantic
- * of VM resume to you.
- */
- public native void restore();
-
/** Class initializer (for JNI), don't do it yourself */
public static native void nativeInit();
static {