-/* Copyright (c) 2013-2022. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2013-2023. The SimGrid Team. All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
* under the terms of the license (GNU LGPL) which comes with this package. */
#include <simgrid/kernel/routing/NetZoneImpl.hpp>
#include <simgrid/s4u/Exec.hpp>
-#include "simgrid/sg_config.hpp"
#include "src/kernel/EngineImpl.hpp"
#include "src/kernel/activity/ExecImpl.hpp"
#include "src/kernel/resource/VirtualMachineImpl.hpp"
-#include "src/surf/cpu_cas01.hpp"
-#include "src/surf/cpu_ti.hpp"
+#include "src/kernel/resource/models/cpu_cas01.hpp"
+#include "src/kernel/resource/models/cpu_ti.hpp"
+#include "src/simgrid/module.hpp"
+#include "src/simgrid/sg_config.hpp"
#include <numeric>
XBT_LOG_NEW_DEFAULT_SUBCATEGORY(res_vm, ker_resource, "Virtual Machines, containing actors and mobile across hosts");
-void surf_vm_model_init_HL13(simgrid::kernel::resource::CpuModel* cpu_pm_model)
+void simgrid_vm_model_init_HL13()
{
+ auto* cpu_pm_model = simgrid::s4u::Engine::get_instance()->get_netzone_root()->get_impl()->get_cpu_pm_model().get();
auto vm_model = std::make_shared<simgrid::kernel::resource::VMModel>("VM_HL13");
auto* engine = simgrid::kernel::EngineImpl::get_instance();
if (not host.is_on()) { // just turned off.
std::vector<s4u::VirtualMachine*> trash;
/* Find all VMs living on that host */
- for (s4u::VirtualMachine* const& vm : VirtualMachineImpl::allVms_)
+ for (auto* vm : VirtualMachineImpl::allVms_)
if (vm->get_pm() == &host)
trash.push_back(vm);
- for (s4u::VirtualMachine* vm : trash)
+ for (auto* vm : trash)
vm->shutdown();
}
}
const s4u::VirtualMachine* vm = dynamic_cast<s4u::VirtualMachine*>(task.get_host());
if (vm != nullptr) {
VirtualMachineImpl* vm_impl = vm->get_vm_impl();
- vm_impl->add_active_exec();
+ for (int i = 1; i <= task.get_thread_count(); i++)
+ vm_impl->add_active_exec();
vm_impl->update_action_weight();
}
}
const s4u::VirtualMachine* vm = dynamic_cast<s4u::VirtualMachine*>(exec->get_host());
if (vm != nullptr) {
VirtualMachineImpl* vm_impl = vm->get_vm_impl();
- vm_impl->remove_active_exec();
+ for (int i = 1; i <= exec->get_thread_count(); i++)
+ vm_impl->remove_active_exec();
vm_impl->update_action_weight();
}
}
s4u::Host::on_state_change_cb(host_state_change);
s4u::Exec::on_start_cb(add_active_exec);
s4u::Activity::on_completion_cb(remove_active_exec);
- s4u::Activity::on_resumed_cb(add_active_activity);
- s4u::Activity::on_suspended_cb(remove_active_activity);
+ s4u::Activity::on_resume_cb(add_active_activity);
+ s4u::Activity::on_suspend_cb(remove_active_activity);
}
double VMModel::next_occurring_event(double now)
**/
/* iterate for all virtual machines */
- for (s4u::VirtualMachine* const& ws_vm : VirtualMachineImpl::allVms_) {
+ for (auto const* ws_vm : VirtualMachineImpl::allVms_) {
if (ws_vm->get_state() == s4u::VirtualMachine::State::SUSPENDED) // Ignore suspended VMs
continue;
not physical_host_->extension<s4u::VmHostExt>()->overcommit) { /* Need to verify that we don't overcommit */
/* Retrieve the memory occupied by the VMs on that host. Yep, we have to traverse all VMs of all hosts for that */
size_t total_ramsize_of_vms = 0;
- for (auto* const& ws_vm : allVms_)
+ for (auto const* ws_vm : allVms_)
if (physical_host_ == ws_vm->get_pm())
total_ramsize_of_vms += ws_vm->get_ramsize();
set_state(s4u::VirtualMachine::State::DESTROYED);
s4u::VirtualMachine::on_shutdown(*get_iface());
- /* FIXME: we may have to do something at the surf layer, e.g., vcpu action */
}
/** @brief Change the physical host on which the given VM is running