Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Revert "Fix MC tests."
authorArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Tue, 30 Mar 2021 19:45:44 +0000 (21:45 +0200)
committerArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Tue, 30 Mar 2021 19:54:01 +0000 (21:54 +0200)
This reverts commit ba5cf16371aed445f20533645ca049990862630a.

A fix for the MC side is coming soon.

include/simgrid/s4u/Host.hpp
src/plugins/vm/s4u_VirtualMachine.cpp
src/s4u/s4u_Host.cpp
src/surf/HostImpl.cpp
src/surf/HostImpl.hpp

index 2fec149..b23efc3 100644 (file)
@@ -46,7 +46,7 @@ class XBT_PUBLIC Host : public xbt::Extendable<Host> {
   surf::HostImpl* const pimpl_;
 
 public:
-  explicit Host(const std::string& name, surf::HostImpl* pimpl) : pimpl_(pimpl), name_(name) {}
+  explicit Host(surf::HostImpl* pimpl) : pimpl_(pimpl) {}
 
 protected:
   virtual ~Host(); // Call destroy() instead of manually deleting it.
@@ -79,9 +79,9 @@ public:
   static Host* current();
 
   /** Retrieves the name of that host as a C++ string */
-  xbt::string const& get_name() const { return name_; };
+  xbt::string const& get_name() const;
   /** Retrieves the name of that host as a C string */
-  const char* get_cname() const { return name_.c_str(); };
+  const char* get_cname() const;
 
   kernel::routing::NetPoint* get_netpoint() const { return pimpl_netpoint_; }
 
@@ -190,8 +190,6 @@ public:
   surf::HostImpl* get_impl() const { return pimpl_; }
 
 private:
-  /* Host name must be kept in the s4u side to be accessible by MC process */
-  xbt::string name_{"noname"};
   kernel::routing::NetPoint* pimpl_netpoint_ = nullptr;
 
 public:
index 4b966f7..7450b70 100644 (file)
@@ -30,7 +30,7 @@ VirtualMachine::VirtualMachine(const std::string& name, s4u::Host* physical_host
 }
 
 VirtualMachine::VirtualMachine(const std::string& name, s4u::Host* physical_host, int core_amount, size_t ramsize)
-    : Host(name, new vm::VirtualMachineImpl(name, this, physical_host, core_amount, ramsize))
+    : Host(new vm::VirtualMachineImpl(name, this, physical_host, core_amount, ramsize))
     , pimpl_vm_(dynamic_cast<vm::VirtualMachineImpl*>(Host::get_impl()))
 {
   XBT_DEBUG("Create VM %s", get_cname());
index bb56640..2689b56 100644 (file)
@@ -74,6 +74,16 @@ Host* Host::current()
   return self->get_host();
 }
 
+xbt::string const& Host::get_name() const
+{
+  return this->pimpl_->get_name();
+}
+
+const char* Host::get_cname() const
+{
+  return this->pimpl_->get_cname();
+}
+
 void Host::turn_on()
 {
   if (not is_on()) {
index 8919977..9b8ec04 100644 (file)
@@ -25,16 +25,16 @@ namespace surf {
 /************
  * Resource *
  ************/
-HostImpl::HostImpl(const std::string& name, s4u::Host* piface) : piface_(name, this)
+HostImpl::HostImpl(const std::string& name, s4u::Host* piface) : piface_(this), name_(name)
 {
-  xbt_assert(s4u::Host::by_name_or_null(name) == nullptr, "Refusing to create a second host named '%s'.", name.c_str());
-  s4u::Engine::get_instance()->host_register(name, piface);
+  xbt_assert(s4u::Host::by_name_or_null(name_) == nullptr, "Refusing to create a second host named '%s'.", get_cname());
+  s4u::Engine::get_instance()->host_register(name_, piface);
 }
 
-HostImpl::HostImpl(const std::string& name) : piface_(name, this)
+HostImpl::HostImpl(const std::string& name) : piface_(this), name_(name)
 {
-  xbt_assert(s4u::Host::by_name_or_null(name) == nullptr, "Refusing to create a second host named '%s'.", name.c_str());
-  s4u::Engine::get_instance()->host_register(name, &piface_);
+  xbt_assert(s4u::Host::by_name_or_null(name_) == nullptr, "Refusing to create a second host named '%s'.", get_cname());
+  s4u::Engine::get_instance()->host_register(name_, &piface_);
 }
 
 HostImpl::~HostImpl()
@@ -63,7 +63,7 @@ HostImpl::~HostImpl()
 void HostImpl::destroy()
 {
   s4u::Host::on_destruction(*this->get_iface());
-  s4u::Engine::get_instance()->host_unregister(std::string(get_iface()->get_name()));
+  s4u::Engine::get_instance()->host_unregister(std::string(name_));
   delete this;
 }
 
index 1b08609..2429c3d 100644 (file)
@@ -50,6 +50,7 @@ class XBT_PRIVATE HostImpl : public xbt::PropertyHolder {
   std::vector<kernel::actor::ProcessArg*> actors_at_boot_;
   s4u::Host piface_;
   std::vector<kernel::resource::DiskImpl*> disks_;
+  xbt::string name_{"noname"};
 
 protected:
   virtual ~HostImpl(); // Use destroy() instead of this destructor.
@@ -69,6 +70,11 @@ public:
   virtual const s4u::Host* get_iface() const { return &piface_; }
   virtual s4u::Host* get_iface() { return &piface_; }
 
+  /** Retrieves the name of that host as a C++ string */
+  xbt::string const& get_name() const { return name_; }
+  /** Retrieves the name of that host as a C string */
+  const char* get_cname() const { return name_.c_str(); }
+
   void turn_on() const;
   void turn_off(const kernel::actor::ActorImpl* issuer);
   std::vector<s4u::ActorPtr> get_all_actors();