Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Rename VirtualMachine::get_impl() to not hide Host::get_impl().
[simgrid.git] / src / plugins / vm / VmLiveMigration.cpp
index 6dafe97..77d9b5c 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2013-2020. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2013-2021. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -30,12 +30,10 @@ void MigrationRx::operator()()
       std::string("__mig_stage3:") + vm_->get_cname() + "(" + src_pm_->get_cname() + "-" + dst_pm_->get_cname() + ")";
 
   while (not received_finalize) {
-    const std::string* payload = static_cast<std::string*>(mbox->get());
+    auto payload = mbox->get_unique<std::string>();
 
     if (finalize_task_name == *payload)
       received_finalize = true;
-
-    delete payload;
   }
 
   // Here Stage 1, 2  and 3 have been performed.
@@ -50,7 +48,7 @@ void MigrationRx::operator()()
   vm_->resume();
 
   // Now the VM is running on the new host (the migration is completed) (even if the SRC crash)
-  vm_->get_impl()->end_migration();
+  vm_->get_vm_impl()->end_migration();
   XBT_DEBUG("VM(%s) moved from PM(%s) to PM(%s)", vm_->get_cname(), src_pm_->get_cname(), dst_pm_->get_cname());
 
   if (TRACE_vm_is_enabled()) {
@@ -180,7 +178,7 @@ void MigrationTx::operator()()
       XBT_CRITICAL("bug");
   } catch (const Exception&) {
     // hostfailure (if you want to know whether this is the SRC or the DST check directly in send_migration_data code)
-    // Stop the dirty page tracking an return (there is no memory space to release)
+    // Stop the dirty page tracking and return (there is no memory space to release)
     sg_vm_stop_dirty_page_tracking(vm_);
     return;
   }
@@ -219,7 +217,7 @@ void MigrationTx::operator()()
       } catch (const Exception&) {
         // hostfailure (if you want to know whether this is the SRC or the DST check directly in send_migration_data
         // code)
-        // Stop the dirty page tracking an return (there is no memory space to release)
+        // Stop the dirty page tracking and return (there is no memory space to release)
         sg_vm_stop_dirty_page_tracking(vm_);
         return;
       }
@@ -262,7 +260,7 @@ void MigrationTx::operator()()
     sendMigrationData(remaining_size, 3, 0, mig_speed, -1);
   } catch (const Exception&) {
     // hostfailure (if you want to know whether this is the SRC or the DST check directly in send_migration_data code)
-    // Stop the dirty page tracking an return (there is no memory space to release)
+    // Stop the dirty page tracking and return (there is no memory space to release)
     vm_->resume();
     return;
   }
@@ -276,11 +274,11 @@ void MigrationTx::operator()()
 
 static void onVirtualMachineShutdown(simgrid::s4u::VirtualMachine const& vm)
 {
-  if (vm.get_impl()->is_migrating()) {
+  if (vm.get_vm_impl()->is_migrating()) {
     vm.extension<simgrid::vm::VmMigrationExt>()->rx_->kill();
     vm.extension<simgrid::vm::VmMigrationExt>()->tx_->kill();
     vm.extension<simgrid::vm::VmMigrationExt>()->issuer_->kill();
-    vm.get_impl()->end_migration();
+    vm.get_vm_impl()->end_migration();
   }
 }
 
@@ -310,7 +308,7 @@ simgrid::s4u::VirtualMachine* sg_vm_create_migratable(simgrid::s4u::Host* pm, co
 
 int sg_vm_is_migrating(const simgrid::s4u::VirtualMachine* vm)
 {
-  return vm->get_impl()->is_migrating();
+  return vm->get_vm_impl()->is_migrating();
 }
 
 void sg_vm_migrate(simgrid::s4u::VirtualMachine* vm, simgrid::s4u::Host* dst_pm)
@@ -329,12 +327,12 @@ void sg_vm_migrate(simgrid::s4u::VirtualMachine* vm, simgrid::s4u::Host* dst_pm)
     throw simgrid::VmFailureException(
         XBT_THROW_POINT,
         simgrid::xbt::string_printf("Cannot migrate VM '%s' that is not running yet.", vm->get_cname()));
-  if (vm->get_impl()->is_migrating())
+  if (vm->get_vm_impl()->is_migrating())
     throw simgrid::VmFailureException(
         XBT_THROW_POINT,
         simgrid::xbt::string_printf("Cannot migrate VM '%s' that is already migrating.", vm->get_cname()));
 
-  vm->get_impl()->start_migration();
+  vm->get_vm_impl()->start_migration();
   simgrid::s4u::VirtualMachine::on_migration_start(*vm);
 
   std::string rx_name =
@@ -353,10 +351,10 @@ void sg_vm_migrate(simgrid::s4u::VirtualMachine* vm, simgrid::s4u::Host* dst_pm)
   XBT_DEBUG("wait for reception of the final ACK (i.e. migration has been correctly performed");
   simgrid::s4u::Mailbox* mbox_ctl = simgrid::s4u::Mailbox::by_name(
       std::string("__mbox_mig_ctl:") + vm->get_cname() + "(" + src_pm->get_cname() + "-" + dst_pm->get_cname() + ")");
-  delete static_cast<std::string*>(mbox_ctl->get());
+  mbox_ctl->get_unique<std::string>();
   tx->join();
   rx->join();
 
-  vm->get_impl()->end_migration();
+  vm->get_vm_impl()->end_migration();
   simgrid::s4u::VirtualMachine::on_migration_end(*vm);
 }