Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
s4u::VM: make getState() public, and add a state for destroyed VMs
authorMartin Quinson <martin.quinson@loria.fr>
Tue, 21 Mar 2017 22:28:12 +0000 (23:28 +0100)
committerMartin Quinson <martin.quinson@loria.fr>
Wed, 22 Mar 2017 00:44:13 +0000 (01:44 +0100)
include/simgrid/s4u/VirtualMachine.hpp
src/msg/msg_vm.cpp
src/plugins/vm/VirtualMachineImpl.cpp
src/plugins/vm/s4u_VirtualMachine.cpp

index 6dfb999..0d3c791 100644 (file)
@@ -14,6 +14,7 @@ typedef enum {
   SURF_VM_STATE_CREATED, /**< created, but not yet started */
   SURF_VM_STATE_RUNNING,
   SURF_VM_STATE_SUSPENDED, /**< Suspend/resume does not involve disk I/O, so we assume there is no transition states. */
+  SURF_VM_STATE_DESTROYED
 } e_surf_vm_state_t;
 
 namespace simgrid {
@@ -51,6 +52,8 @@ public:
   double getRamsize();
   simgrid::s4u::Host* pm();
 
+  e_surf_vm_state_t getState();
+
   /* FIXME: protect me */
   simgrid::vm::VirtualMachineImpl* pimpl_vm_ = nullptr;
 };
index c08b2c7..837268e 100644 (file)
@@ -153,7 +153,8 @@ void MSG_vm_destroy(msg_vm_t vm)
   if (MSG_vm_is_running(vm))
     MSG_vm_shutdown(vm);
 
-  xbt_assert(MSG_vm_is_created(vm), "shutdown the given VM before destroying it");
+  xbt_assert(MSG_vm_is_created(vm) || __MSG_vm_is_state(vm, SURF_VM_STATE_DESTROYED),
+             "shutdown the given VM before destroying it");
 
   /* Then, destroy the VM object */
   simgrid::simix::kernelImmediate([vm]() {
index fc5c0c0..02f74dc 100644 (file)
@@ -220,7 +220,7 @@ void VirtualMachineImpl::shutdown(smx_actor_t issuer)
     SIMIX_process_kill(smx_process, issuer);
   }
 
-  setState(SURF_VM_STATE_CREATED);
+  setState(SURF_VM_STATE_DESTROYED);
 
   /* FIXME: we may have to do something at the surf layer, e.g., vcpu action */
 }
index 97d2749..261f63a 100644 (file)
@@ -66,6 +66,10 @@ simgrid::s4u::Host* VirtualMachine::pm()
 {
   return pimpl_vm_->getPm();
 }
+e_surf_vm_state_t VirtualMachine::getState()
+{
+  return pimpl_vm_->getState();
+}
 
 /** @brief Retrieve a copy of the parameters of that VM/PM
  *  @details The ramsize and overcommit fields are used on the PM too */