]> AND Public Git Repository - simgrid.git/blobdiff - teshsuite/s4u/vm-live-migration/vm-live-migration.cpp
Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Sonar and minor improv in doc
[simgrid.git] / teshsuite / s4u / vm-live-migration / vm-live-migration.cpp
index b5b78b2220ac84fd1021e0d87ff30db3a1e88cf2..33524187aff2aa4b8ae70b80603d5856889a9962 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2007-2020. The SimGrid Team.
+/* Copyright (c) 2007-2021. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
@@ -19,9 +19,10 @@ static void task_executor()
   simgrid::s4u::this_actor::sleep_for(3); // Breaks everything
 
   ptr->wait();
-  XBT_INFO("Task done. It's running on %s@%s that runs at %.0ef/s. host2 runs at %.0ef/s", ptr->get_host()->get_cname(),
-           dynamic_cast<simgrid::s4u::VirtualMachine*>(ptr->get_host())->get_pm()->get_cname(),
-           ptr->get_host()->get_speed(), simgrid::s4u::Host::by_name("host2")->get_speed());
+  const auto* vm = dynamic_cast<simgrid::s4u::VirtualMachine*>(ptr->get_host());
+  xbt_assert(vm != nullptr, "Hey, I expected to run on a VM");
+  XBT_INFO("Task done. It's running on %s@%s that runs at %.0ef/s. host2 runs at %.0ef/s", vm->get_cname(),
+           vm->get_pm()->get_cname(), vm->get_speed(), simgrid::s4u::Host::by_name("host2")->get_speed());
 }
 
 int main(int argc, char* argv[])
@@ -42,7 +43,7 @@ int main(int argc, char* argv[])
 
   simgrid::s4u::Actor::create("migration", pm, [vm]() {
     XBT_INFO("%s migration started", vm->get_cname());
-    auto* old = vm->get_pm();
+    const auto* old = vm->get_pm();
 
     sg_vm_migrate(vm, simgrid::s4u::Host::by_name("host2"));