Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
233be568c6a73e429f6b3d889ce9fe2f058b4697
[simgrid.git] / include / simgrid / s4u / VirtualMachine.hpp
1 /* Copyright (c) 2015-2017. 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 XBT_PUBLIC_CLASS VirtualMachine : public s4u::Host
35 {
36   simgrid::vm::VirtualMachineImpl* pimpl_vm_ = nullptr;
37   virtual ~VirtualMachine();
38
39 public:
40   explicit VirtualMachine(const char* name, s4u::Host* hostPm, int coreAmount);
41   explicit VirtualMachine(const char* name, s4u::Host* hostPm, int coreAmount, size_t ramsize);
42
43   // No copy/move
44   VirtualMachine(VirtualMachine const&) = delete;
45   VirtualMachine& operator=(VirtualMachine const&) = delete;
46
47   simgrid::vm::VirtualMachineImpl* getImpl() { return pimpl_vm_; }
48   void start();
49   void suspend();
50   void resume();
51   void shutdown();
52   void destroy();
53
54   bool isMigrating();
55
56   simgrid::s4u::Host* getPm();
57   void setPm(simgrid::s4u::Host * pm);
58   size_t getRamsize();
59   void setRamsize(size_t ramsize);
60   void setBound(double bound);
61
62   e_surf_vm_state_t getState();
63   static simgrid::xbt::signal<void(simgrid::s4u::VirtualMachine*)> onVmShutdown;
64 };
65 }
66 } // namespace simgrid::s4u
67
68 #endif