Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Merge branches 'master' and 'master' of scm.gforge.inria.fr:/gitroot/simgrid/simgrid
authorMartin Quinson <martin.quinson@loria.fr>
Fri, 21 Oct 2016 20:09:51 +0000 (22:09 +0200)
committerMartin Quinson <martin.quinson@loria.fr>
Fri, 21 Oct 2016 20:09:51 +0000 (22:09 +0200)
17 files changed:
include/simgrid/s4u/VirtualMachine.hpp [new file with mode: 0644]
include/simgrid/s4u/host.hpp
src/s4u/s4u_VirtualMachine.cpp [new file with mode: 0644]
src/s4u/s4u_host.cpp
src/simix/libsmx.cpp
src/simix/smx_host.cpp
src/simix/smx_vm.cpp
src/surf/HostImpl.cpp
src/surf/HostImpl.hpp
src/surf/VirtualMachineImpl.cpp [moved from src/surf/virtual_machine.cpp with 77% similarity]
src/surf/VirtualMachineImpl.hpp [moved from src/surf/virtual_machine.hpp with 84% similarity]
src/surf/host_clm03.cpp
src/surf/plugins/energy.cpp
src/surf/sg_platf.cpp
src/surf/surf_c_bindings.cpp
src/surf/surf_interface.cpp
tools/cmake/DefinePackages.cmake

diff --git a/include/simgrid/s4u/VirtualMachine.hpp b/include/simgrid/s4u/VirtualMachine.hpp
new file mode 100644 (file)
index 0000000..968090b
--- /dev/null
@@ -0,0 +1,45 @@
+/* Copyright (c) 2015-2016. The SimGrid Team. All rights reserved.          */
+
+/* This program is free software; you can redistribute it and/or modify it
+ * under the terms of the license (GNU LGPL) which comes with this package. */
+
+#ifndef SIMGRID_S4U_VM_HPP
+#define SIMGRID_S4U_VM_HPP
+
+#include <simgrid/s4u/forward.hpp>
+#include <simgrid/s4u/host.hpp>
+#include <xbt/base.h>
+
+namespace simgrid {
+
+namespace s4u {
+
+/** @ingroup s4u_api
+ *
+ * @tableofcontents
+ *
+ * A VM is a virtual machine that contains actors. The total computing power that the contained
+ * processes can get is constrained to the virtual machine size.
+ *
+ */
+XBT_PUBLIC_CLASS VirtualMachine : public s4u::Host
+{
+
+public:
+  explicit VirtualMachine(const char* name, s4u::Host* hostPm);
+
+  // No copy/move
+  VirtualMachine(VirtualMachine const&) = delete;
+  VirtualMachine& operator=(VirtualMachine const&) = delete;
+
+private:
+  virtual ~VirtualMachine();
+
+public:
+  void parameters(vm_params_t params) override;
+  void setParameters(vm_params_t params) override;
+};
+}
+} // namespace simgrid::s4u
+
+#endif /* SIMGRID_S4U_HOST_HPP */
index ac7174d..b197b72 100644 (file)
@@ -46,11 +46,16 @@ public:
   explicit Host(const char *name);
 
   /** Host destruction logic */
+protected:
+  virtual ~Host();
+
 private:
-  ~Host();
   bool currentlyDestroying_ = false;
 public:
   void destroy();
+  // No copy/move
+  Host(Host const&) = delete;
+  Host& operator=(Host const&) = delete;
 
   /** Retrieves an host from its name, or return nullptr */
   static Host* by_name_or_null(const char* name);
@@ -85,8 +90,8 @@ public:
   int pstatesCount() const;
   void setPstate(int pstate_index);
   int pstate();
-  void parameters(vm_params_t params);
-  void setParameters(vm_params_t params);
+  virtual void parameters(vm_params_t params);
+  virtual void setParameters(vm_params_t params);
   xbt_dict_t mountedStoragesAsDict(); // HACK
   xbt_dynar_t attachedStorages();
 
