X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/a924fc6f7328160d99348f7d3de23fc50930ea03..18bee871381a6ce670d9da211f43ab9b55fdc350:/src/plugins/vm/s4u_VirtualMachine.cpp diff --git a/src/plugins/vm/s4u_VirtualMachine.cpp b/src/plugins/vm/s4u_VirtualMachine.cpp index f46ee37c9a..86a184feb8 100644 --- a/src/plugins/vm/s4u_VirtualMachine.cpp +++ b/src/plugins/vm/s4u_VirtualMachine.cpp @@ -7,11 +7,12 @@ #include "simgrid/s4u/VirtualMachine.hpp" #include "simgrid/s4u/host.hpp" #include "simgrid/simix.hpp" +#include "src/instr/instr_private.h" #include "src/plugins/vm/VirtualMachineImpl.hpp" #include "src/simix/smx_host_private.h" #include "src/surf/HostImpl.hpp" +#include "src/surf/cpu_cas01.hpp" #include "xbt/asserts.h" -#include "src/instr/instr_private.h" XBT_LOG_NEW_DEFAULT_CATEGORY(s4u_vm, "S4U virtual machines"); @@ -22,11 +23,21 @@ VirtualMachine::VirtualMachine(const char* name, s4u::Host* pm) : Host(name) { XBT_DEBUG("Create VM %s", name); - pimpl_vm_ = new surf::VirtualMachineImpl(this, pm); + pimpl_vm_ = new vm::VirtualMachineImpl(this, pm); + /* Currently, a VM uses the network resource of its physical host */ + pimpl_netcard = pm->pimpl_netcard; + // Create a VCPU for this VM + surf::CpuCas01* sub_cpu = dynamic_cast(pm->pimpl_cpu); + + pimpl_cpu = surf_cpu_model_vm->createCpu(this, sub_cpu->getSpeedPeakList(), 1 /*cores*/); + if (sub_cpu->getPState() != 0) + pimpl_cpu->setPState(sub_cpu->getPState()); + + /* Make a process container */ extension_set(new simgrid::simix::Host()); if (TRACE_msg_vm_is_enabled()) { - container_t host_container = PJ_container_get(sg_host_get_name(pm)); + container_t host_container = PJ_container_get(pm->cname()); PJ_container_new(name, INSTR_MSG_VM, host_container); } } @@ -35,7 +46,7 @@ VirtualMachine::~VirtualMachine() { onDestruction(*this); - XBT_DEBUG("destroy %s", name().c_str()); + XBT_DEBUG("destroy %s", cname()); /* FIXME: this is really strange that everything fails if the next line is removed. * This is as if we shared these data with the PM, which definitely should not be the case... @@ -46,25 +57,28 @@ VirtualMachine::~VirtualMachine() extension_set(nullptr); /* Don't free these things twice: they are the ones of my physical host */ - pimpl_cpu = nullptr; pimpl_netcard = nullptr; } bool VirtualMachine::isMigrating() { - return static_cast(pimpl_)->isMigrating; + return pimpl_vm_->isMigrating; +} +double VirtualMachine::getRamsize() +{ + return pimpl_vm_->params_.ramsize; } /** @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) { - static_cast(pimpl_)->getParams(params); + pimpl_vm_->getParams(params); } /** @brief Sets the params of that VM/PM */ void VirtualMachine::setParameters(vm_params_t params) { - simgrid::simix::kernelImmediate([&]() { static_cast(pimpl_)->setParams(params); }); + simgrid::simix::kernelImmediate([&]() { pimpl_vm_->setParams(params); }); } } // namespace simgrid