Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
code simplifications in VMs
authorMartin Quinson <martin.quinson@loria.fr>
Sun, 16 Oct 2016 14:14:06 +0000 (16:14 +0200)
committerMartin Quinson <martin.quinson@loria.fr>
Sun, 16 Oct 2016 14:44:25 +0000 (16:44 +0200)
include/simgrid/s4u/host.hpp
src/simix/smx_vm.cpp
src/surf/HostImpl.hpp
src/surf/virtual_machine.cpp

index 3583def..2eeded4 100644 (file)
@@ -44,12 +44,11 @@ XBT_PUBLIC_CLASS Host :
 
 public:
   explicit Host(const char *name);
+
   /** Host destruction logic */
-protected:
-  ~Host(); // TODO, make me private
 private:
+  ~Host();
   bool currentlyDestroying_ = false;
-
 public:
   void destroy();
 
@@ -72,6 +71,7 @@ public:
   void turnOff();
   /** Returns if that host is currently up and running */
   bool isOn();
+  /** Returns if that host is currently down and offline */
   bool isOff() { return !isOn(); }
 
   double speed();
index 77c24f0..e582a31 100644 (file)
@@ -298,12 +298,11 @@ void simcall_HANDLER_vm_shutdown(smx_simcall_t simcall, sg_host_t vm)
   SIMIX_vm_shutdown(vm, simcall->issuer);
 }
 
-extern xbt_dict_t host_list; // FIXME:killme don't dupplicate the content of s4u::Host this way
-                             /**
-                              * @brief Function to destroy a SIMIX VM host.
-                              *
-                              * @param vm the vm host to destroy (a sg_host_t)
-                              */
+/**
+ * @brief Function to destroy a SIMIX VM host.
+ *
+ * @param vm the vm host to destroy (a sg_host_t)
+ */
 void SIMIX_vm_destroy(sg_host_t vm)
 {
   /* this code basically performs a similar thing like SIMIX_host_destroy() */
index 695e0c0..32d9417 100644 (file)
@@ -223,8 +223,8 @@ public:
     {THROW_IMPOSSIBLE;} // FIXME: Host should not be a Resource
 
 public:
-  xbt_dynar_t storage_;
-  Cpu *cpu_;
+  xbt_dynar_t storage_        = nullptr;
+  Cpu* cpu_                   = nullptr;
   simgrid::s4u::Host* piface_ = nullptr;
 
   /** @brief Get the list of virtual machines on the current Host */
index 79a112b..794ec01 100644 (file)
@@ -103,34 +103,27 @@ double VMModel::nextOccuringEvent(double now)
  * Resource *
  ************/
 
-VirtualMachine::VirtualMachine(HostModel *model, const char *name, simgrid::s4u::Host *host_PM)
-: HostImpl(model, name, nullptr, nullptr, nullptr)
-, hostPM_(host_PM)
+VirtualMachine::VirtualMachine(HostModel* model, const char* name, simgrid::s4u::Host* host_PM)
+    : HostImpl(model, name, nullptr /*constraint*/, nullptr /*storage*/, nullptr /*cpu*/), hostPM_(host_PM)
 {
   /* Register this VM to the list of all VMs */
   allVms_.push_back(this);
   piface_ = new simgrid::s4u::Host(name);
   piface_->extension_set<simgrid::surf::HostImpl>(this);
 
-  /* Currently, we assume a VM has no storage. */
-  storage_ = nullptr;
-
   /* 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
    * from the VM name, we have to make sure that the system does not call the
    * free callback for the network resource object. The network resource object
    * is still used by the physical machine. */
-  sg_host_t host_VM      = piface_;
-  host_VM->pimpl_netcard = host_PM->pimpl_netcard;
-
-  vmState_ = SURF_VM_STATE_CREATED;
+  piface_->pimpl_netcard = host_PM->pimpl_netcard;
 
   // //// 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);
 
-  cpu_ = surf_cpu_model_vm->createCpu(host_VM, sub_cpu->getSpeedPeakList(), 1 /*cores*/);
+  cpu_ = surf_cpu_model_vm->createCpu(piface_, sub_cpu->getSpeedPeakList(), 1 /*cores*/);
   if (sub_cpu->getPState() != 0)
     cpu_->setPState(sub_cpu->getPState());