From 0ceb6b86f9b13248051e884d6a1199d7175b9398 Mon Sep 17 00:00:00 2001 From: Arnaud Giersch Date: Tue, 30 Mar 2021 21:45:44 +0200 Subject: [PATCH] Revert "Fix MC tests." This reverts commit ba5cf16371aed445f20533645ca049990862630a. A fix for the MC side is coming soon. --- include/simgrid/s4u/Host.hpp | 8 +++----- src/plugins/vm/s4u_VirtualMachine.cpp | 2 +- src/s4u/s4u_Host.cpp | 10 ++++++++++ src/surf/HostImpl.cpp | 14 +++++++------- src/surf/HostImpl.hpp | 6 ++++++ 5 files changed, 27 insertions(+), 13 deletions(-) diff --git a/include/simgrid/s4u/Host.hpp b/include/simgrid/s4u/Host.hpp index 2fec149e8e..b23efc3c63 100644 --- a/include/simgrid/s4u/Host.hpp +++ b/include/simgrid/s4u/Host.hpp @@ -46,7 +46,7 @@ class XBT_PUBLIC Host : public xbt::Extendable { 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: diff --git a/src/plugins/vm/s4u_VirtualMachine.cpp b/src/plugins/vm/s4u_VirtualMachine.cpp index 4b966f794d..7450b709cd 100644 --- a/src/plugins/vm/s4u_VirtualMachine.cpp +++ b/src/plugins/vm/s4u_VirtualMachine.cpp @@ -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(Host::get_impl())) { XBT_DEBUG("Create VM %s", get_cname()); diff --git a/src/s4u/s4u_Host.cpp b/src/s4u/s4u_Host.cpp index bb56640b9d..2689b56341 100644 --- a/src/s4u/s4u_Host.cpp +++ b/src/s4u/s4u_Host.cpp @@ -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()) { diff --git a/src/surf/HostImpl.cpp b/src/surf/HostImpl.cpp index 8919977f99..9b8ec04df4 100644 --- a/src/surf/HostImpl.cpp +++ b/src/surf/HostImpl.cpp @@ -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; } diff --git a/src/surf/HostImpl.hpp b/src/surf/HostImpl.hpp index 1b08609b11..2429c3d91b 100644 --- a/src/surf/HostImpl.hpp +++ b/src/surf/HostImpl.hpp @@ -50,6 +50,7 @@ class XBT_PRIVATE HostImpl : public xbt::PropertyHolder { std::vector actors_at_boot_; s4u::Host piface_; std::vector 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 get_all_actors(); -- 2.20.1