From 3fc1d8cd34e7f80a5f11efff7c7d87874a879dec Mon Sep 17 00:00:00 2001 From: Martin Quinson Date: Fri, 1 Apr 2016 21:08:33 +0200 Subject: [PATCH] Remove the properties from the host constructor --- src/surf/HostImpl.cpp | 13 ++++++------- src/surf/HostImpl.hpp | 6 +++--- src/surf/sg_platf.cpp | 9 ++++++++- src/surf/virtual_machine.cpp | 4 ++-- src/surf/virtual_machine.hpp | 3 +-- src/surf/vm_hl13.cpp | 6 +++--- src/surf/vm_hl13.hpp | 2 +- 7 files changed, 24 insertions(+), 19 deletions(-) diff --git a/src/surf/HostImpl.cpp b/src/surf/HostImpl.cpp index f990c45ea6..646f093fad 100644 --- a/src/surf/HostImpl.cpp +++ b/src/surf/HostImpl.cpp @@ -31,10 +31,10 @@ simgrid::xbt::Extension HostImpl::EXTENSION_ID; /********* * Model * *********/ -HostImpl *HostModel::createHost(const char *name,NetCard *netElm, Cpu *cpu, xbt_dict_t props){ +HostImpl *HostModel::createHost(const char *name,NetCard *netElm, Cpu *cpu){ xbt_dynar_t storageList = (xbt_dynar_t)xbt_lib_get_or_null(storage_lib, name, ROUTING_STORAGE_HOST_LEVEL); - HostImpl *host = new simgrid::surf::HostImpl(surf_host_model, name, props, storageList, cpu); + HostImpl *host = new simgrid::surf::HostImpl(surf_host_model, name, storageList, cpu); XBT_DEBUG("Create host %s with %ld mounted disks", name, xbt_dynar_length(host->p_storage)); return host; } @@ -123,19 +123,18 @@ void HostImpl::classInit() } } -HostImpl::HostImpl(simgrid::surf::HostModel *model, const char *name, xbt_dict_t props, - xbt_dynar_t storage, Cpu *cpu) +HostImpl::HostImpl(simgrid::surf::HostModel *model, const char *name, xbt_dynar_t storage, Cpu *cpu) : Resource(model, name) - , PropertyHolder(props) + , PropertyHolder(nullptr) , p_storage(storage), p_cpu(cpu) { p_params.ramsize = 0; } -HostImpl::HostImpl(simgrid::surf::HostModel *model, const char *name, xbt_dict_t props, lmm_constraint_t constraint, +HostImpl::HostImpl(simgrid::surf::HostModel *model, const char *name, lmm_constraint_t constraint, xbt_dynar_t storage, Cpu *cpu) : Resource(model, name, constraint) - , PropertyHolder(props) + , PropertyHolder(nullptr) , p_storage(storage), p_cpu(cpu) { p_params.ramsize = 0; diff --git a/src/surf/HostImpl.hpp b/src/surf/HostImpl.hpp index 66122211fc..058140b169 100644 --- a/src/surf/HostImpl.hpp +++ b/src/surf/HostImpl.hpp @@ -52,7 +52,7 @@ public: HostModel() : Model() {} ~HostModel() override {} - HostImpl *createHost(const char *name, NetCard *net, Cpu *cpu, xbt_dict_t props); + HostImpl *createHost(const char *name, NetCard *net, Cpu *cpu); virtual void adjustWeightOfDummyCpuActions(); virtual Action *executeParallelTask(int host_nb, sg_host_t *host_list, @@ -85,7 +85,7 @@ public: * @param storage The Storage associated to this Host * @param cpu The Cpu associated to this Host */ - HostImpl(HostModel *model, const char *name, xbt_dict_t props, xbt_dynar_t storage, Cpu *cpu); + HostImpl(HostModel *model, const char *name, xbt_dynar_t storage, Cpu *cpu); /** * @brief Host constructor @@ -97,7 +97,7 @@ public: * @param storage The Storage associated to this Host * @param cpu The Cpu associated to this Host */ - HostImpl(HostModel *model, const char *name, xbt_dict_t props, + HostImpl(HostModel *model, const char *name, lmm_constraint_t constraint, xbt_dynar_t storage, Cpu *cpu); /* Host destruction logic */ diff --git a/src/surf/sg_platf.cpp b/src/surf/sg_platf.cpp index 1932e5a89a..9fa57c7a29 100644 --- a/src/surf/sg_platf.cpp +++ b/src/surf/sg_platf.cpp @@ -151,7 +151,14 @@ void sg_platf_new_host(sg_platf_host_cbarg_t host) cpu->setStateTrace(host->state_trace); if (host->speed_trace) cpu->setSpeedTrace(host->speed_trace); - surf_host_model->createHost(host->id, netcard, cpu, host->properties)->attach(h); + surf_host_model->createHost(host->id, netcard, cpu)->attach(h); + + if (host->properties) { + xbt_dict_cursor_t cursor=NULL; + char *key,*data; + xbt_dict_foreach(host->properties,cursor,key,data) + h->setProperty(key,data); + } if (host->pstate != 0) cpu->setPState(host->pstate); diff --git a/src/surf/virtual_machine.cpp b/src/surf/virtual_machine.cpp index e640cc373a..37e771c020 100644 --- a/src/surf/virtual_machine.cpp +++ b/src/surf/virtual_machine.cpp @@ -32,8 +32,8 @@ VMModel::vm_list_t VMModel::ws_vms; * Resource * ************/ -VirtualMachine::VirtualMachine(HostModel *model, const char *name, xbt_dict_t props, simgrid::s4u::Host *hostPM) -: HostImpl(model, name, props, NULL, NULL, NULL) +VirtualMachine::VirtualMachine(HostModel *model, const char *name, simgrid::s4u::Host *hostPM) +: HostImpl(model, name, NULL, NULL, NULL) , p_hostPM(hostPM) { VMModel::ws_vms.push_back(*this); diff --git a/src/surf/virtual_machine.hpp b/src/surf/virtual_machine.hpp index 5c6872e1b2..4c64492549 100644 --- a/src/surf/virtual_machine.hpp +++ b/src/surf/virtual_machine.hpp @@ -58,10 +58,9 @@ public: * * @param model VMModel associated to this VM * @param name The name of the VM - * @param props Dictionary of properties associated to this VM * @param host The host */ - VirtualMachine(simgrid::surf::HostModel *model, const char *name, xbt_dict_t props, simgrid::s4u::Host *host); + VirtualMachine(simgrid::surf::HostModel *model, const char *name, simgrid::s4u::Host *host); /** @brief Destructor */ ~VirtualMachine(); diff --git a/src/surf/vm_hl13.cpp b/src/surf/vm_hl13.cpp index aee9b9927d..ad0151d985 100644 --- a/src/surf/vm_hl13.cpp +++ b/src/surf/vm_hl13.cpp @@ -33,7 +33,7 @@ void VMHL13Model::updateActionsState(double /*now*/, double /*delta*/) {} VirtualMachine *VMHL13Model::createVM(const char *name, sg_host_t host_PM) { - VirtualMachine* vm = new VMHL13(this, name, NULL, host_PM); + VirtualMachine* vm = new VMHL13(this, name, host_PM); VMCreatedCallbacks(vm); return vm; } @@ -95,8 +95,8 @@ double VMHL13Model::next_occuring_event(double now) /************ * Resource * ************/ -VMHL13::VMHL13(VMModel *model, const char* name, xbt_dict_t props, sg_host_t host_PM) - : VirtualMachine(model, name, props, host_PM) +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; diff --git a/src/surf/vm_hl13.hpp b/src/surf/vm_hl13.hpp index 7b66c2a01a..a901656b9d 100644 --- a/src/surf/vm_hl13.hpp +++ b/src/surf/vm_hl13.hpp @@ -45,7 +45,7 @@ public: class VMHL13 : public VirtualMachine { public: - VMHL13(VMModel *model, const char* name, xbt_dict_t props, sg_host_t host_PM); + VMHL13(VMModel *model, const char* name, sg_host_t host_PM); ~VMHL13() {} void suspend() override; -- 2.20.1