Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
destroying a VM that was not shutdown is OK
[simgrid.git] / src / msg / msg_vm.cpp
index 4ba7663..26e46b8 100644 (file)
@@ -58,7 +58,8 @@ void MSG_vm_get_params(msg_vm_t vm, vm_params_t params)
 /* **** Check state of a VM **** */
 static inline int __MSG_vm_is_state(msg_vm_t vm, e_surf_vm_state_t state)
 {
-  return static_cast<simgrid::s4u::VirtualMachine*>(vm)->pimpl_vm_->getState() == state;
+  simgrid::s4u::VirtualMachine* castedVm = static_cast<simgrid::s4u::VirtualMachine*>(vm);
+  return castedVm->pimpl_vm_ != nullptr && castedVm->pimpl_vm_->getState() == state;
 }
 
 /** @brief Returns whether the given VM has just created, not running.
@@ -153,9 +154,6 @@ 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) || __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]() {
     vm->destroy();
@@ -171,7 +169,7 @@ void MSG_vm_destroy(msg_vm_t vm)
 /** @brief Start a vm (i.e., boot the guest operating system)
  *  @ingroup msg_VMs
  *
- *  If the VM cannot be started (because of memory overprovisionning), an exception is generated.
+ *  If the VM cannot be started (because of memory over-provisioning), an exception is generated.
  */
 void MSG_vm_start(msg_vm_t vm)
 {