diff --git a/src/s4u/s4u_VirtualMachine.cpp b/src/s4u/s4u_VirtualMachine.cpp
new file mode 100644 (file)
index 0000000..1b3872c
--- /dev/null
@@ -0,0 +1,39 @@
+/* Copyright (c) 2015-2016. The SimGrid Team. All rights reserved.          */
+
+/* This program is free software; you can redistribute it and/or modify it
+ * under the terms of the license (GNU LGPL) which comes with this package. */
+
+#include "simgrid/datatypes.h"
+#include "simgrid/s4u/VirtualMachine.hpp"
+#include "simgrid/s4u/host.hpp"
+#include "simgrid/simix.hpp"
+#include "src/surf/HostImpl.hpp"
+#include "src/surf/VirtualMachineImpl.hpp"
+#include "xbt/asserts.h"
+
+namespace simgrid {
+
+namespace s4u {
+
+VirtualMachine::VirtualMachine(const char* name, s4u::Host* Pm) : Host(name)
+{
+  pimpl_ = new surf::VirtualMachineImpl(this, Pm);
+}
+
+VirtualMachine::~VirtualMachine()
+{
+  onDestruction(*this);
+}
+
+void VirtualMachine::parameters(vm_params_t params)
+{
+  this->pimpl_->getParams(params);
+}
+
+void VirtualMachine::setParameters(vm_params_t params)
+{
+  simgrid::simix::kernelImmediate([&]() { this->pimpl_->setParams(params); });
+}
+
+} // namespace simgrid
+} // namespace s4u
index 79cc9fc..ae52217 100644 (file)
@@ -196,12 +196,12 @@ int Host::pstate()
 
 void Host::parameters(vm_params_t params)
 {
-  simgrid::simix::kernelImmediate([&]() { this->pimpl_->getParams(params); });
+  THROW_IMPOSSIBLE; // This should only be used on VMs
 }
 
 void Host::setParameters(vm_params_t params)
 {
-  simgrid::simix::kernelImmediate([&]() { this->pimpl_->setParams(params); });
+  THROW_IMPOSSIBLE; // This should only be used on VMs
 }
 
 /**
index 2fa37b7..4c4bf39 100644 (file)
 
 #include <simgrid/simix/blocking_simcall.hpp>
 
-#include "src/mc/mc_replay.h"
+#include "mc/mc.h"
 #include "smx_private.h"
+#include "src/kernel/activity/SynchroComm.hpp"
 #include "src/mc/mc_forward.hpp"
-#include "xbt/ex.h"
-#include "mc/mc.h"
+#include "src/mc/mc_replay.h"
 #include "src/simix/smx_host_private.h"
-#include "src/kernel/activity/SynchroComm.hpp"
-#include "src/surf/virtual_machine.hpp"
-
+#include "src/surf/VirtualMachineImpl.hpp"
+#include "xbt/ex.h"
 
 #include <simgrid/simix.hpp>
 
index 0f0878a..9147633 100644 (file)
@@ -4,13 +4,13 @@
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
-#include "smx_private.h"
-#include <xbt/ex.hpp>
-#include "xbt/sysdep.h"
 #include "mc/mc.h"
+#include "smx_private.h"
 #include "src/mc/mc_replay.h"
-#include "src/surf/virtual_machine.hpp"
 #include "src/surf/HostImpl.hpp"
+#include "src/surf/VirtualMachineImpl.hpp"
+#include "xbt/sysdep.h"
+#include <xbt/ex.hpp>
 
 #include "src/kernel/activity/SynchroExec.hpp"
 #include "src/kernel/activity/SynchroComm.hpp"
@@ -203,9 +203,9 @@ smx_activity_t SIMIX_execution_parallel_start(const char *name, int host_nb, sg_
     host_list_cpy[i] = host_list[i];
 
   /* Check that we are not mixing VMs and PMs in the parallel task */
-  bool is_a_vm = (nullptr != dynamic_cast<simgrid::surf::VirtualMachine*>(host_list[0]->pimpl_));
+  bool is_a_vm = (nullptr != dynamic_cast<simgrid::surf::VirtualMachineImpl*>(host_list[0]->pimpl_));
   for (int i = 1; i < host_nb; i++) {
-    bool tmp_is_a_vm = (nullptr != dynamic_cast<simgrid::surf::VirtualMachine*>(host_list[i]->pimpl_));
+    bool tmp_is_a_vm = (nullptr != dynamic_cast<simgrid::surf::VirtualMachineImpl*>(host_list[i]->pimpl_));
     xbt_assert(is_a_vm == tmp_is_a_vm, "parallel_execute: mixing VMs and PMs is not supported (yet).");
   }
 
