demonstrates how we can generate a nice graphical representation of the
platform.
+General:
+ - Modified the host_by_name functions:
+ - Now, they return only hosts, not VMs, and in a much more efficient way.
+ - If one wants to find a VM by name, he now needs to know the host on
+ which it runs and call vm_by_name (or manually iterate over the list of hosts)
+
Tools:
- Enhancements to the graphicator tool:
- Allow to dump the platform topology as a CSV file representing the edges
const char* vm_name = argv[1];
const char* dst_pm_name = argv[2];
- sg_vm_t vm = (sg_vm_t)sg_host_by_name(vm_name);
+ sg_host_t src_pm = sg_host_self();
+ sg_vm_t vm = (sg_vm_t)sg_vm_by_name(src_pm,vm_name);
sg_host_t dst_pm = sg_host_by_name(dst_pm_name);
vm_migrate(vm, dst_pm);
/** Finds a host from its name */
XBT_PUBLIC sg_host_t sg_host_by_name(const char* name);
+XBT_PUBLIC sg_vm_t sg_vm_by_name(sg_host_t host, const char* name);
/** @brief Return the name of the sg_host_t. */
XBT_PUBLIC const char* sg_host_get_name(const_sg_host_t host);
VirtualMachine* create_vm(const std::string& name, int core_amount);
VirtualMachine* create_vm(const std::string& name, int core_amount, size_t ramsize);
+ /** Retrieve a VM running on this host from its name, or return nullptr */
+ VirtualMachine* vm_by_name_or_null(const std::string& name);
void route_to(const Host* dest, std::vector<Link*>& links, double* latency) const;
void route_to(const Host* dest, std::vector<kernel::resource::StandardLinkImpl*>& links, double* latency) const;
resource::HostImpl* NetZoneImpl::get_host_by_name_or_null(const std::string& name) const
{
- for (auto const& [_, host] : hosts_) {
- if (host->get_name() == name)
- return host;
- /* keep old behavior where host and VMs were saved together on EngineImpl::hosts_
- * get hosts returns VMs too */
- auto* vm = host->get_vm_by_name_or_null(name);
- if (vm)
- return vm;
- }
+ auto host_it = hosts_.find(name);
+ if(host_it != hosts_.end())
+ return host_it->second;
for (const auto* child : children_) {
auto* host = child->get_host_by_name_or_null(name);
[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 ==========