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.