- MSG_storage_set_property_value()
* VM properties. Since msg_vm_t are msg_host_t, just use
MSG_host_get_property_value() and friends
- * MSG_vm_create had ignored parameters, that are now dropped:
- core_nb, disk_path and disk_size.
+ * VM I/O related things:
+ - Ignored parameter of vm_create: core_nb, disk_path and disk_size.
+ - Unimplemented save/restore methods
* MSG_as_router_get_property_value() was redundent with
MSG_environment_as_get_property_value().
- Removed MSG_as_router_*propert*() functions
XBT_PUBLIC(int) MSG_vm_is_created(msg_vm_t vm);
XBT_PUBLIC(int) MSG_vm_is_running(msg_vm_t vm);
XBT_PUBLIC(int) MSG_vm_is_migrating(msg_vm_t vm);
-
XBT_PUBLIC(int) MSG_vm_is_suspended(msg_vm_t vm);
-XBT_PUBLIC(int) MSG_vm_is_saving(msg_vm_t vm);
-XBT_PUBLIC(int) MSG_vm_is_saved(msg_vm_t vm);
-XBT_PUBLIC(int) MSG_vm_is_restoring(msg_vm_t vm);
#define MSG_vm_get_name(vm) MSG_host_get_name(vm)
XBT_PUBLIC(void) MSG_vm_suspend(msg_vm_t vm);
XBT_PUBLIC(void) MSG_vm_resume(msg_vm_t vm);
-/* Save the VM state to a disk. */
-XBT_PUBLIC(void) MSG_vm_save(msg_vm_t vm);
-XBT_PUBLIC(void) MSG_vm_restore(msg_vm_t vm);
-
XBT_PUBLIC(msg_host_t) MSG_vm_get_pm(msg_vm_t vm);
XBT_PUBLIC(void) MSG_vm_set_bound(msg_vm_t vm, double bound);
SURF_VM_STATE_CREATED, /**< created, but not yet started */
SURF_VM_STATE_RUNNING,
SURF_VM_STATE_SUSPENDED, /**< Suspend/resume does not involve disk I/O, so we assume there is no transition states. */
-
- SURF_VM_STATE_SAVING, /**< Save/restore involves disk I/O, so there should be transition states. */
- SURF_VM_STATE_SAVED,
- SURF_VM_STATE_RESTORING,
} e_surf_vm_state_t;
namespace simgrid {
return (jint) MSG_vm_is_suspended(vm);
}
-JNIEXPORT jint JNICALL Java_org_simgrid_msg_VM_isSaving(JNIEnv * env, jobject jvm)
-{
- msg_vm_t vm = jvm_get_native(env,jvm);
- return (jint) MSG_vm_is_saving(vm);
-}
-
-JNIEXPORT jint JNICALL Java_org_simgrid_msg_VM_isSaved(JNIEnv * env, jobject jvm)
-{
- msg_vm_t vm = jvm_get_native(env,jvm);
- return (jint) MSG_vm_is_saved(vm);
-}
-
-JNIEXPORT jint JNICALL Java_org_simgrid_msg_VM_isRestoring(JNIEnv * env, jobject jvm)
-{
- msg_vm_t vm = jvm_get_native(env,jvm);
- return (jint) MSG_vm_is_restoring(vm);
-}
-
JNIEXPORT void JNICALL Java_org_simgrid_msg_VM_setBound(JNIEnv *env, jobject jvm, jdouble bound)
{
msg_vm_t vm = jvm_get_native(env,jvm);
const char* name = env->GetStringUTFChars(jname, 0);
name = xbt_strdup(name);
- // TODO disk concerns are not taken into account yet
- // const char *diskpath;
- // disk_path = (*env)->GetStringUTFChars(env, jdiskpath, 0);
- // disk_path = xbt_strdup(disk_path);
-
msg_vm_t vm = MSG_vm_create(host, name, (int)jramsize, (int)jmig_netspeed, (int)jdp_intensity);
jvm_bind(env, jvm, vm);
MSG_vm_resume(vm);
}
-JNIEXPORT void JNICALL Java_org_simgrid_msg_VM_save(JNIEnv *env, jobject jvm)
-{
- msg_vm_t vm = jvm_get_native(env,jvm);
- MSG_vm_save(vm);
-}
-
-JNIEXPORT void JNICALL Java_org_simgrid_msg_VM_restore(JNIEnv *env, jobject jvm)
-{
- msg_vm_t vm = jvm_get_native(env,jvm);
- MSG_vm_restore(vm);
-}
*/
JNIEXPORT jint JNICALL Java_org_simgrid_msg_VM_isResuming(JNIEnv *env, jobject jvm);
-/**
- * Class org_simgrid_msg_VM
- * Method isSuspended
- * Signature ()B
- */
-JNIEXPORT jint JNICALL Java_org_simgrid_msg_VM_isSaving(JNIEnv *env, jobject jvm);
-
-/**
- * Class org_simgrid_msg_VM
- * Method isSave
- * Signature ()B
- */
-JNIEXPORT jint JNICALL Java_org_simgrid_msg_VM_isSaved(JNIEnv *env, jobject jvm);
-
-/**
- * Class org_simgrid_msg_VM
- * Method isResuming
- * Signature ()B
- */
-JNIEXPORT jint JNICALL Java_org_simgrid_msg_VM_isRestoring(JNIEnv *env, jobject jvm);
-
/**
* Class org_simgrid_msg_VM
* Method setBound
*/
JNIEXPORT void JNICALL Java_org_simgrid_msg_VM_shutdown(JNIEnv *env, jobject jvm);
-/**
- * Class org_simgrid_msg_VM
- * Method save
- * Signature ()V
- */
-JNIEXPORT void JNICALL Java_org_simgrid_msg_VM_save(JNIEnv *env, jobject jvm);
-
-/**
- * Class org_simgrid_msg_VM
- * Method restore
- * Signature ()V
- */
-JNIEXPORT void JNICALL Java_org_simgrid_msg_VM_restore(JNIEnv *env, jobject jvm);
-
SG_END_DECL()
#endif
/** 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 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 {
return __MSG_vm_is_state(vm, SURF_VM_STATE_SUSPENDED);
}
-/** @brief Returns whether the given VM is being saved (FIXME: live saving or not?).
- * @ingroup msg_VMs
- */
-int MSG_vm_is_saving(msg_vm_t vm)
-{
- return __MSG_vm_is_state(vm, SURF_VM_STATE_SAVING);
-}
-
-/** @brief Returns whether the given VM has been saved, not running.
- * @ingroup msg_VMs
- */
-int MSG_vm_is_saved(msg_vm_t vm)
-{
- return __MSG_vm_is_state(vm, SURF_VM_STATE_SAVED);
-}
-
-/** @brief Returns whether the given VM is being restored, not running.
- * @ingroup msg_VMs
- */
-int MSG_vm_is_restoring(msg_vm_t vm)
-{
- return __MSG_vm_is_state(vm, SURF_VM_STATE_RESTORING);
-}
-
/* **** ******** MSG vm actions ********* **** */
/** @brief Create a new VM with specified parameters.
* @ingroup msg_VMs*
}
}
-
-/** @brief Immediately save the execution of all processes within the given VM.
- * @ingroup msg_VMs
- *
- * This function stops the execution of the VM. All the processes on this VM
- * will pause. The state of the VM is preserved. We can later resume it again.
- *
- * FIXME: No suspension cost occurs. If you want to simulate this too, you want to use a \ref MSG_file_write() before
- * or after, depending on the exact semantic of VM save to you.
- */
-void MSG_vm_save(msg_vm_t vm)
-{
- smx_actor_t issuer=SIMIX_process_self();
- simgrid::simix::kernelImmediate([vm,issuer]() {
- static_cast<simgrid::s4u::VirtualMachine*>(vm)->pimpl_vm_->save(issuer);
- });
-
- if (TRACE_msg_vm_is_enabled()) {
- container_t vm_container = PJ_container_get(vm->cname());
- type_t type = PJ_type_get("MSG_VM_STATE", vm_container->type);
- val_t value = PJ_value_get_or_new("save", "0 1 0", type); // save is green
- new_pajePushState(MSG_get_clock(), vm_container, type, value);
- }
-}
-
-/** @brief Restore the execution of the VM. All processes on the VM run again.
- * @ingroup msg_VMs
- *
- * FIXME: No restore cost occurs. If you want to simulate this too, you want to use a \ref MSG_file_read() before or
- * after, depending on the exact semantic of VM restore to you.
- */
-void MSG_vm_restore(msg_vm_t vm)
-{
- simgrid::simix::kernelImmediate([vm]() {
- static_cast<simgrid::s4u::VirtualMachine*>(vm)->pimpl_vm_->restore();
- });
-
- if (TRACE_msg_vm_is_enabled()) {
- container_t vm_container = PJ_container_get(vm->cname());
- type_t type = PJ_type_get("MSG_VM_STATE", vm_container->type);
- new_pajePopState(MSG_get_clock(), vm_container, type);
- }
-}
-
/** @brief Get the physical host of a given VM.
* @ingroup msg_VMs
*/
vmState_ = SURF_VM_STATE_RUNNING;
}
-/**
- * @brief Function to save a VM.
- * This function is the same as vm_suspend, but the state of the VM is saved to the disk, and not preserved in memory.
- * We can later restore it again.
- *
- * @param issuer the process requesting this operation
- */
-void VirtualMachineImpl::save(smx_actor_t issuer)
-{
- if (isMigrating)
- THROWF(vm_error, 0, "Cannot save VM %s: it is migrating.", piface_->cname());
-
- if (getState() != SURF_VM_STATE_RUNNING)
- THROWF(vm_error, 0, "Cannot save VM %s: it is not running.", piface_->cname());
-
- xbt_swag_t process_list = piface_->extension<simgrid::simix::Host>()->process_list;
- XBT_DEBUG("Save VM %s, where %d processes exist", piface_->cname(), xbt_swag_size(process_list));
-
- vmState_ = SURF_VM_STATE_SAVING;
- action_->suspend();
- vmState_ = SURF_VM_STATE_SAVED;
-
- smx_actor_t smx_process, smx_process_safe;
- xbt_swag_foreach_safe(smx_process, smx_process_safe, process_list) {
- XBT_DEBUG("suspend %s", smx_process->cname());
- SIMIX_process_suspend(smx_process, issuer);
- }
-}
-
-void VirtualMachineImpl::restore()
-{
- if (getState() != SURF_VM_STATE_SAVED)
- THROWF(vm_error, 0, "Cannot restore VM %s: it was not saved", piface_->cname());
-
- xbt_swag_t process_list = piface_->extension<simgrid::simix::Host>()->process_list;
- XBT_DEBUG("Restore VM %s, where %d processes exist", piface_->cname(), xbt_swag_size(process_list));
-
- vmState_ = SURF_VM_STATE_RESTORING;
- action_->resume();
- vmState_ = SURF_VM_STATE_RUNNING;
-
- smx_actor_t smx_process, smx_process_safe;
- xbt_swag_foreach_safe(smx_process, smx_process_safe, process_list) {
- XBT_DEBUG("resume %s", smx_process->cname());
- SIMIX_process_resume(smx_process);
- }
-}
-
/** @brief Power off a VM.
*
* All hosted processes will be killed, but the VM state is preserved on memory.
/** @brief Resume the VM */
virtual void resume();
- /** @brief Save (suspend+store on disk) the VM */
- virtual void save(smx_actor_t issuer);
-
- /** @brief Restore (read from disk+resume) the VM */
- virtual void restore();
-
/** @brief Shutdown the VM */
virtual void shutdown(smx_actor_t issuer);