X-Git-Url: http://bilbo.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/67d66b0cf79b9fc02c0450f254584693dbf21d3b..ab5814bd4ea6117ecf9ac2df328333e89eb45f5f:/src/plugins/vm/VmLiveMigration.cpp diff --git a/src/plugins/vm/VmLiveMigration.cpp b/src/plugins/vm/VmLiveMigration.cpp index f4dd67457c..be895e159d 100644 --- a/src/plugins/vm/VmLiveMigration.cpp +++ b/src/plugins/vm/VmLiveMigration.cpp @@ -1,9 +1,10 @@ -/* Copyright (c) 2013-2021. The SimGrid Team. All rights reserved. */ +/* Copyright (c) 2013-2023. 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. */ #include +#include #include "src/instr/instr_private.hpp" #include "src/kernel/resource/VirtualMachineImpl.hpp" @@ -11,9 +12,7 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY(vm_live_migration, s4u, "S4U virtual machines live migration"); -namespace simgrid { -namespace plugin { -namespace vm { +namespace simgrid::plugin::vm { xbt::Extension VmMigrationExt::EXTENSION_ID; void VmMigrationExt::ensureVmMigrationExtInstalled() @@ -28,7 +27,7 @@ void MigrationRx::operator()() bool received_finalize = false; std::string finalize_task_name = - std::string("__mig_stage3:") + vm_->get_cname() + "(" + src_pm_->get_cname() + "-" + dst_pm_->get_cname() + ")"; + "__mig_stage3:" + vm_->get_name() + "(" + src_pm_->get_name() + "-" + dst_pm_->get_name() + ")"; while (not received_finalize) { auto payload = mbox->get_unique(); @@ -73,7 +72,7 @@ void MigrationRx::operator()() } // Inform the SRC that the migration has been correctly performed auto* payload = new std::string("__mig_stage4:"); - *payload = *payload + vm_->get_cname() + "(" + src_pm_->get_cname() + "-" + dst_pm_->get_cname() + ")"; + *payload = *payload + vm_->get_name() + "(" + src_pm_->get_name() + "-" + dst_pm_->get_name() + ")"; mbox_ctl->put(payload, 0); @@ -94,22 +93,20 @@ static sg_size_t get_updated_size(double computed, double dp_rate, sg_size_t dp_ sg_size_t MigrationTx::sendMigrationData(sg_size_t size, int stage, int stage2_round, double mig_speed, double timeout) { sg_size_t sent = size; - auto* msg = new std::string("__mig_stage"); - *msg = *msg + std::to_string(stage) + ":" + vm_->get_cname() + "(" + src_pm_->get_cname() + "-" + - dst_pm_->get_cname() + ")"; - + auto msg = std::make_unique(xbt::string_printf("__mig_stage%d:%s(%s-%s)", stage, vm_->get_cname(), + src_pm_->get_cname(), dst_pm_->get_cname())); double clock_sta = s4u::Engine::get_clock(); - s4u::CommPtr comm = mbox->put_init(msg, size); + s4u::CommPtr comm = mbox->put_init(msg.get(), size); if (mig_speed > 0) comm->set_rate(mig_speed); try { comm->wait_for(timeout); + msg.release(); } catch (const Exception&) { auto remaining = static_cast(comm->get_remaining()); XBT_VERB("timeout (%lf s) in sending_migration_data, remaining %llu bytes of %llu", timeout, remaining, size); sent -= remaining; - delete msg; } double clock_end = s4u::Engine::get_clock(); @@ -270,9 +267,7 @@ void MigrationTx::operator()() // effectively the VM on the DST node. XBT_DEBUG("mig: tx_done"); } -} // namespace vm -} // namespace plugin -} // namespace simgrid +} // namespace simgrid::plugin::vm using simgrid::plugin::vm::VmMigrationExt; @@ -336,13 +331,10 @@ void sg_vm_migrate(simgrid::s4u::VirtualMachine* vm, simgrid::s4u::Host* dst_pm) XBT_THROW_POINT, simgrid::xbt::string_printf("Cannot migrate VM '%s' that is already migrating.", vm->get_cname())); - vm->get_vm_impl()->start_migration(); - simgrid::s4u::VirtualMachine::on_migration_start(*vm); + vm->start_migration(); - std::string rx_name = - std::string("__pr_mig_rx:") + vm->get_cname() + "(" + src_pm->get_cname() + "-" + dst_pm->get_cname() + ")"; - std::string tx_name = - std::string("__pr_mig_tx:") + vm->get_cname() + "(" + src_pm->get_cname() + "-" + dst_pm->get_cname() + ")"; + std::string rx_name = "__pr_mig_rx:" + vm->get_name() + "(" + src_pm->get_name() + "-" + dst_pm->get_name() + ")"; + std::string tx_name = "__pr_mig_tx:" + vm->get_name() + "(" + src_pm->get_name() + "-" + dst_pm->get_name() + ")"; simgrid::s4u::ActorPtr rx = simgrid::s4u::Actor::create(rx_name.c_str(), dst_pm, simgrid::plugin::vm::MigrationRx(vm, dst_pm)); @@ -353,12 +345,11 @@ void sg_vm_migrate(simgrid::s4u::VirtualMachine* vm, simgrid::s4u::Host* dst_pm) /* wait until the migration have finished or on error has occurred */ 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() + ")"); + simgrid::s4u::Mailbox* mbox_ctl = simgrid::s4u::Mailbox::by_name("__mbox_mig_ctl:" + vm->get_name() + "(" + + src_pm->get_name() + "-" + dst_pm->get_name() + ")"); mbox_ctl->get_unique(); tx->join(); rx->join(); - vm->get_vm_impl()->end_migration(); - simgrid::s4u::VirtualMachine::on_migration_end(*vm); + vm->end_migration(); }