Host *host = new simgrid::surf::HostCLM03(surf_host_model, name, NULL,
(xbt_dynar_t)xbt_lib_get_or_null(storage_lib, name, ROUTING_STORAGE_HOST_LEVEL),
netElm, cpu);
- surf_callback_emit(hostCreatedCallbacks, host);
XBT_DEBUG("Create host %s with %ld mounted disks", name, xbt_dynar_length(host->p_storage));
- simgrid::Host::by_name_or_null(name)->set_facet(host);
return host;
}
surf_callback_emit(hostDestructedCallbacks, this);
}
+void Host::attach(simgrid::Host* host)
+{
+ if (p_host != nullptr)
+ xbt_die("Already attached to host %s", host->id().c_str());
+ host->set_facet(this);
+ p_host = host;
+ surf_callback_emit(hostCreatedCallbacks, this);
+}
+
void Host::setState(e_surf_resource_state_t state){
e_surf_resource_state_t old = Resource::getState();
Resource::setState(state);
/** @brief Host destructor */
~Host();
+ void attach(simgrid::Host* host);
void setState(e_surf_resource_state_t state);
/**
xbt_dynar_t p_storage;
RoutingEdge *p_netElm;
Cpu *p_cpu;
+ simgrid::Host* p_host = nullptr;
/** @brief Get the list of virtual machines on the current Host */
xbt_dynar_t getVms();
Host *HostL07Model::createHost(const char *name,RoutingEdge *netElm, Cpu *cpu)
{
- HostL07 *host = new HostL07(this, name, NULL, netElm, cpu);
-
- surf_callback_emit(hostCreatedCallbacks, host);
- simgrid::Host::by_name_or_create(name)->set_facet<Host>(host);
-
- return host;
+ return new HostL07(this, name, NULL, netElm, cpu);
}
Action *NetworkL07Model::communicate(RoutingEdge *src, RoutingEdge *dst,
host->state_trace,
host->properties);
cpu->plug(h);
- surf_host_model->createHost(host->id, net, cpu);
-
+ surf_host_model->createHost(host->id, net, cpu)->attach(h);
if (TRACE_is_enabled() && TRACE_needs_platform())
sg_instr_new_host(host);
}