- lmm_variable_t var = NULL;
- lmm_element_t elem = NULL;
-
- surf_watched_hosts();
-
- if (event_type == p_powerEvent) {
- m_powerScale = value;
- lmm_update_constraint_bound(surf_cpu_model->p_maxminSystem, p_constraint,
- m_core * m_powerScale *
- m_powerPeak);
-#ifdef HAVE_TRACING
- TRACE_surf_host_set_power(date, m_name,
- m_core * m_powerScale *
- m_powerPeak);
-#endif
- while ((var = lmm_get_var_from_cnst
- (surf_cpu_model->p_maxminSystem, p_constraint, &elem))) {
- CpuCas01ActionLmmPtr action = (CpuCas01ActionLmmPtr) lmm_variable_id(var);
- lmm_update_variable_bound(surf_cpu_model->p_maxminSystem,
- action->p_variable,
- m_powerScale * m_powerPeak);
- }
- if (tmgr_trace_event_free(event_type))
- p_powerEvent = NULL;
- } else if (event_type == p_stateEvent) {
- if (value > 0)
- p_stateCurrent = SURF_RESOURCE_ON;
- else {
- lmm_constraint_t cnst = p_constraint;
-
- p_stateCurrent = SURF_RESOURCE_OFF;
-
- while ((var = lmm_get_var_from_cnst(surf_cpu_model->p_maxminSystem, cnst, &elem))) {
- ActionPtr action = (ActionPtr) lmm_variable_id(var);
-
- if (action->getState() == SURF_ACTION_RUNNING ||
- action->getState() == SURF_ACTION_READY ||
- action->getState() == SURF_ACTION_NOT_IN_THE_SYSTEM) {
- action->m_finish = date;
- action->setState(SURF_ACTION_FAILED);
+ if (event == speed_.event) {
+ /* TODO (Hypervisor): do the same thing for constraint_core[i] */
+ xbt_assert(coresAmount_ == 1, "FIXME: add speed scaling code also for constraint_core[i]");
+
+ speed_.scale = value;
+ onSpeedChange();
+
+ tmgr_trace_event_unref(&speed_.event);
+ } else if (event == stateEvent_) {
+ /* TODO (Hypervisor): do the same thing for constraint_core[i] */
+ xbt_assert(coresAmount_ == 1, "FIXME: add state change code also for constraint_core[i]");
+
+ if (value > 0) {
+ if(isOff())
+ host_that_restart.push_back(getHost());
+ turnOn();
+ } else {
+ lmm_constraint_t cnst = constraint();
+ lmm_variable_t var = nullptr;
+ lmm_element_t elem = nullptr;
+ double date = surf_get_clock();
+
+ turnOff();
+
+ while ((var = lmm_get_var_from_cnst(model()->getMaxminSystem(), cnst, &elem))) {
+ Action *action = static_cast<Action*>(lmm_variable_id(var));
+
+ if (action->getState() == Action::State::running ||
+ action->getState() == Action::State::ready ||
+ action->getState() == Action::State::not_in_the_system) {
+ action->setFinishTime(date);
+ action->setState(Action::State::failed);