Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Update XBT_ATTRIB_DEPRECATED_v??? in comments.
[simgrid.git] / src / s4u / s4u_VirtualMachine.cpp
index 284e5eb..71a8f7a 100644 (file)
@@ -1,19 +1,20 @@
-/* Copyright (c) 2015-2022. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2015-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/simix.hpp"
 #include <simgrid/Exception.hpp>
 #include <simgrid/kernel/routing/NetPoint.hpp>
 #include <simgrid/vm.h>
 
 #include "src/kernel/resource/VirtualMachineImpl.hpp"
-#include "src/surf/cpu_cas01.hpp"
+#include "src/kernel/resource/models/cpu_cas01.hpp"
 
 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(s4u_vm, s4u, "S4U virtual machines");
 
 namespace simgrid::s4u {
-xbt::signal<void(VirtualMachine&)> VirtualMachine::on_creation;
+xbt::signal<void(VirtualMachine&)> VirtualMachine::on_vm_creation;
 xbt::signal<void(VirtualMachine const&)> VirtualMachine::on_start;
 xbt::signal<void(VirtualMachine const&)> VirtualMachine::on_started;
 xbt::signal<void(VirtualMachine const&)> VirtualMachine::on_shutdown;
@@ -21,7 +22,7 @@ xbt::signal<void(VirtualMachine const&)> VirtualMachine::on_suspend;
 xbt::signal<void(VirtualMachine const&)> VirtualMachine::on_resume;
 xbt::signal<void(VirtualMachine const&)> VirtualMachine::on_migration_start;
 xbt::signal<void(VirtualMachine const&)> VirtualMachine::on_migration_end;
-xbt::signal<void(VirtualMachine const&)> VirtualMachine::on_destruction;
+xbt::signal<void(VirtualMachine const&)> VirtualMachine::on_vm_destruction;
 
 xbt::Extension<Host, VmHostExt> VmHostExt::EXTENSION_ID;
 
@@ -31,7 +32,8 @@ void VmHostExt::ensureVmExtInstalled()
     EXTENSION_ID = Host::extension_create<VmHostExt>();
 }
 
-VirtualMachine::VirtualMachine(const std::string& name, s4u::Host* physical_host, int core_amount, size_t ramsize)
+VirtualMachine::VirtualMachine(const std::string& name, s4u::Host* physical_host, int core_amount,
+                               size_t ramsize) // XBT_ATTRIB_DEPRECATED_v336
     : Host(new kernel::resource::VirtualMachineImpl(name, this, physical_host, core_amount, ramsize))
     , pimpl_vm_(dynamic_cast<kernel::resource::VirtualMachineImpl*>(Host::get_impl()))
 {
@@ -72,7 +74,8 @@ void VirtualMachine::destroy()
     shutdown();
 
     XBT_DEBUG("destroy %s", get_cname());
-    on_destruction(*this);
+    on_vm_destruction(*this);
+    on_this_vm_destruction(*this);
     /* Then, destroy the VM object */
     kernel::actor::simcall_answered(
         [this]() { get_vm_impl()->get_physical_host()->get_impl()->destroy_vm(get_name()); });
@@ -80,7 +83,7 @@ void VirtualMachine::destroy()
 
   if (not this_actor::is_maestro() && this_actor::get_host() == this) {
     XBT_VERB("Launch another actor on physical host %s to destroy my own VM: %s", get_pm()->get_cname(), get_cname());
-    simgrid::s4u::Actor::create(get_cname() + std::string("-vm_destroy"), get_pm(), destroy_code);
+    simgrid::s4u::Actor::create(get_name() + "-vm_destroy", get_pm(), destroy_code);
     simgrid::s4u::this_actor::yield();
     XBT_CRITICAL("I should be dead now!");
     DIE_IMPOSSIBLE;
@@ -118,7 +121,7 @@ VirtualMachine* VirtualMachine::set_ramsize(size_t ramsize)
 /** @brief Set a CPU bound for a given VM.
  *  @ingroup msg_VMs
  *
- * 1. Note that in some cases MSG_task_set_bound() may not intuitively work for VMs.
+ * 1. Note that in some cases sg_exec_set_bound() may not intuitively work for VMs.
  *
  * For example,
  *  On PM0, there are Task1 and VM0.
@@ -136,7 +139,7 @@ VirtualMachine* VirtualMachine::set_ramsize(size_t ramsize)
  * It should be the sum of all tasks on the VM. But, this solution might be costly, because we have to scan all tasks
  * on the VM in share_resource() or we have to trap both the start and end of task execution.
  *
- * The current solution is to use setBound(), which allows us to directly set the bound of the dummy CPU action.
+ * The current solution is to use set_bound(), which allows us to directly set the bound of the dummy CPU action.
  *
  * 2. Note that bound == 0 means no bound (i.e., unlimited). But, if a host has multiple CPU cores, the CPU share of a
  *    computation task (or a VM) never exceeds the capacity of a CPU core.