Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Merge pull request #256 from Flamefire/master
[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 #include "simgrid/s4u/forward.hpp"
11
12 enum e_surf_vm_state_t {
13   SURF_VM_STATE_CREATED, /**< created, but not yet started */
14   SURF_VM_STATE_RUNNING,
15   SURF_VM_STATE_SUSPENDED, /**< Suspend/resume does not involve disk I/O, so we assume there is no transition states. */
16   SURF_VM_STATE_DESTROYED
17 };
18
19 namespace simgrid {
20 namespace vm {
21 class VirtualMachineImpl;
22 };
23
24 namespace s4u {
25
26 /** @ingroup s4u_api
27  *
28  * @tableofcontents
29  *
30  * A VM represents a virtual machine (or a container) that hosts actors.
31  * The total computing power that the contained actors can get is constrained to the virtual machine size.
32  *
33  */
34 class XBT_PUBLIC VirtualMachine : public s4u::Host {
35   simgrid::vm::VirtualMachineImpl* pimpl_vm_ = nullptr;
36   virtual ~VirtualMachine();
37
38 public:
39   explicit VirtualMachine(const char* name, s4u::Host* hostPm, int coreAmount);
40   explicit VirtualMachine(const char* name, s4u::Host* hostPm, int coreAmount, size_t ramsize);
41
42   // No copy/move
43   VirtualMachine(VirtualMachine const&) = delete;
44   VirtualMachine& operator=(VirtualMachine const&) = delete;
45
46   simgrid::vm::VirtualMachineImpl* getImpl() { return pimpl_vm_; }
47   void start();
48   void suspend();
49   void resume();
50   void shutdown();
51   void destroy();
52
53   simgrid::s4u::Host* getPm();
54   void setPm(simgrid::s4u::Host * pm);
55   size_t getRamsize();
56   void setRamsize(size_t ramsize);
57   void setBound(double bound);
58
59   e_surf_vm_state_t getState();
60   static simgrid::xbt::signal<void(simgrid::s4u::VirtualMachine*)> onVmShutdown;
61 };
62 }
63 } // namespace simgrid::s4u
64
65 #endif