X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/1afb6751888eb781f1fa1bc7c98b7c7338308c49..b631743f5e3537ae0b3ee34654c5f7c1f8a30a12:/src/plugins/vm/VmLiveMigration.cpp diff --git a/src/plugins/vm/VmLiveMigration.cpp b/src/plugins/vm/VmLiveMigration.cpp index 3dce9fbb2f..4ac6b365ce 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-2022. 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" @@ -94,22 +95,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(); @@ -290,7 +289,7 @@ void sg_vm_live_migration_plugin_init() { sg_vm_dirty_page_tracking_init(); VmMigrationExt::ensureVmMigrationExtInstalled(); - simgrid::s4u::VirtualMachine::on_shutdown.connect(&onVirtualMachineShutdown); + simgrid::s4u::VirtualMachine::on_shutdown_cb(&onVirtualMachineShutdown); } simgrid::s4u::VirtualMachine* sg_vm_create_migratable(simgrid::s4u::Host* pm, const char* name, int coreAmount, @@ -336,8 +335,7 @@ 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() + ")"; @@ -359,6 +357,5 @@ void sg_vm_migrate(simgrid::s4u::VirtualMachine* vm, simgrid::s4u::Host* dst_pm) tx->join(); rx->join(); - vm->get_vm_impl()->end_migration(); - simgrid::s4u::VirtualMachine::on_migration_end(*vm); + vm->end_migration(); }