Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
25f2e1b05e11b27090d32b2082b2f13fc51ede27
[simgrid.git] / include / simgrid / s4u / VirtualMachine.hpp
1 /* Copyright (c) 2015-2019. 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   vm::VirtualMachineImpl* const pimpl_vm_;
24   virtual ~VirtualMachine();
25
26 public:
27   explicit VirtualMachine(const std::string& name, Host* physical_host, int core_amount);
28   explicit VirtualMachine(const std::string& name, 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   vm::VirtualMachineImpl* get_impl() const { return pimpl_vm_; }
42   void start();
43   void suspend();
44   void resume();
45   void shutdown();
46   void destroy();
47
48   Host* get_pm();
49   void set_pm(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 xbt::signal<void(VirtualMachine&)> on_start;
56   static xbt::signal<void(VirtualMachine&)> on_started;
57   static xbt::signal<void(VirtualMachine&)> on_shutdown;
58   static xbt::signal<void(VirtualMachine&)> on_suspend;
59   static xbt::signal<void(VirtualMachine&)> on_resume;
60   static xbt::signal<void(VirtualMachine&)> on_migration_start;
61   static xbt::signal<void(VirtualMachine&)> on_migration_end;
62
63 #ifndef DOXYGEN
64   // Deprecated methods
65   /** @deprecated See VirtualMachine::get_state() */
66   XBT_ATTRIB_DEPRECATED_v323("Please use VirtualMachine::get_state()") VirtualMachine::state getState()
67   {
68     return get_state();
69   }
70   /** @deprecated See VirtualMachine::get_impl() */
71   XBT_ATTRIB_DEPRECATED_v323("Please use VirtualMachine::get_impl()") vm::VirtualMachineImpl* getImpl()
72   {
73     return pimpl_vm_;
74   }
75   /** @deprecated See VirtualMachine::get_pm() */
76   XBT_ATTRIB_DEPRECATED_v323("Please use VirtualMachine::get_pm()") Host* getPm() { return get_pm(); }
77   /** @deprecated See VirtualMachine::set_pm() */
78   XBT_ATTRIB_DEPRECATED_v323("Please use VirtualMachine::set_pm()") void setPm(Host* pm) { set_pm(pm); }
79   /** @deprecated See VirtualMachine::get_ramsize() */
80   XBT_ATTRIB_DEPRECATED_v323("Please use VirtualMachine::get_ramsize()") size_t getRamsize() { return get_ramsize(); }
81   /** @deprecated See VirtualMachine::set_ramsize() */
82   XBT_ATTRIB_DEPRECATED_v323("Please use VirtualMachine::set_ramsize()") void setRamsize(size_t ramsize)
83   {
84     set_ramsize(ramsize);
85   }
86   /** @deprecated See VirtualMachine::set_bound() */
87   XBT_ATTRIB_DEPRECATED_v323("Please use VirtualMachine::set_bound()") void setBound(double bound) { set_bound(bound); }
88 #endif
89 };
90 } // namespace s4u
91 } // namespace simgrid
92
93 #endif