1 /* Copyright (c) 2004-2016. The SimGrid Team. All rights reserved. */
3 /* This program is free software; you can redistribute it and/or modify it
4 * under the terms of the license (GNU LGPL) which comes with this package. */
6 #include "simgrid/s4u.hpp"
8 #ifndef VM_LIVE_MIGRATION_HPP_
9 #define VM_LIVE_MIGRATION_HPP_
13 class VmMigrationExt {
15 s4u::ActorPtr issuer_ = nullptr;
16 s4u::ActorPtr tx_ = nullptr;
17 s4u::ActorPtr rx_ = nullptr;
18 static simgrid::xbt::Extension<simgrid::s4u::Host, VmMigrationExt> EXTENSION_ID;
19 virtual ~VmMigrationExt() = default;
20 explicit VmMigrationExt(s4u::ActorPtr issuer, s4u::ActorPtr rx, s4u::ActorPtr tx) : issuer_(issuer), tx_(tx), rx_(rx)
23 static void ensureVmMigrationExtInstalled();
27 /* The miration_rx process uses mbox_ctl to let the caller of do_migration() know the completion of the migration. */
28 s4u::MailboxPtr mbox_ctl;
29 /* The migration_rx and migration_tx processes use mbox to transfer migration data. */
31 s4u::VirtualMachine* vm_;
32 s4u::Host* src_pm_ = nullptr;
33 s4u::Host* dst_pm_ = nullptr;
36 explicit MigrationRx(s4u::VirtualMachine* vm, s4u::Host* dst_pm) : vm_(vm), dst_pm_(dst_pm)
38 src_pm_ = vm_->getPm();
40 mbox_ctl = s4u::Mailbox::byName(std::string("__mbox_mig_ctl:") + vm_->getCname() + "(" + src_pm_->getCname() + "-" +
41 dst_pm_->getCname() + ")");
42 mbox = s4u::Mailbox::byName(std::string("__mbox_mig_src_dst:") + vm_->getCname() + "(" + src_pm_->getCname() + "-" +
43 dst_pm_->getCname() + ")");
49 /* The migration_rx and migration_tx processes use mbox to transfer migration data. */
51 s4u::VirtualMachine* vm_;
52 s4u::Host* src_pm_ = nullptr;
53 s4u::Host* dst_pm_ = nullptr;
56 explicit MigrationTx(s4u::VirtualMachine* vm, s4u::Host* dst_pm) : vm_(vm), dst_pm_(dst_pm)
58 src_pm_ = vm_->getPm();
59 mbox = s4u::Mailbox::byName(std::string("__mbox_mig_src_dst:") + vm_->getCname() + "(" + src_pm_->getCname() + "-" +
60 dst_pm_->getCname() + ")");
63 sg_size_t sendMigrationData(sg_size_t size, int stage, int stage2_round, double mig_speed, double timeout);