From: Martin Quinson Date: Sat, 12 Nov 2016 20:28:02 +0000 (+0100) Subject: Move some content out of HostImpl (into VirtualMachineImpl) X-Git-Tag: v3_14~215 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/f4c5410f81d07f93436c5986356e6d78f4121f8f Move some content out of HostImpl (into VirtualMachineImpl) --- diff --git a/src/s4u/s4u_VirtualMachine.cpp b/src/s4u/s4u_VirtualMachine.cpp index 1b3872ced6..8a8e190c39 100644 --- a/src/s4u/s4u_VirtualMachine.cpp +++ b/src/s4u/s4u_VirtualMachine.cpp @@ -12,7 +12,6 @@ #include "xbt/asserts.h" namespace simgrid { - namespace s4u { VirtualMachine::VirtualMachine(const char* name, s4u::Host* Pm) : Host(name) @@ -25,14 +24,16 @@ VirtualMachine::~VirtualMachine() onDestruction(*this); } +/** @brief Retrieve a copy of the parameters of that VM/PM + * @details The ramsize and overcommit fields are used on the PM too */ void VirtualMachine::parameters(vm_params_t params) { - this->pimpl_->getParams(params); + static_cast(pimpl_)->getParams(params); } - +/** @brief Sets the params of that VM/PM */ void VirtualMachine::setParameters(vm_params_t params) { - simgrid::simix::kernelImmediate([&]() { this->pimpl_->setParams(params); }); + simgrid::simix::kernelImmediate([&]() { static_cast(pimpl_)->setParams(params); }); } } // namespace simgrid diff --git a/src/simix/smx_vm.cpp b/src/simix/smx_vm.cpp index 002be82015..2866042664 100644 --- a/src/simix/smx_vm.cpp +++ b/src/simix/smx_vm.cpp @@ -4,6 +4,7 @@ * under the terms of the license (GNU LGPL) which comes with this package. */ #include "mc/mc.h" +#include "simgrid/s4u/VirtualMachine.hpp" #include "smx_private.h" #include "src/surf/HostImpl.hpp" #include "src/surf/VirtualMachineImpl.hpp" @@ -14,7 +15,7 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY(simix_vm, simix, "Logging specific to SIMIX Virt static long host_get_ramsize(sg_host_t vm, int *overcommit) { s_vm_params_t params; - vm->pimpl_->getParams(¶ms); + static_cast(vm)->parameters(¶ms); if (overcommit) *overcommit = params.overcommit; diff --git a/src/surf/HostImpl.cpp b/src/surf/HostImpl.cpp index 3fd06eb932..f745663142 100644 --- a/src/surf/HostImpl.cpp +++ b/src/surf/HostImpl.cpp @@ -101,7 +101,6 @@ Action* HostModel::executeParallelTask(int host_nb, simgrid::s4u::Host** host_li HostImpl::HostImpl(s4u::Host* host, xbt_dynar_t storage) : PropertyHolder(nullptr), storage_(storage), piface_(host) { piface_->pimpl_ = this; - params_.ramsize = 0; } /** @brief use destroy() instead of this destructor */ @@ -329,15 +328,4 @@ xbt_dynar_t HostImpl::getVms() return dyn; } -void HostImpl::getParams(vm_params_t params) -{ - *params = params_; -} - -void HostImpl::setParams(vm_params_t params) -{ - /* may check something here. */ - params_ = *params; -} - }} diff --git a/src/surf/HostImpl.hpp b/src/surf/HostImpl.hpp index 56909eb1ed..21908ea70c 100644 --- a/src/surf/HostImpl.hpp +++ b/src/surf/HostImpl.hpp @@ -192,15 +192,7 @@ public: /** @brief Get the list of virtual machines on the current Host */ xbt_dynar_t getVms(); - /* common with vm */ - /** @brief Retrieve a copy of the parameters of that VM/PM - * @details The ramsize and overcommit fields are used on the PM too */ - void getParams(vm_params_t params); - /** @brief Sets the params of that VM/PM */ - void setParams(vm_params_t params); simgrid::s4u::Host* getHost() { return piface_; } -private: - s_vm_params_t params_; }; } diff --git a/src/surf/VirtualMachineImpl.cpp b/src/surf/VirtualMachineImpl.cpp index 8ad7f58438..fbf47e5ae2 100644 --- a/src/surf/VirtualMachineImpl.cpp +++ b/src/surf/VirtualMachineImpl.cpp @@ -124,6 +124,9 @@ VirtualMachineImpl::VirtualMachineImpl(simgrid::s4u::Host* piface, simgrid::s4u: /* FIXME: TODO: we have to periodically input GUESTOS_NOISE to the system? how ? */ action_ = sub_cpu->execution_start(0); + /* Initialize the VM parameters */ + params_.ramsize = 0; + XBT_VERB("Create VM(%s)@PM(%s) with %ld mounted disks", piface->name().c_str(), hostPM_->name().c_str(), xbt_dynar_length(storage_)); } @@ -225,5 +228,16 @@ void VirtualMachineImpl::setBound(double bound) { action_->setBound(bound); } + +void VirtualMachineImpl::getParams(vm_params_t params) +{ + *params = params_; +} + +void VirtualMachineImpl::setParams(vm_params_t params) +{ + /* may check something here. */ + params_ = *params; +} } } diff --git a/src/surf/VirtualMachineImpl.hpp b/src/surf/VirtualMachineImpl.hpp index 2e3b054d3d..8a8cc68461 100644 --- a/src/surf/VirtualMachineImpl.hpp +++ b/src/surf/VirtualMachineImpl.hpp @@ -56,7 +56,7 @@ extern XBT_PRIVATE simgrid::xbt::signal allVms_; +private: + s_vm_params_t params_; + protected: e_surf_vm_state_t vmState_ = SURF_VM_STATE_CREATED; };