Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Apply the default settings of 'smpi/buffering' too
[simgrid.git] / src / plugins / vm / VirtualMachineImpl.cpp
index a461371..b7b2002 100644 (file)
@@ -4,9 +4,9 @@
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
 #include "src/plugins/vm/VirtualMachineImpl.hpp"
+#include "simgrid/Exception.hpp"
 #include "src/include/surf/surf.hpp"
 #include "src/kernel/activity/ExecImpl.hpp"
-#include "xbt/asserts.h" // xbt_log_no_loc
 
 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_vm, surf, "Logging specific to the SURF VM module");
 
@@ -23,8 +23,8 @@ namespace vm {
 /*************
  * Callbacks *
  *************/
-simgrid::xbt::signal<void(VirtualMachineImpl&)> VirtualMachineImpl::on_creation;
-simgrid::xbt::signal<void(VirtualMachineImpl const&)> VirtualMachineImpl::on_destruction;
+xbt::signal<void(VirtualMachineImpl&)> VirtualMachineImpl::on_creation;
+xbt::signal<void(VirtualMachineImpl const&)> VirtualMachineImpl::on_destruction;
 
 /*********
  * Model *
@@ -115,7 +115,7 @@ double VMModel::next_occuring_event(double now)
 
   /* iterate for all virtual machines */
   for (s4u::VirtualMachine* const& ws_vm : VirtualMachineImpl::allVms_) {
-    surf::Cpu* cpu = ws_vm->pimpl_cpu;
+    kernel::resource::Cpu* cpu = ws_vm->pimpl_cpu;
 
     double solved_value =
         ws_vm->get_impl()->action_->get_variable()->get_value(); // this is X1 in comment above, what
@@ -173,10 +173,11 @@ VirtualMachineImpl::~VirtualMachineImpl()
 void VirtualMachineImpl::suspend(smx_actor_t issuer)
 {
   if (get_state() != s4u::VirtualMachine::state::RUNNING)
-    THROWF(vm_error, 0, "Cannot suspend VM %s: it is not running.", piface_->get_cname());
+    throw VmFailureException(XBT_THROW_POINT,
+                             xbt::string_printf("Cannot suspend VM %s: it is not running.", piface_->get_cname()));
   if (issuer->get_host() == piface_)
-    THROWF(vm_error, 0, "Actor %s cannot suspend the VM %s in which it runs", issuer->get_cname(),
-           piface_->get_cname());
+    throw VmFailureException(XBT_THROW_POINT, xbt::string_printf("Actor %s cannot suspend the VM %s in which it runs",
+                                                                 issuer->get_cname(), piface_->get_cname()));
 
   XBT_DEBUG("suspend VM(%s), where %zu processes exist", piface_->get_cname(), process_list_.size());
 
@@ -195,7 +196,8 @@ void VirtualMachineImpl::suspend(smx_actor_t issuer)
 void VirtualMachineImpl::resume()
 {
   if (get_state() != s4u::VirtualMachine::state::SUSPENDED)
-    THROWF(vm_error, 0, "Cannot resume VM %s: it was not suspended", piface_->get_cname());
+    throw VmFailureException(XBT_THROW_POINT,
+                             xbt::string_printf("Cannot resume VM %s: it was not suspended", piface_->get_cname()));
 
   XBT_DEBUG("Resume VM %s, containing %zu processes.", piface_->get_cname(), process_list_.size());
 
@@ -266,8 +268,8 @@ void VirtualMachineImpl::set_physical_host(s4u::Host* destination)
 
   /* Update vcpu's action for the new pm */
   /* create a cpu action bound to the pm model at the destination. */
-  surf::CpuAction* new_cpu_action =
-      static_cast<surf::CpuAction*>(destination->pimpl_cpu->execution_start(0, this->core_amount_));
+  kernel::resource::CpuAction* new_cpu_action =
+      static_cast<kernel::resource::CpuAction*>(destination->pimpl_cpu->execution_start(0, this->core_amount_));
 
   if (action_->get_remains_no_update() > 0)
     XBT_CRITICAL("FIXME: need copy the state(?), %f", action_->get_remains_no_update());
@@ -300,9 +302,9 @@ void VirtualMachineImpl::update_action_weight(){
   XBT_DEBUG("set the weight of the dummy CPU action of VM%p on PM to %d (#tasks: %d)", this, impact, active_tasks_);
 
   if (impact > 0)
-    action_->set_priority(1. / impact);
+    action_->set_sharing_penalty(1. / impact);
   else
-    action_->set_priority(0.);
+    action_->set_sharing_penalty(0.);
 
   action_->set_bound(std::min(impact * physical_host_->get_speed(), user_bound_));
 }