return self->get_host();
}
-xbt::string const& Host::get_name() const
+std::string const& Host::get_name() const
{
return this->pimpl_->get_name();
}
if (is_on()) {
const kernel::actor::ActorImpl* self = kernel::actor::ActorImpl::self();
kernel::actor::simcall_answered([this, self] {
- for (VirtualMachine* const& vm : kernel::resource::VirtualMachineImpl::allVms_)
- if (vm->get_pm() == this) {
- vm->shutdown();
- vm->turn_off();
- }
this->pimpl_cpu_->turn_off();
this->pimpl_->turn_off(self);
VirtualMachine* Host::create_vm(const std::string& name, int core_amount)
{
- return new VirtualMachine(name, this, core_amount);
+ return kernel::actor::simcall_answered(
+ [this, &name, core_amount] { return this->pimpl_->create_vm(name, core_amount); });
}
VirtualMachine* Host::create_vm(const std::string& name, int core_amount, size_t ramsize)
{
- return new VirtualMachine(name, this, core_amount, ramsize);
+ return kernel::actor::simcall_answered(
+ [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 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());
}
}
}