Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Host::get_englobing_zone() returns the englobing netzone
[simgrid.git] / src / s4u / s4u_Host.cpp
index 46d86bb..db85aa3 100644 (file)
@@ -7,6 +7,8 @@
 #include "simgrid/s4u/Actor.hpp"
 #include "simgrid/s4u/Engine.hpp"
 #include "simgrid/s4u/Exec.hpp"
+#include "simgrid/s4u/VirtualMachine.hpp"
+#include "src/plugins/vm/VirtualMachineImpl.hpp"
 #include "src/simix/smx_private.hpp"
 #include "src/surf/HostImpl.hpp"
 
@@ -98,6 +100,11 @@ void Host::turn_off()
 {
   if (is_on()) {
     simix::simcall([this] {
+      for (VirtualMachine* const& vm : vm::VirtualMachineImpl::allVms_)
+        if (vm->get_pm() == this) {
+          vm->shutdown();
+          vm->turn_off();
+        }
       this->pimpl_cpu->turn_off();
       this->pimpl_->turn_off();
 
@@ -164,6 +171,20 @@ void Host::route_to(Host* dest, std::vector<kernel::resource::LinkImpl*>& links,
   }
 }
 
+/** @brief Returns the networking zone englobing that host */
+NetZone* Host::get_englobing_zone()
+{
+  return pimpl_netpoint->get_englobing_zone()->get_iface();
+}
+
+void Host::send_to(Host* dest, double byte_amount)
+{
+  std::vector<Host*> m_host_list   = {this, dest};
+  std::vector<double> flops_amount = {0, 0};
+  std::vector<double> bytes_amount = {0, byte_amount, 0, 0};
+  this_actor::parallel_execute(m_host_list, flops_amount, bytes_amount);
+}
+
 /** Get the properties assigned to a host */
 const std::unordered_map<std::string, std::string>* Host::get_properties() const
 {
@@ -584,6 +605,11 @@ double sg_host_route_bandwidth(sg_host_t from, sg_host_t to)
   return min_bandwidth;
 }
 
+void sg_host_send_to(sg_host_t from, sg_host_t to, double byte_amount)
+{
+  from->send_to(to, byte_amount);
+}
+
 /** @brief Displays debugging information about a host */
 void sg_host_dump(sg_host_t host)
 {