Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Move some content out of HostImpl (into VirtualMachineImpl)
authorMartin Quinson <martin.quinson@loria.fr>
Sat, 12 Nov 2016 20:28:02 +0000 (21:28 +0100)
committerMartin Quinson <martin.quinson@loria.fr>
Sat, 12 Nov 2016 20:28:02 +0000 (21:28 +0100)
src/s4u/s4u_VirtualMachine.cpp
src/simix/smx_vm.cpp
src/surf/HostImpl.cpp
src/surf/HostImpl.hpp
src/surf/VirtualMachineImpl.cpp
src/surf/VirtualMachineImpl.hpp

index 1b3872c..8a8e190 100644 (file)
@@ -12,7 +12,6 @@
 #include "xbt/asserts.h"
 
 namespace simgrid {
-
 namespace s4u {
 
 VirtualMachine::VirtualMachine(const char* name, s4u::Host* Pm) : Host(name)
@@ -25,14 +24,16 @@ VirtualMachine::~VirtualMachine()
   onDestruction(*this);
 }
 
+/** @brief Retrieve a copy of the parameters of that VM/PM
+ *  @details The ramsize and overcommit fields are used on the PM too */
 void VirtualMachine::parameters(vm_params_t params)
 {
-  this->pimpl_->getParams(params);
+  static_cast<surf::VirtualMachineImpl*>(pimpl_)->getParams(params);
 }
-
+/** @brief Sets the params of that VM/PM */
 void VirtualMachine::setParameters(vm_params_t params)
 {
-  simgrid::simix::kernelImmediate([&]() { this->pimpl_->setParams(params); });
+  simgrid::simix::kernelImmediate([&]() { static_cast<surf::VirtualMachineImpl*>(pimpl_)->setParams(params); });
 }
 
 } // namespace simgrid
index 002be82..2866042 100644 (file)
@@ -4,6 +4,7 @@
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
 #include "mc/mc.h"
+#include "simgrid/s4u/VirtualMachine.hpp"
 #include "smx_private.h"
 #include "src/surf/HostImpl.hpp"
 #include "src/surf/VirtualMachineImpl.hpp"
@@ -14,7 +15,7 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY(simix_vm, simix, "Logging specific to SIMIX Virt
 static long host_get_ramsize(sg_host_t vm, int *overcommit)
 {
   s_vm_params_t params;
-  vm->pimpl_->getParams(&params);
+  static_cast<simgrid::s4u::VirtualMachine*>(vm)->parameters(&params);
 
   if (overcommit)
     *overcommit = params.overcommit;
index 3fd06eb..f745663 100644 (file)
@@ -101,7 +101,6 @@ Action* HostModel::executeParallelTask(int host_nb, simgrid::s4u::Host** host_li
 HostImpl::HostImpl(s4u::Host* host, xbt_dynar_t storage) : PropertyHolder(nullptr), storage_(storage), piface_(host)
 {
   piface_->pimpl_ = this;
-  params_.ramsize = 0;
 }
 
 /** @brief use destroy() instead of this destructor */
@@ -329,15 +328,4 @@ xbt_dynar_t HostImpl::getVms()
   return dyn;
 }
 
-void HostImpl::getParams(vm_params_t params)
-{
-  *params = params_;
-}
-
-void HostImpl::setParams(vm_params_t params)
-{
-  /* may check something here. */
-  params_ = *params;
-}
-
 }}
index 56909eb..21908ea 100644 (file)
@@ -192,15 +192,7 @@ public:
   /** @brief Get the list of virtual machines on the current Host */
   xbt_dynar_t getVms();
 
-  /* common with vm */
-  /** @brief Retrieve a copy of the parameters of that VM/PM
-   *  @details The ramsize and overcommit fields are used on the PM too */
-  void getParams(vm_params_t params);
-  /** @brief Sets the params of that VM/PM */
-  void setParams(vm_params_t params);
   simgrid::s4u::Host* getHost() { return piface_; }
-private:
-  s_vm_params_t params_;
 };
 
 }
index 8ad7f58..fbf47e5 100644 (file)
@@ -124,6 +124,9 @@ VirtualMachineImpl::VirtualMachineImpl(simgrid::s4u::Host* piface, simgrid::s4u:
   /* FIXME: TODO: we have to periodically input GUESTOS_NOISE to the system? how ? */
   action_ = sub_cpu->execution_start(0);
 
+  /* Initialize the VM parameters */
+  params_.ramsize = 0;
+
   XBT_VERB("Create VM(%s)@PM(%s) with %ld mounted disks", piface->name().c_str(), hostPM_->name().c_str(),
            xbt_dynar_length(storage_));
 }
@@ -225,5 +228,16 @@ void VirtualMachineImpl::setBound(double bound)
 {
   action_->setBound(bound);
 }
+
+void VirtualMachineImpl::getParams(vm_params_t params)
+{
+  *params = params_;
+}
+
+void VirtualMachineImpl::setParams(vm_params_t params)
+{
+  /* may check something here. */
+  params_ = *params;
+}
 }
 }
index 2e3b054..8a8cc68 100644 (file)
@@ -56,7 +56,7 @@ extern XBT_PRIVATE simgrid::xbt::signal<void(simgrid::surf::VirtualMachineImpl*)
  */
 class VirtualMachineImpl : public HostImpl {
 public:
-  VirtualMachineImpl(s4u::Host* piface, s4u::Host* host);
+  explicit VirtualMachineImpl(s4u::Host* piface, s4u::Host* host);
   ~VirtualMachineImpl();
 
   /** @brief Suspend the VM */
@@ -79,6 +79,9 @@ public:
 
   virtual void setBound(double bound);
 
+  void getParams(vm_params_t params);
+  void setParams(vm_params_t params);
+
   /* The vm object of the lower layer */
   CpuAction* action_ = nullptr;
 
@@ -90,6 +93,9 @@ public:
   void setState(e_surf_vm_state_t state);
   static std::deque<VirtualMachineImpl*> allVms_;
 
+private:
+  s_vm_params_t params_;
+
 protected:
   e_surf_vm_state_t vmState_ = SURF_VM_STATE_CREATED;
 };