index 1203a51..002be82 100644 (file)
@@ -3,10 +3,10 @@
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
-#include "smx_private.h"
 #include "mc/mc.h"
-#include "src/surf/virtual_machine.hpp"
+#include "smx_private.h"
 #include "src/surf/HostImpl.hpp"
+#include "src/surf/VirtualMachineImpl.hpp"
 
 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(simix_vm, simix, "Logging specific to SIMIX Virtual Machines");
 
@@ -66,7 +66,7 @@ static int __can_be_started(sg_host_t vm)
 void SIMIX_vm_start(sg_host_t vm)
 {
   if (__can_be_started(vm))
-    static_cast<simgrid::surf::VirtualMachine*>(vm->pimpl_)->setState(SURF_VM_STATE_RUNNING);
+    static_cast<simgrid::surf::VirtualMachineImpl*>(vm->pimpl_)->setState(SURF_VM_STATE_RUNNING);
   else
     THROWF(vm_error, 0, "The VM %s cannot be started", vm->name().c_str());
 }
@@ -74,7 +74,7 @@ void SIMIX_vm_start(sg_host_t vm)
 
 e_surf_vm_state_t SIMIX_vm_get_state(sg_host_t vm)
 {
-  return static_cast<simgrid::surf::VirtualMachine*>(vm->pimpl_)->getState();
+  return static_cast<simgrid::surf::VirtualMachineImpl*>(vm->pimpl_)->getState();
 }
 
 /**
@@ -284,7 +284,7 @@ void SIMIX_vm_shutdown(sg_host_t vm, smx_actor_t issuer)
   }
 
   /* FIXME: we may have to do something at the surf layer, e.g., vcpu action */
-  static_cast<simgrid::surf::VirtualMachine*>(vm->pimpl_)->setState(SURF_VM_STATE_CREATED);
+  static_cast<simgrid::surf::VirtualMachineImpl*>(vm->pimpl_)->setState(SURF_VM_STATE_CREATED);
 }
 
 void simcall_HANDLER_vm_shutdown(smx_simcall_t simcall, sg_host_t vm)
index 2408c68..3fd06eb 100644 (file)
@@ -10,8 +10,8 @@
 #include "src/surf/HostImpl.hpp"
 #include "simgrid/sg_config.h"
 
+#include "VirtualMachineImpl.hpp"
 #include "network_interface.hpp"
-#include "virtual_machine.hpp"
 
 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_host, surf, "Logging specific to the SURF host module");
 
