Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Remove explicit conversion to std::string when it's not required.
[simgrid.git] / src / plugins / vm / VmLiveMigration.hpp
1 /* Copyright (c) 2004-2022. The SimGrid Team. All rights reserved.          */
2
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. */
5
6 #include "simgrid/s4u/Engine.hpp"
7 #include "simgrid/s4u/Mailbox.hpp"
8 #include "simgrid/s4u/VirtualMachine.hpp"
9
10 #ifndef VM_LIVE_MIGRATION_HPP_
11 #define VM_LIVE_MIGRATION_HPP_
12
13 namespace simgrid::plugin::vm {
14 class VmMigrationExt {
15 public:
16   s4u::ActorPtr issuer_ = nullptr;
17   s4u::ActorPtr tx_     = nullptr;
18   s4u::ActorPtr rx_     = nullptr;
19   static xbt::Extension<s4u::Host, VmMigrationExt> EXTENSION_ID;
20   explicit VmMigrationExt(s4u::ActorPtr issuer, s4u::ActorPtr rx, s4u::ActorPtr tx) : issuer_(issuer), tx_(tx), rx_(rx)
21   {
22   }
23   static void ensureVmMigrationExtInstalled();
24 };
25
26 class MigrationRx {
27   /* The migration_rx process uses mbox_ctl to let the caller of do_migration()  know the completion of the migration.
28    */
29   s4u::Mailbox* mbox_ctl;
30   /* The migration_rx and migration_tx processes use mbox to transfer migration data. */
31   s4u::Mailbox* mbox;
32   s4u::VirtualMachine* vm_;
33   s4u::Host* src_pm_ = nullptr;
34   s4u::Host* dst_pm_ = nullptr;
35
36 public:
37   explicit MigrationRx(s4u::VirtualMachine* vm, s4u::Host* dst_pm) : vm_(vm), dst_pm_(dst_pm)
38   {
39     src_pm_ = vm_->get_pm();
40
41     mbox_ctl = s4u::Mailbox::by_name("__mbox_mig_ctl:" + vm_->get_name() + "(" + src_pm_->get_name() + "-" +
42                                      dst_pm_->get_name() + ")");
43     mbox     = s4u::Mailbox::by_name("__mbox_mig_src_dst:" + vm_->get_name() + "(" + src_pm_->get_name() + "-" +
44                                  dst_pm_->get_name() + ")");
45   }
46   void operator()();
47 };
48
49 class MigrationTx {
50   /* The migration_rx and migration_tx processes use mbox to transfer migration data. */
51   s4u::Mailbox* mbox;
52   s4u::VirtualMachine* vm_;
53   s4u::Host* src_pm_ = nullptr;
54   s4u::Host* dst_pm_ = nullptr;
55
56 public:
57   explicit MigrationTx(s4u::VirtualMachine* vm, s4u::Host* dst_pm) : vm_(vm), dst_pm_(dst_pm)
58   {
59     src_pm_ = vm_->get_pm();
60     mbox    = s4u::Mailbox::by_name("__mbox_mig_src_dst:" + vm_->get_name() + "(" + src_pm_->get_name() + "-" +
61                                  dst_pm_->get_name() + ")");
62   }
63   void operator()();
64   sg_size_t sendMigrationData(sg_size_t size, int stage, int stage2_round, double mig_speed, double timeout);
65 };
66 } // namespace simgrid::plugin::vm
67 #endif