Пример #1
0
/**
 * \brief Add a "host" to the network element list
 */
static void parse_S_host(sg_platf_host_cbarg_t host)
{
  if (current_routing->p_hierarchy == SURF_ROUTING_NULL)
    current_routing->p_hierarchy = SURF_ROUTING_BASE;
  xbt_assert(!sg_host_by_name(host->id),
		     "Reading a host, processing unit \"%s\" already exists", host->id);

  RoutingEdge *info = new RoutingEdgeImpl(xbt_strdup(host->id),
		                                    -1,
		                                    SURF_NETWORK_ELEMENT_HOST,
		                                    current_routing);
  info->setId(current_routing->parsePU(info));
  sg_host_edge_set(sg_host_by_name_or_create(host->id), info);
  XBT_DEBUG("Having set name '%s' id '%d'", host->id, info->getId());

  if(mount_list){
    xbt_lib_set(storage_lib, host->id, ROUTING_STORAGE_HOST_LEVEL, (void *) mount_list);
    mount_list = NULL;
  }

  if (host->coord && strcmp(host->coord, "")) {
    unsigned int cursor;
    char*str;

    if (!COORD_HOST_LEVEL)
      xbt_die ("To use host coordinates, please add --cfg=network/coordinates:yes to your command line");
    /* Pre-parse the host coordinates -- FIXME factorize with routers by overloading the routing->parse_PU function*/
    xbt_dynar_t ctn_str = xbt_str_split_str(host->coord, " ");
    xbt_dynar_t ctn = xbt_dynar_new(sizeof(double),NULL);
    xbt_dynar_foreach(ctn_str,cursor, str) {
      double val = atof(str);
      xbt_dynar_push(ctn,&val);
    }
Пример #2
0
/************
 * Resource *
 ************/
VMHL13::VMHL13(VMModel *model, const char* name, sg_host_t host_PM)
 : VirtualMachine(model, name, host_PM)
{
  /* Currently, we assume a VM has no storage. */
  p_storage = NULL;

  /* Currently, a VM uses the network resource of its physical host. In
   * host_lib, this network resource object is referred from two different keys.
   * When deregistering the reference that points the network resource object
   * from the VM name, we have to make sure that the system does not call the
   * free callback for the network resource object. The network resource object
   * is still used by the physical machine. */
  sg_host_t host_VM = sg_host_by_name_or_create(name);
  host_VM->pimpl_netcard = host_PM->pimpl_netcard;

  p_vm_state = SURF_VM_STATE_CREATED;

  // //// CPU  RELATED STUFF ////
  // Roughly, create a vcpu resource by using the values of the sub_cpu one.
  CpuCas01 *sub_cpu = static_cast<CpuCas01*>(host_PM->pimpl_cpu);

  p_cpu = surf_cpu_model_vm->createCpu(host_VM, // the machine hosting the VM
      sub_cpu->getSpeedPeakList(), 1 /*cores*/);
  if (sub_cpu->getPState() != 0)
    p_cpu->setPState(sub_cpu->getPState());

  /* We create cpu_action corresponding to a VM process on the host operating system. */
  /* FIXME: TODO: we have to periodically input GUESTOS_NOISE to the system? how ? */
  action_ = sub_cpu->execution_start(0);

  XBT_VERB("Create VM(%s)@PM(%s) with %ld mounted disks", name, hostPM_->name().c_str(), xbt_dynar_length(p_storage));
}