Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
69221c8b787133943b64eddf5b7507048e528a70
[simgrid.git] / include / simgrid / s4u / VirtualMachine.hpp
1 /* Copyright (c) 2015-2018. 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 #ifndef SIMGRID_S4U_VM_HPP
7 #define SIMGRID_S4U_VM_HPP
8
9 #include <simgrid/s4u/Host.hpp>
10
11 namespace simgrid {
12 namespace s4u {
13
14 /** @ingroup s4u_api
15  *
16  * @tableofcontents
17  *
18  * A VM represents a virtual machine (or a container) that hosts actors.
19  * The total computing power that the contained actors can get is constrained to the virtual machine size.
20  *
21  */
22 class XBT_PUBLIC VirtualMachine : public s4u::Host {
23   simgrid::vm::VirtualMachineImpl* pimpl_vm_ = nullptr;
24   virtual ~VirtualMachine();
25
26 public:
27   explicit VirtualMachine(std::string name, s4u::Host* physical_host, int core_amount);
28   explicit VirtualMachine(std::string name, s4u::Host* physical_host, int core_amount, size_t ramsize);
29
30   // No copy/move
31   VirtualMachine(VirtualMachine const&) = delete;
32   VirtualMachine& operator=(VirtualMachine const&) = delete;
33
34   enum class state {
35     CREATED, /**< created, but not yet started */
36     RUNNING,
37     SUSPENDED, /**< Suspend/resume does not involve disk I/O, so we assume there is no transition states. */
38     DESTROYED
39   };
40
41   simgrid::vm::VirtualMachineImpl* get_impl() { return pimpl_vm_; }
42   void start();
43   void suspend();
44   void resume();
45   void shutdown();
46   void destroy();
47
48   simgrid::s4u::Host* get_pm();
49   void set_pm(simgrid::s4u::Host* pm);
50   size_t get_ramsize();
51   void set_ramsize(size_t ramsize);
52   void set_bound(double bound);
53
54   VirtualMachine::state get_state();
55   static simgrid::xbt::signal<void(VirtualMachine&)> on_start;
56   static simgrid::xbt::signal<void(VirtualMachine&)> on_started;
57   static simgrid::xbt::signal<void(VirtualMachine&)> on_shutdown;
58   static simgrid::xbt::signal<void(VirtualMachine&)> on_suspend;
59   static simgrid::xbt::signal<void(VirtualMachine&)> on_resume;
60   static simgrid::xbt::signal<void(VirtualMachine&)> on_migration_start;
61   static simgrid::xbt::signal<void(VirtualMachine&)> on_migration_end;
62
63   // Deprecated methods
64   /** @deprecated See VirtualMachine::get_state() */
65   XBT_ATTRIB_DEPRECATED_v323("Please use VirtualMachine::get_state()") VirtualMachine::state getState()
66   {
67     return get_state();
68   }
69   /** @deprecated See VirtualMachine::get_impl() */
70   XBT_ATTRIB_DEPRECATED_v323("Please use VirtualMachine::get_impl()") simgrid::vm::VirtualMachineImpl* getImpl()
71   {
72     return pimpl_vm_;
73   }
74   /** @deprecated See VirtualMachine::get_pm() */
75   XBT_ATTRIB_DEPRECATED_v323("Please use VirtualMachine::get_pm()") simgrid::s4u::Host* getPm() { return get_pm(); }
76   /** @deprecated See VirtualMachine::set_pm() */
77   XBT_ATTRIB_DEPRECATED_v323("Please use VirtualMachine::set_pm()") void setPm(simgrid::s4u::Host* pm) { set_pm(pm); }
78   /** @deprecated See VirtualMachine::get_ramsize() */
79   XBT_ATTRIB_DEPRECATED_v323("Please use VirtualMachine::get_ramsize()") size_t getRamsize() { return get_ramsize(); }
80   /** @deprecated See VirtualMachine::set_ramsize() */
81   XBT_ATTRIB_DEPRECATED_v323("Please use VirtualMachine::set_ramsize()") void setRamsize(size_t ramsize)
82   {
83     set_ramsize(ramsize);
84   }
85   /** @deprecated See VirtualMachine::set_bound() */
86   XBT_ATTRIB_DEPRECATED_v323("Please use VirtualMachine::set_bound()") void setBound(double bound) { set_bound(bound); }
87 };
88 }
89 } // namespace simgrid::s4u
90
91 #endif