Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
VM: code simplification by ensuring that the piface field is set
authorMartin Quinson <martin.quinson@loria.fr>
Sun, 28 Aug 2016 16:56:10 +0000 (18:56 +0200)
committerMartin Quinson <martin.quinson@loria.fr>
Sun, 28 Aug 2016 16:56:13 +0000 (18:56 +0200)
- that field points to the s4u vision of myself.
- Fix the prototype of surf::VMModel::createVM() to ease the life
  of its unique user

src/simix/libsmx.cpp
src/surf/virtual_machine.cpp
src/surf/virtual_machine.hpp
src/surf/vm_hl13.cpp
src/surf/vm_hl13.hpp

index 91447fe..f31aa0e 100644 (file)
@@ -194,8 +194,7 @@ e_smx_state_t simcall_execution_wait(smx_activity_t execution)
 sg_host_t simcall_vm_create(const char *name, sg_host_t phys_host)
 {
   return simgrid::simix::kernelImmediate([&] {
 sg_host_t simcall_vm_create(const char *name, sg_host_t phys_host)
 {
   return simgrid::simix::kernelImmediate([&] {
-    surf_vm_model->createVM(name, phys_host);
-    sg_host_t host = sg_host_by_name(name);
+    sg_host_t host = surf_vm_model->createVM(name, phys_host);
     SIMIX_host_create(host);
 
     return host;
     SIMIX_host_create(host);
 
     return host;
index 4b4a895..ea65bc7 100644 (file)
@@ -39,7 +39,8 @@ VirtualMachine::VirtualMachine(HostModel *model, const char *name, simgrid::s4u:
 , hostPM_(hostPM)
 {
   VMModel::ws_vms.push_back(*this);
 , hostPM_(hostPM)
 {
   VMModel::ws_vms.push_back(*this);
-  simgrid::s4u::Host::by_name_or_create(name)->extension_set<simgrid::surf::HostImpl>(this);
+  piface = simgrid::s4u::Host::by_name_or_create(name);
+  piface->extension_set<simgrid::surf::HostImpl>(this);
 }
 
 /*
 }
 
 /*
index c69a11c..2ba1859 100644 (file)
@@ -114,7 +114,7 @@ public:
    * @param name The name of the new VM
    * @param host_PM The real machine hosting the VM
    */
    * @param name The name of the new VM
    * @param host_PM The real machine hosting the VM
    */
-  virtual VirtualMachine *createVM(const char *name, sg_host_t host_PM)=0;
+  virtual s4u::Host *createVM(const char *name, sg_host_t host_PM)=0;
   void adjustWeightOfDummyCpuActions() {};
 
   typedef boost::intrusive::member_hook<
   void adjustWeightOfDummyCpuActions() {};
 
   typedef boost::intrusive::member_hook<
index c51615e..09cb663 100644 (file)
@@ -28,11 +28,11 @@ VMHL13Model::VMHL13Model() : VMModel() {}
 
 void VMHL13Model::updateActionsState(double /*now*/, double /*delta*/) {}
 
 
 void VMHL13Model::updateActionsState(double /*now*/, double /*delta*/) {}
 
-VirtualMachine *VMHL13Model::createVM(const char *name, sg_host_t host_PM)
+s4u::Host *VMHL13Model::createVM(const char *name, sg_host_t host_PM)
 {
   VirtualMachine* vm = new VMHL13(this, name, host_PM);
   VMCreatedCallbacks(vm);
 {
   VirtualMachine* vm = new VMHL13(this, name, host_PM);
   VMCreatedCallbacks(vm);
-  return vm;
+  return vm->piface;
 }
 
 /* In the real world, processes on the guest operating system will be somewhat degraded due to virtualization overhead.
 }
 
 /* In the real world, processes on the guest operating system will be somewhat degraded due to virtualization overhead.
index 478b509..54642d3 100644 (file)
@@ -33,7 +33,7 @@ public:
   VMHL13Model();
   ~VMHL13Model(){};
 
   VMHL13Model();
   ~VMHL13Model(){};
 
-  VirtualMachine *createVM(const char *name, sg_host_t host_PM) override;
+  s4u::Host *createVM(const char *name, sg_host_t host_PM) override;
   double next_occuring_event(double now) override;
   void adjustWeightOfDummyCpuActions() override {};
   void updateActionsState(double /*now*/, double /*delta*/) override;
   double next_occuring_event(double now) override;
   void adjustWeightOfDummyCpuActions() override {};
   void updateActionsState(double /*now*/, double /*delta*/) override;