+static void energyVMCreatedCallback(VirtualMachine* vm) {
+ std::map<Cpu*, CpuEnergy*>::iterator cpu_energy_it = surf_energy->find(vm->p_subWs->p_cpu);
+ xbt_assert(cpu_energy_it != surf_energy->end(), "The cpu is not in surf_energy.");
+ (*surf_energy)[vm->p_cpu] = cpu_energy_it->second;
+ cpu_energy_it->second->ref(); // protect the CpuEnergy from getting deleted too early
+}
+
+/* Computes the consumption so far. Called lazily on need. */
+static void update_consumption(Cpu *cpu, CpuEnergy *cpu_energy) {