Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
more refactoring of get_instance calls
[simgrid.git] / src / plugins / vm / VirtualMachineImpl.cpp
index 19d1847..0f389ca 100644 (file)
@@ -20,8 +20,9 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY(res_vm, ker_resource, "Virtual Machines, contain
 void surf_vm_model_init_HL13(simgrid::kernel::resource::CpuModel* cpu_pm_model)
 {
   auto vm_model = std::make_shared<simgrid::vm::VMModel>("VM_HL13");
+  auto* engine  = simgrid::kernel::EngineImpl::get_instance();
 
-  simgrid::kernel::EngineImpl::get_instance()->add_model(vm_model, {cpu_pm_model});
+  engine->add_model(vm_model, {cpu_pm_model});
   std::shared_ptr<simgrid::kernel::resource::CpuModel> cpu_model_vm;
 
   auto cpu_optim = simgrid::config::get_value<std::string>("cpu/optim");
@@ -30,8 +31,8 @@ void surf_vm_model_init_HL13(simgrid::kernel::resource::CpuModel* cpu_pm_model)
   } else {
     cpu_model_vm = std::make_shared<simgrid::kernel::resource::CpuCas01Model>("VmCpu_Cas01");
   }
-  simgrid::kernel::EngineImpl::get_instance()->add_model(cpu_model_vm, {cpu_pm_model, vm_model.get()});
-  simgrid::s4u::Engine::get_instance()->get_netzone_root()->get_impl()->set_cpu_vm_model(cpu_model_vm);
+  engine->add_model(cpu_model_vm, {cpu_pm_model, vm_model.get()});
+  engine->get_netzone_root()->set_cpu_vm_model(cpu_model_vm);
 }
 
 namespace simgrid {
@@ -156,10 +157,10 @@ double VMModel::next_occurring_event(double now)
     if (ws_vm->get_state() == s4u::VirtualMachine::State::SUSPENDED) // Ignore suspended VMs
       continue;
 
-    const kernel::resource::Cpu* cpu = ws_vm->pimpl_cpu;
+    const kernel::resource::CpuImpl* cpu = ws_vm->get_cpu();
 
     // solved_value below is X1 in comment above: what this VM got in the sharing on the PM
-    double solved_value = ws_vm->get_vm_impl()->get_action()->get_variable()->get_value();
+    double solved_value = ws_vm->get_vm_impl()->get_action()->get_rate();
     XBT_DEBUG("assign %f to vm %s @ pm %s", solved_value, ws_vm->get_cname(), ws_vm->get_pm()->get_cname());
 
     kernel::lmm::System* vcpu_system = cpu->get_model()->get_maxmin_system();
@@ -184,7 +185,7 @@ VirtualMachineImpl::VirtualMachineImpl(const std::string& name, s4u::VirtualMach
    * The value for GUESTOS_NOISE corresponds to the cost of the global action associated to the VM.  It corresponds to
    * the cost of a VM running no tasks.
    */
-  action_ = physical_host_->pimpl_cpu->execution_start(0, core_amount_);
+  action_ = physical_host_->get_cpu()->execution_start(0, core_amount_);
 
   // It's empty for now, so it should not request resources in the PM
   update_action_weight();
@@ -288,13 +289,13 @@ void VirtualMachineImpl::set_physical_host(s4u::Host* destination)
   piface_->set_netpoint(destination->get_netpoint());
 
   /* Adapt the speed, pstate and other physical characteristics to the one of our new physical CPU */
-  piface_->pimpl_cpu->reset_vcpu(destination->pimpl_cpu);
+  piface_->get_cpu()->reset_vcpu(destination->get_cpu());
 
   physical_host_ = destination;
 
   /* Update vcpu's action for the new pm */
   /* create a cpu action bound to the pm model at the destination. */
-  kernel::resource::CpuAction* new_cpu_action = destination->pimpl_cpu->execution_start(0, this->core_amount_);
+  kernel::resource::CpuAction* new_cpu_action = destination->get_cpu()->execution_start(0, this->core_amount_);
 
   if (action_->get_remains_no_update() > 0)
     XBT_CRITICAL("FIXME: need copy the state(?), %f", action_->get_remains_no_update());