#include <simgrid/s4u/VirtualMachine.hpp>
#include <xbt/parse_units.hpp>
+#include "simgrid/simix.hpp"
#include "src/kernel/resource/StandardLinkImpl.hpp"
#include "src/kernel/resource/VirtualMachineImpl.hpp"
#include "src/surf/HostImpl.hpp"
return self->get_host();
}
-xbt::string const& Host::get_name() const
+std::string const& Host::get_name() const
{
return this->pimpl_->get_name();
}
Host* Host::set_property(const std::string& key, const std::string& value)
{
- kernel::actor::simcall_answered([this, &key, &value] { this->pimpl_->set_property(key, value); });
+ kernel::actor::simcall_object_access(pimpl_, [this, &key, &value] { this->pimpl_->set_property(key, value); });
return this;
}
Host* Host::set_properties(const std::unordered_map<std::string, std::string>& properties)
{
- kernel::actor::simcall_answered([this, &properties] { this->pimpl_->set_properties(properties); });
+ kernel::actor::simcall_object_access(pimpl_, [this, &properties] { this->pimpl_->set_properties(properties); });
return this;
}
* The profile must contain boolean values. */
Host* Host::set_state_profile(kernel::profile::Profile* p)
{
- kernel::actor::simcall_answered([this, p] { pimpl_cpu_->set_state_profile(p); });
+ kernel::actor::simcall_object_access(pimpl_, [this, p] { pimpl_cpu_->set_state_profile(p); });
return this;
}
/** Specify a profile modeling the external load according to an exhaustive list or a stochastic law.
*/
Host* Host::set_speed_profile(kernel::profile::Profile* p)
{
- kernel::actor::simcall_answered([this, p] { pimpl_cpu_->set_speed_profile(p); });
+ kernel::actor::simcall_object_access(pimpl_, [this, p] { pimpl_cpu_->set_speed_profile(p); });
return this;
}
Host* Host::set_sharing_policy(SharingPolicy policy, const s4u::NonLinearResourceCb& cb)
{
- kernel::actor::simcall_answered([this, policy, &cb] { pimpl_cpu_->set_sharing_policy(policy, cb); });
+ kernel::actor::simcall_object_access(pimpl_, [this, policy, &cb] { pimpl_cpu_->set_sharing_policy(policy, cb); });
return this;
}
Host* Host::set_core_count(int core_count)
{
- kernel::actor::simcall_answered([this, core_count] { this->pimpl_cpu_->set_core_count(core_count); });
+ kernel::actor::simcall_object_access(pimpl_, [this, core_count] { this->pimpl_cpu_->set_core_count(core_count); });
return this;
}
Host* Host::set_pstate_speed(const std::vector<double>& speed_per_state)
{
- kernel::actor::simcall_answered([this, &speed_per_state] { pimpl_cpu_->set_pstate_speed(speed_per_state); });
+ kernel::actor::simcall_object_access(pimpl_,
+ [this, &speed_per_state] { pimpl_cpu_->set_pstate_speed(speed_per_state); });
return this;
}
/** @brief Set the pstate at which the host should run */
Host* Host::set_pstate(unsigned long pstate_index)
{
- kernel::actor::simcall_answered([this, pstate_index] { this->pimpl_cpu_->set_pstate(pstate_index); });
+ kernel::actor::simcall_object_access(pimpl_, [this, pstate_index] { this->pimpl_cpu_->set_pstate(pstate_index); });
return this;
}
Host* Host::set_factor_cb(const std::function<CpuFactorCb>& cb)
{
- kernel::actor::simcall_answered([this, &cb] { pimpl_cpu_->set_factor_cb(cb); });
+ kernel::actor::simcall_object_access(pimpl_, [this, &cb] { pimpl_cpu_->set_factor_cb(cb); });
return this;
}
Host* Host::set_coordinates(const std::string& coords)
{
if (not coords.empty())
- kernel::actor::simcall_answered([this, coords] { this->pimpl_netpoint_->set_coordinates(coords); });
+ kernel::actor::simcall_object_access(pimpl_, [this, coords] { this->pimpl_netpoint_->set_coordinates(coords); });
return this;
}
std::vector<Disk*> Host::get_disks() const
[this, &name, core_amount, ramsize] { return this->pimpl_->create_vm(name, core_amount, ramsize); });
}
+VirtualMachine* Host::vm_by_name_or_null(const std::string& name)
+{
+ simgrid::kernel::resource::VirtualMachineImpl* vm = this->pimpl_->get_vm_by_name_or_null(name);
+ return vm ? vm->get_iface() : nullptr;
+}
+
ExecPtr Host::exec_init(double flops) const
{
return this_actor::exec_init(flops);
return simgrid::s4u::Host::by_name_or_null(name);
}
+/** @brief Retrieve a VM running on a given host from its name, or return NULL if no VM matches*/
+sg_vm_t sg_vm_by_name(sg_host_t host, const char* name)
+{
+ return host->vm_by_name_or_null(name);
+}
+
// ========= Layering madness ==============*
// ========== User data Layer ==========
if (props == nullptr)
return nullptr;
- for (auto const& elm : *props) {
- xbt_dict_set(as_dict, elm.first.c_str(), xbt_strdup(elm.second.c_str()));
+ for (auto const& [key, value] : *props) {
+ xbt_dict_set(as_dict, key.c_str(), xbt_strdup(value.c_str()));
}
return as_dict;
}
if (not props->empty()) {
XBT_INFO(" - properties:");
- for (auto const& elm : *props) {
- XBT_INFO(" %s->%s", elm.first.c_str(), elm.second.c_str());
+ for (auto const& [key, value] : *props) {
+ XBT_INFO(" %s->%s", key.c_str(), value.c_str());
}
}
}