Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Reduce the foreign usages of s4u::Host::pimpl_cpu, which should be private
[simgrid.git] / src / plugins / vm / s4u_VirtualMachine.cpp
index 2985b7c..d603636 100644 (file)
@@ -33,12 +33,15 @@ VirtualMachine::VirtualMachine(const char* name, s4u::Host* pm, int coreAmount,
 
   /* Currently, a VM uses the network resource of its physical host */
   pimpl_netpoint = pm->pimpl_netpoint;
+
   // Create a VCPU for this VM
-  surf::CpuCas01* sub_cpu = dynamic_cast<surf::CpuCas01*>(pm->pimpl_cpu);
+  std::vector<double>* speeds = new std::vector<double>();
+  for (int i = 0; i < pm->getPstatesCount(); i++)
+    speeds->push_back(pm->getPstateSpeed(i));
 
-  pimpl_cpu = surf_cpu_model_vm->createCpu(this, sub_cpu->getSpeedPeakList(), coreAmount);
-  if (sub_cpu->getPState() != 0)
-    pimpl_cpu->setPState(sub_cpu->getPState());
+  surf_cpu_model_vm->createCpu(this, speeds, pm->getCoreCount());
+  if (pm->getPstate() != 0)
+    setPstate(pm->getPstate());
 
   /* Make a process container */
   extension_set<simgrid::simix::Host>(new simgrid::simix::Host());
@@ -46,7 +49,7 @@ VirtualMachine::VirtualMachine(const char* name, s4u::Host* pm, int coreAmount,
 
 VirtualMachine::~VirtualMachine()
 {
-  onDestruction(*this);
+  on_destruction(*this);
 
   XBT_DEBUG("destroy %s", get_cname());