Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
vm_migrate is now part of the live_migration plugin \o/
[simgrid.git] / src / plugins / vm / VmLiveMigration.hpp
1 /* Copyright (c) 2004-2016. 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.hpp"
7
8 #ifndef VM_LIVE_MIGRATION_HPP_
9 #define VM_LIVE_MIGRATION_HPP_
10
11 namespace simgrid {
12 namespace vm {
13
14 class MigrationRx {
15   /* The miration_rx process uses mbox_ctl to let the caller of do_migration()  know the completion of the migration. */
16   s4u::MailboxPtr mbox_ctl;
17   /* The migration_rx and migration_tx processes use mbox to transfer migration data. */
18   s4u::MailboxPtr mbox;
19   s4u::VirtualMachine* vm_;
20   s4u::Host* src_pm_ = nullptr;
21   s4u::Host* dst_pm_ = nullptr;
22
23 public:
24   explicit MigrationRx(s4u::VirtualMachine* vm, s4u::Host* dst_pm) : vm_(vm), dst_pm_(dst_pm)
25   {
26     src_pm_ = vm_->getPm();
27
28     mbox_ctl = s4u::Mailbox::byName(std::string("__mbox_mig_ctl:") + vm_->getCname() + "(" + src_pm_->getCname() + "-" +
29                                     dst_pm_->getCname() + ")");
30     mbox = s4u::Mailbox::byName(std::string("__mbox_mig_src_dst:") + vm_->getCname() + "(" + src_pm_->getCname() + "-" +
31                                 dst_pm_->getCname() + ")");
32   }
33   void operator()();
34 };
35
36 class MigrationTx {
37   /* The migration_rx and migration_tx processes use mbox to transfer migration data. */
38   s4u::MailboxPtr mbox;
39   s4u::VirtualMachine* vm_;
40   s4u::Host* src_pm_ = nullptr;
41   s4u::Host* dst_pm_ = nullptr;
42
43 public:
44   explicit MigrationTx(s4u::VirtualMachine* vm, s4u::Host* dst_pm) : vm_(vm), dst_pm_(dst_pm)
45   {
46     src_pm_ = vm_->getPm();
47     mbox = s4u::Mailbox::byName(std::string("__mbox_mig_src_dst:") + vm_->getCname() + "(" + src_pm_->getCname() + "-" +
48                                 dst_pm_->getCname() + ")");
49   }
50   void operator()();
51   sg_size_t sendMigrationData(sg_size_t size, int stage, int stage2_round, double mig_speed, double timeout);
52 };
53 }
54 }
55 #endif