X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/82f048773df5d2086fe2044d2bef0cbffdf6f982..7af5f68e45deae49059e1495630646d0c875a6a5:/src/surf/plugins/energy.cpp diff --git a/src/surf/plugins/energy.cpp b/src/surf/plugins/energy.cpp index c972873381..8abd780c03 100644 --- a/src/surf/plugins/energy.cpp +++ b/src/surf/plugins/energy.cpp @@ -205,17 +205,22 @@ static void onCreation(simgrid::s4u::Host& host) { host.extension_set(new HostEnergy(&host)); } -static void onActionStateChange(simgrid::surf::CpuAction *action, e_surf_action_state_t previous) { - const char *name = getActionCpu(action)->getName(); - simgrid::surf::HostImpl *host = sg_host_by_name(name)->extension(); - simgrid::surf::VirtualMachine *vm = dynamic_cast(host); - if (vm) // If it's a VM, take the corresponding PM - host = vm->getPm()->extension(); - - HostEnergy *host_energy = host->p_host->extension(); - - if(host_energy->last_updated < surf_get_clock()) - host_energy->update(); +static void onActionStateChange(simgrid::surf::CpuAction *action, simgrid::surf::Action::State previous) { + for(simgrid::surf::Cpu* cpu : action->cpus()) { + const char *name = cpu->getName(); + sg_host_t sghost = sg_host_by_name(name); + if(sghost == NULL) + continue; + simgrid::surf::HostImpl *host = sghost->extension(); + simgrid::surf::VirtualMachine *vm = dynamic_cast(host); + if (vm) // If it's a VM, take the corresponding PM + host = vm->getPm()->extension(); + + HostEnergy *host_energy = host->p_host->extension(); + + if(host_energy->last_updated < surf_get_clock()) + host_energy->update(); + } } static void onHostStateChange(simgrid::s4u::Host &host) {