@@ -35,7 +35,7 @@ namespace surf {
 void HostModel::adjustWeightOfDummyCpuActions()
 {
   /* iterate for all virtual machines */
-  for (VirtualMachine *ws_vm : VirtualMachine::allVms_) {
+  for (VirtualMachineImpl* ws_vm : VirtualMachineImpl::allVms_) {
 
     Cpu* cpu = ws_vm->piface_->pimpl_cpu;
 
@@ -98,23 +98,15 @@ Action* HostModel::executeParallelTask(int host_nb, simgrid::s4u::Host** host_li
 /************
  * Resource *
  ************/
-HostImpl::HostImpl(simgrid::surf::HostModel* model, const char* name, xbt_dynar_t storage)
-    : PropertyHolder(nullptr), storage_(storage)
+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 */
 HostImpl::~HostImpl() = default;
 
-void HostImpl::attach(simgrid::s4u::Host* host)
-{
-  if (piface_ != nullptr)
-    xbt_die("Already attached to host %s", host->name().c_str());
-  host->pimpl_ = this;
-  piface_ = host;
-}
-
 simgrid::surf::Storage *HostImpl::findStorageOnMountList(const char* mount)
 {
   simgrid::surf::Storage *st = nullptr;
@@ -327,9 +319,9 @@ int HostImpl::fileMove(surf_file_t fd, const char* fullpath){
 
 xbt_dynar_t HostImpl::getVms()
 {
-  xbt_dynar_t dyn = xbt_dynar_new(sizeof(simgrid::surf::VirtualMachine*), nullptr);
+  xbt_dynar_t dyn = xbt_dynar_new(sizeof(simgrid::surf::VirtualMachineImpl*), nullptr);
 
-  for (VirtualMachine *ws_vm : VirtualMachine::allVms_) {
+  for (VirtualMachineImpl* ws_vm : VirtualMachineImpl::allVms_) {
     if (this == ws_vm->getPm()->pimpl_)
       xbt_dynar_push(dyn, &ws_vm);
   }
index d5d7933..56909eb 100644 (file)
@@ -69,19 +69,15 @@ public:
   /**
    * @brief Host constructor
    *
-   * @param model HostModel associated to this Host
-   * @param name The name of the Host
    * @param storage The Storage associated to this Host
    */
-  HostImpl(HostModel* model, const char* name, xbt_dynar_t storage);
+  HostImpl(s4u::Host* host, xbt_dynar_t storage);
 
   /* Host destruction logic */
   /**************************/
   virtual ~HostImpl();
 
 public:
-  void attach(simgrid::s4u::Host* host);
-
   /** @brief Return the storage of corresponding mount point */
   virtual simgrid::surf::Storage *findStorageOnMountList(const char* storage);
 
similarity index 77%
rename from src/surf/virtual_machine.cpp
rename to src/surf/VirtualMachineImpl.cpp
index aa27cf8..be31926 100644 (file)
@@ -4,16 +4,19 @@
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
+#include "src/surf/VirtualMachineImpl.hpp"
+#include "simgrid/s4u/VirtualMachine.hpp"
+
 #include <xbt/signal.hpp>
 
 #include "cpu_cas01.hpp"
-#include "virtual_machine.hpp"
 
 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_vm, surf, "Logging specific to the SURF VM module");
 
-simgrid::surf::VMModel *surf_vm_model = nullptr;
+simgrid::surf::VMModelsurf_vm_model = nullptr;
 
-void surf_vm_model_init_HL13(){
+void surf_vm_model_init_HL13()
+{
   if (surf_cpu_model_vm) {
     surf_vm_model = new simgrid::surf::VMModel();
     all_existing_models->push_back(surf_vm_model);
@@ -23,26 +26,23 @@ void surf_vm_model_init_HL13(){
 namespace simgrid {
 namespace surf {
 
-
 /*************
  * Callbacks *
  *************/
 
-simgrid::xbt::signal<void(simgrid::surf::VirtualMachine*)> onVmCreation;
-simgrid::xbt::signal<void(simgrid::surf::VirtualMachine*)> onVmDestruction;
-simgrid::xbt::signal<void(simgrid::surf::VirtualMachine*)> onVmStateChange;
+simgrid::xbt::signal<void(simgrid::surf::VirtualMachineImpl*)> onVmCreation;
+simgrid::xbt::signal<void(simgrid::surf::VirtualMachineImpl*)> onVmDestruction;
+simgrid::xbt::signal<void(simgrid::surf::VirtualMachineImpl*)> onVmStateChange;
 
 /*********
  * Model *
  *********/
 
-std::deque<VirtualMachine*> VirtualMachine::allVms_;
+std::deque<VirtualMachineImpl*> VirtualMachineImpl::allVms_;
 
-s4u::Host *VMModel::createVM(const char *name, sg_host_t host_PM)
+s4u::Host* VMModel::createVM(const char* name, sg_host_t host_PM)
 {
-  VirtualMachine* vm = new VirtualMachine(this, name, host_PM);
-  onVmCreation(vm);
-  return vm->piface_;
+  return new s4u::VirtualMachine(name, host_PM);
 }
 
 /* In the real world, processes on the guest operating system will be somewhat degraded due to virtualization overhead.
@@ -77,7 +77,7 @@ double VMModel::nextOccuringEvent(double now)
    **/
 
   /* iterate for all virtual machines */
-  for (VirtualMachine *ws_vm : VirtualMachine::allVms_) {
+  for (VirtualMachineImpl* ws_vm : VirtualMachineImpl::allVms_) {
     Cpu* cpu = ws_vm->piface_->pimpl_cpu;
     xbt_assert(cpu, "cpu-less host");
 
@@ -99,20 +99,16 @@ double VMModel::nextOccuringEvent(double now)
   return surf_cpu_model_vm->nextOccuringEvent(now);
 }
 
-
 /************
  * Resource *
  ************/
 
-VirtualMachine::VirtualMachine(HostModel* model, const char* name, simgrid::s4u::Host* host_PM)
-    : HostImpl(model, name, nullptr /*storage*/), hostPM_(host_PM)
+VirtualMachineImpl::VirtualMachineImpl(simgrid::s4u::Host* piface, simgrid::s4u::Host* host_PM)
+    : HostImpl(piface, nullptr /*storage*/), hostPM_(host_PM)
 {
   /* Register this VM to the list of all VMs */
   allVms_.push_back(this);
 
-  piface_ = new simgrid::s4u::Host(name);
-  piface_->pimpl_ = this;
-
   /* Currently, a VM uses the network resource of its physical host. In
    * host_lib, this network resource object is referred from two different keys.
    * When deregistering the reference that points the network resource object
@@ -123,7 +119,7 @@ VirtualMachine::VirtualMachine(HostModel* model, const char* name, simgrid::s4u:
 
   // //// CPU  RELATED STUFF ////
   // Roughly, create a vcpu resource by using the values of the sub_cpu one.
-  CpuCas01 *sub_cpu = dynamic_cast<CpuCas01*>(host_PM->pimpl_cpu);
+  CpuCas01sub_cpu = dynamic_cast<CpuCas01*>(host_PM->pimpl_cpu);
 
   piface_->pimpl_cpu = surf_cpu_model_vm->createCpu(piface_, sub_cpu->getSpeedPeakList(), 1 /*cores*/);
   if (sub_cpu->getPState() != 0)
@@ -133,50 +129,52 @@ VirtualMachine::VirtualMachine(HostModel* model, const char* name, simgrid::s4u:
   /* FIXME: TODO: we have to periodically input GUESTOS_NOISE to the system? how ? */
   action_ = sub_cpu->execution_start(0);
 
-  XBT_VERB("Create VM(%s)@PM(%s) with %ld mounted disks", name, hostPM_->name().c_str(), xbt_dynar_length(storage_));
+  XBT_VERB("Create VM(%s)@PM(%s) with %ld mounted disks", piface->name().c_str(), hostPM_->name().c_str(),
+           xbt_dynar_length(storage_));
 }
 
 /*
  * A physical host does not disappear in the current SimGrid code, but a VM may disappear during a simulation.
  */
-VirtualMachine::~VirtualMachine()
+VirtualMachineImpl::~VirtualMachineImpl()
 {
   onVmDestruction(this);
-  allVms_.erase( find(allVms_.begin(), allVms_.end(), this) );
+  allVms_.erase(find(allVms_.begin(), allVms_.end(), this));
 
   /* Free the cpu_action of the VM. */
   XBT_ATTRIB_UNUSED int ret = action_->unref();
   xbt_assert(ret == 1, "Bug: some resource still remains");
 }
 
-e_surf_vm_state_t VirtualMachine::getState() {
+e_surf_vm_state_t VirtualMachineImpl::getState()
+{
   return vmState_;
 }
 
-void VirtualMachine::setState(e_surf_vm_state_t state)
+void VirtualMachineImpl::setState(e_surf_vm_state_t state)
 {
   vmState_ = state;
 }
-void VirtualMachine::suspend()
+void VirtualMachineImpl::suspend()
 {
   action_->suspend();
   vmState_ = SURF_VM_STATE_SUSPENDED;
 }
 
-void VirtualMachine::resume()
+void VirtualMachineImpl::resume()
 {
   action_->resume();
   vmState_ = SURF_VM_STATE_RUNNING;
 }
 
-void VirtualMachine::save()
+void VirtualMachineImpl::save()
 {
   vmState_ = SURF_VM_STATE_SAVING;
   action_->suspend();
   vmState_ = SURF_VM_STATE_SAVED;
 }
 
-void VirtualMachine::restore()
+void VirtualMachineImpl::restore()
 {
   vmState_ = SURF_VM_STATE_RESTORING;
   action_->resume();
@@ -184,12 +182,13 @@ void VirtualMachine::restore()
 }
 
 /** @brief returns the physical machine on which the VM is running **/
-sg_host_t VirtualMachine::getPm() {
+sg_host_t VirtualMachineImpl::getPm()
+{
   return hostPM_;
 }
 
 /* Update the physical host of the given VM */
-void VirtualMachine::migrate(sg_host_t host_dest)
+void VirtualMachineImpl::migrate(sg_host_t host_dest)
 {
   const char* vm_name     = piface_->name().c_str();
   const char* pm_name_src = hostPM_->name().c_str();
@@ -215,20 +214,19 @@ void VirtualMachine::migrate(sg_host_t host_dest)
   if (old_bound != 0) {
     XBT_DEBUG("migrate VM(%s): set bound (%f) at %s", vm_name, old_bound, pm_name_dst);
     new_cpu_action->setBound(old_bound);
-   }
+  }
 
-   XBT_ATTRIB_UNUSED int ret = action_->unref();
-   xbt_assert(ret == 1, "Bug: some resource still remains");
+  XBT_ATTRIB_UNUSED int ret = action_->unref();
+  xbt_assert(ret == 1, "Bug: some resource still remains");
 
-   action_ = new_cpu_action;
+  action_ = new_cpu_action;
 
-   XBT_DEBUG("migrate VM(%s): change PM (%s to %s)", vm_name, pm_name_src, pm_name_dst);
+  XBT_DEBUG("migrate VM(%s): change PM (%s to %s)", vm_name, pm_name_src, pm_name_dst);
 }
 
-void VirtualMachine::setBound(double bound){
- action_->setBound(bound);
+void VirtualMachineImpl::setBound(double bound)
+{
+  action_->setBound(bound);
 }
-
-
 }
 }
similarity index 84%
rename from src/surf/virtual_machine.hpp
rename to src/surf/VirtualMachineImpl.hpp
index 9e5452f..99faa0b 100644 (file)
@@ -4,8 +4,8 @@
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
-#include <deque>
 #include <boost/intrusive/list.hpp>
+#include <deque>
 
 #include <xbt/base.h>
 
@@ -25,7 +25,7 @@ namespace surf {
  ***********/
 
 class XBT_PRIVATE VMModel;
-class XBT_PRIVATE VirtualMachine;
+class XBT_PRIVATE VirtualMachineImpl;
 
 /*************
  * Callbacks *
@@ -34,17 +34,17 @@ class XBT_PRIVATE VirtualMachine;
 /** @ingroup SURF_callbacks
  * @brief Callbacks fired after VM creation. Signature: `void(VirtualMachine*)`
  */
-extern XBT_PRIVATE simgrid::xbt::signal<void(simgrid::surf::VirtualMachine*)> onVmCreation;
+extern XBT_PRIVATE simgrid::xbt::signal<void(simgrid::surf::VirtualMachineImpl*)> onVmCreation;
 
 /** @ingroup SURF_callbacks
  * @brief Callbacks fired after VM destruction. Signature: `void(VirtualMachine*)`
  */
-extern XBT_PRIVATE simgrid::xbt::signal<void(simgrid::surf::VirtualMachine*)> onVmDestruction;
+extern XBT_PRIVATE simgrid::xbt::signal<void(simgrid::surf::VirtualMachineImpl*)> onVmDestruction;
 
 /** @ingroup SURF_callbacks
  * @brief Callbacks after VM State changes. Signature: `void(VirtualMachine*)`
  */
-extern XBT_PRIVATE simgrid::xbt::signal<void(simgrid::surf::VirtualMachine*)> onVmStateChange;
+extern XBT_PRIVATE simgrid::xbt::signal<void(simgrid::surf::VirtualMachineImpl*)> onVmStateChange;
 
 /************
  * Resource *
@@ -54,10 +54,10 @@ extern XBT_PRIVATE simgrid::xbt::signal<void(simgrid::surf::VirtualMachine*)> on
  * @brief SURF VM interface class
  * @details A VM represent a virtual machine
  */
-class VirtualMachine : public HostImpl {
+class VirtualMachineImpl : public HostImpl {
 public:
-  VirtualMachine(simgrid::surf::HostModel *model, const char *name, simgrid::s4u::Host *host);
-  ~VirtualMachine();
+  VirtualMachineImpl(s4u::Host* piface, s4u::Host* host);
+  ~VirtualMachineImpl();
 
   /** @brief Suspend the VM */
   virtual void suspend();
@@ -80,14 +80,15 @@ public:
   virtual void setBound(double bound);
 
   /* The vm object of the lower layer */
-  CpuAction *action_ = nullptr;
+  CpuAction* action_ = nullptr;
+
 protected:
-  simgrid::s4u::Host *hostPM_;
+  simgrid::s4u::HosthostPM_;
 
 public:
   e_surf_vm_state_t getState();
   void setState(e_surf_vm_state_t state);
-  static std::deque<VirtualMachine*> allVms_;
+  static std::deque<VirtualMachineImpl*> allVms_;
 
 protected:
   e_surf_vm_state_t vmState_ = SURF_VM_STATE_CREATED;
@@ -108,14 +109,12 @@ public:
    * @param name The name of the new VM
    * @param host_PM The real machine hosting the VM
    */
-  s4u::Host *createVM(const char *name, sg_host_t host_PM);
-  void adjustWeightOfDummyCpuActions() override {};
+  s4u::Host* createVM(const char* name, sg_host_t host_PM);
+  void adjustWeightOfDummyCpuActions() override{};
 
   double nextOccuringEvent(double now) override;
-  void updateActionsState(double /*now*/, double /*delta*/) override {};
-
+  void updateActionsState(double /*now*/, double /*delta*/) override{};
 };
-
 }
 }
 
index 72e4bd4..a60b0bf 100644 (file)
@@ -10,9 +10,9 @@
 
 #include "host_clm03.hpp"
 
+#include "VirtualMachineImpl.hpp"
 #include "cpu_cas01.hpp"
 #include "simgrid/sg_config.h"
-#include "virtual_machine.hpp"
 
 XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(surf_host);
 
index 9474751..b76c913 100644 (file)
@@ -5,10 +5,9 @@
 
 #include "simgrid/plugins/energy.h"
 #include "simgrid/simix.hpp"
-#include "src/surf/plugins/energy.hpp"
+#include "src/surf/VirtualMachineImpl.hpp"
 #include "src/surf/cpu_interface.hpp"
-#include "src/surf/virtual_machine.hpp"
-
+#include "src/surf/plugins/energy.hpp"
 #include <utility>
 
 /** @addtogroup SURF_plugin_energy
@@ -234,7 +233,7 @@ void HostEnergy::initWattsRangeList()
 
 /* **************************** events  callback *************************** */
 static void onCreation(simgrid::s4u::Host& host) {
-  if (dynamic_cast<simgrid::surf::VirtualMachine*>(host.pimpl_)) // Ignore virtual machines
+  if (dynamic_cast<simgrid::surf::VirtualMachineImpl*>(host.pimpl_)) // Ignore virtual machines
     return;
   host.extension_set(new HostEnergy(&host));
 }
@@ -246,7 +245,7 @@ static void onActionStateChange(simgrid::surf::CpuAction *action, simgrid::surf:
     if(sghost == nullptr)
       continue;
     simgrid::surf::HostImpl* host     = sghost->pimpl_;
-    simgrid::surf::VirtualMachine *vm = dynamic_cast<simgrid::surf::VirtualMachine*>(host);
+    simgrid::surf::VirtualMachineImpl* vm = dynamic_cast<simgrid::surf::VirtualMachineImpl*>(host);
     if (vm) // If it's a VM, take the corresponding PM
       host = vm->getPm()->pimpl_;
 
@@ -258,7 +257,7 @@ static void onActionStateChange(simgrid::surf::CpuAction *action, simgrid::surf:
 }
 
 static void onHostStateChange(simgrid::s4u::Host &host) {
-  if (dynamic_cast<simgrid::surf::VirtualMachine*>(host.pimpl_)) // Ignore virtual machines
+  if (dynamic_cast<simgrid::surf::VirtualMachineImpl*>(host.pimpl_)) // Ignore virtual machines
     return;
 
   HostEnergy *host_energy = host.extension<HostEnergy>();
@@ -269,7 +268,7 @@ static void onHostStateChange(simgrid::s4u::Host &host) {
 
 static void onHostDestruction(simgrid::s4u::Host& host) {
   // Ignore virtual machines
-  if (dynamic_cast<simgrid::surf::VirtualMachine*>(host.pimpl_))
+  if (dynamic_cast<simgrid::surf::VirtualMachineImpl*>(host.pimpl_))
     return;
   HostEnergy *host_energy = host.extension<HostEnergy>();
   host_energy->update();
index 9294509..c002ec7 100644 (file)
@@ -111,8 +111,7 @@ void sg_platf_new_host(sg_platf_host_cbarg_t host)
   if (host->speed_trace)
     cpu->setSpeedTrace(host->speed_trace);
 
-  simgrid::surf::HostImpl* hi = new simgrid::surf::HostImpl(surf_host_model, host->id, mount_list);
-  hi->attach(h);
+  new simgrid::surf::HostImpl(h, mount_list);
   xbt_lib_set(storage_lib, host->id, ROUTING_STORAGE_HOST_LEVEL, (void*)mount_list);
 
   mount_list = nullptr;
index c599164..6125779 100644 (file)
@@ -4,12 +4,12 @@
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
-#include "src/surf/HostImpl.hpp"
-#include "surf_interface.hpp"
+#include "VirtualMachineImpl.hpp"
 #include "network_interface.hpp"
-#include "src/instr/instr_private.h"
 #include "plugins/energy.hpp"
-#include "virtual_machine.hpp"
+#include "src/instr/instr_private.h"
+#include "src/surf/HostImpl.hpp"
+#include "surf_interface.hpp"
 
 XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(surf_kernel);
 
@@ -21,8 +21,9 @@ static simgrid::surf::HostImpl *get_casted_host(sg_host_t host){ //FIXME: killme
   return host->pimpl_;
 }
 
-static simgrid::surf::VirtualMachine *get_casted_vm(sg_host_t host){
-  return static_cast<simgrid::surf::VirtualMachine*>(host->pimpl_);
+static simgrid::surf::VirtualMachineImpl* get_casted_vm(sg_host_t host)
+{
+  return static_cast<simgrid::surf::VirtualMachineImpl*>(host->pimpl_);
 }
 
 extern double NOW;
index f90440d..76d1f3e 100644 (file)
@@ -4,19 +4,19 @@
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
-#include "src/internal_config.h"
-#include "surf_private.h"
 #include "surf_interface.hpp"
-#include "network_interface.hpp"
+#include "VirtualMachineImpl.hpp"
 #include "cpu_interface.hpp"
-#include "src/surf/HostImpl.hpp"
-#include "src/simix/smx_host_private.h"
-#include "surf_routing.hpp"
-#include "simgrid/sg_config.h"
 #include "mc/mc.h"
-#include "virtual_machine.hpp"
-#include "src/instr/instr_private.h" // TRACE_is_enabled(). FIXME: remove by subscribing tracing to the surf signals
+#include "network_interface.hpp"
 #include "simgrid/s4u/engine.hpp"
+#include "simgrid/sg_config.h"
+#include "src/instr/instr_private.h" // TRACE_is_enabled(). FIXME: remove by subscribing tracing to the surf signals
+#include "src/internal_config.h"
+#include "src/simix/smx_host_private.h"
+#include "src/surf/HostImpl.hpp"
+#include "surf_private.h"
+#include "surf_routing.hpp"
 #include <vector>
 
 XBT_LOG_NEW_CATEGORY(surf, "All SURF categories");
index a1a26fa..c66284e 100644 (file)
@@ -81,7 +81,7 @@ set(EXTRA_DIST
   src/surf/surf_private.h
   src/surf/surf_routing.hpp
   src/surf/PropertyHolder.hpp
-  src/surf/virtual_machine.hpp
+  src/surf/VirtualMachineImpl.hpp
   src/surf/host_clm03.hpp
   src/surf/HostImpl.hpp
   src/surf/ptask_L07.hpp
@@ -332,7 +332,7 @@ set(SURF_SRC
   src/surf/xml/surfxml_parseplatf.cpp
   src/surf/trace_mgr.hpp
   src/surf/trace_mgr.cpp
-  src/surf/virtual_machine.cpp
+  src/surf/VirtualMachineImpl.cpp
   src/surf/host_clm03.cpp
   src/surf/HostImpl.cpp
   src/surf/ptask_L07.cpp
@@ -391,6 +391,7 @@ set(S4U_SRC
   src/s4u/s4u_mutex.cpp
   src/s4u/s4u_conditionVariable.cpp
   src/s4u/s4u_storage.cpp
+  src/s4u/s4u_VirtualMachine.cpp
 )
 
 set(SIMGRID_SRC
@@ -653,6 +654,7 @@ set(headers_to_install
   include/simgrid/s4u/Mutex.hpp
   include/simgrid/s4u/conditionVariable.hpp
   include/simgrid/s4u/storage.hpp  
+  include/simgrid/s4u/VirtualMachine.hpp  
   include/simgrid/s4u.hpp
   include/simgrid/plugins/energy.h
   include/smpi/mpi.h