+ smx_process->resume();
+ }
+
+ vmState_ = SURF_VM_STATE_RUNNING;
+}
+
+/** @brief Power off a VM.
+ *
+ * All hosted processes will be killed, but the VM state is preserved on memory.
+ * It can later be restarted.
+ *
+ * @param issuer the actor requesting the shutdown
+ */
+void VirtualMachineImpl::shutdown(smx_actor_t issuer)
+{
+ if (getState() != SURF_VM_STATE_RUNNING) {
+ const char* stateName = "(unknown state)";
+ switch (getState()) {
+ case SURF_VM_STATE_CREATED:
+ stateName = "created, but not yet started";
+ break;
+ case SURF_VM_STATE_SUSPENDED:
+ stateName = "suspended";
+ break;
+ case SURF_VM_STATE_DESTROYED:
+ stateName = "destroyed";
+ break;
+ default: /* SURF_VM_STATE_RUNNING or unexpected values */
+ THROW_IMPOSSIBLE;
+ break;
+ }
+ XBT_VERB("Shuting down the VM %s even if it's not running but %s", piface_->cname(), stateName);
+ }
+
+ xbt_swag_t process_list = piface_->extension<simgrid::simix::Host>()->process_list;
+ XBT_DEBUG("shutdown VM %s, that contains %d processes", piface_->cname(), xbt_swag_size(process_list));
+
+ smx_actor_t smx_process;
+ smx_actor_t smx_process_safe;
+ xbt_swag_foreach_safe(smx_process, smx_process_safe, process_list) {
+ XBT_DEBUG("kill %s", smx_process->cname());
+ SIMIX_process_kill(smx_process, issuer);