A
lgorithmique
N
umérique
D
istribuée
Public GIT Repository
projects
/
simgrid.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
| inline |
side by side
Allow an actor to destroy its own VM.
[simgrid.git]
/
src
/
plugins
/
vm
/
s4u_VirtualMachine.cpp
diff --git
a/src/plugins/vm/s4u_VirtualMachine.cpp
b/src/plugins/vm/s4u_VirtualMachine.cpp
index
f3c7658
..
ff4b0ad
100644
(file)
--- a/
src/plugins/vm/s4u_VirtualMachine.cpp
+++ b/
src/plugins/vm/s4u_VirtualMachine.cpp
@@
-60,8
+60,6
@@
VirtualMachine::~VirtualMachine()
{
on_destruction(*this);
- XBT_DEBUG("destroy %s", get_cname());
-
/* Don't free these things twice: they are the ones of my physical host */
set_netpoint(nullptr);
}
@@
-97,7
+95,7
@@
void VirtualMachine::start()
}
}
- this->pimpl_vm_->set_state(
VirtualMachine::s
tate::RUNNING);
+ this->pimpl_vm_->set_state(
S
tate::RUNNING);
});
on_started(*this);
@@
-125,15
+123,28
@@
void VirtualMachine::shutdown()
void VirtualMachine::destroy()
{
- /* First, terminate all processes on the VM if necessary */
- shutdown();
-
- /* Then, destroy the VM object */
- kernel::actor::simcall([this]() {
- auto impl = get_impl();
- delete this; // delete iface first
- impl->destroy();
- });
+ auto destroy_code = [this]() {
+ /* First, terminate all processes on the VM if necessary */
+ shutdown();
+
+ XBT_DEBUG("destroy %s", get_cname());
+
+ /* Then, destroy the VM object */
+ kernel::actor::simcall([this]() {
+ get_impl()->destroy();
+ delete this;
+ });
+ };
+
+ if (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("-destroy"), get_pm(), destroy_code);
+ simgrid::s4u::this_actor::yield();
+ XBT_CRITICAL("I should be dead now!");
+ DIE_IMPOSSIBLE;
+ }
+
+ destroy_code();
}
simgrid::s4u::Host* VirtualMachine::get_pm() const
@@
-147,7
+158,7
@@
VirtualMachine* VirtualMachine::set_pm(simgrid::s4u::Host* pm)
return this;
}
-VirtualMachine::
s
tate VirtualMachine::get_state() const
+VirtualMachine::
S
tate VirtualMachine::get_state() const
{
return kernel::actor::simcall([this]() { return pimpl_vm_->get_state(); });
}
@@
-243,19
+254,19
@@
void sg_vm_set_bound(sg_vm_t vm, double bound)
/** @brief Returns whether the given VM has just created, not running. */
int sg_vm_is_created(const_sg_vm_t vm)
{
- return vm->get_state() == simgrid::s4u::VirtualMachine::
s
tate::CREATED;
+ return vm->get_state() == simgrid::s4u::VirtualMachine::
S
tate::CREATED;
}
/** @brief Returns whether the given VM is currently running */
int sg_vm_is_running(const_sg_vm_t vm)
{
- return vm->get_state() == simgrid::s4u::VirtualMachine::
s
tate::RUNNING;
+ return vm->get_state() == simgrid::s4u::VirtualMachine::
S
tate::RUNNING;
}
/** @brief Returns whether the given VM is currently suspended, not running. */
int sg_vm_is_suspended(const_sg_vm_t vm)
{
- return vm->get_state() == simgrid::s4u::VirtualMachine::
s
tate::SUSPENDED;
+ return vm->get_state() == simgrid::s4u::VirtualMachine::
S
tate::SUSPENDED;
}
/** @brief Start a vm (i.e., boot the guest operating system)