Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
one step toward a live migration plugin
[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/datatypes.h"
10 #include "simgrid/s4u/Host.hpp"
11 #include "simgrid/s4u/forward.hpp"
12
13 enum e_surf_vm_state_t {
14   SURF_VM_STATE_CREATED, /**< created, but not yet started */
15   SURF_VM_STATE_RUNNING,
16   SURF_VM_STATE_SUSPENDED, /**< Suspend/resume does not involve disk I/O, so we assume there is no transition states. */
17   SURF_VM_STATE_DESTROYED
18 };
19
20 namespace simgrid {
21 namespace vm {
22 class VirtualMachineImpl;
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
37 public:
38   explicit VirtualMachine(const char* name, s4u::Host* hostPm, int coreAmount);
39   explicit VirtualMachine(const char* name, s4u::Host* hostPm, int coreAmount, size_t ramsize);
40
41   // No copy/move
42   VirtualMachine(VirtualMachine const&) = delete;
43   VirtualMachine& operator=(VirtualMachine const&) = delete;
44
45 private:
46   virtual ~VirtualMachine();
47 public:
48   void start();
49   void suspend();
50   void resume();
51   void shutdown();
52
53   bool isMigrating();
54
55   void getParameters(vm_params_t params);
56   void setParameters(vm_params_t params);
57   simgrid::s4u::Host* getPm();
58   size_t getRamsize();
59   void setRamsize(size_t ramsize);
60   void setBound(double bound);
61
62   e_surf_vm_state_t getState();
63
64   /* FIXME: protect me */
65   simgrid::vm::VirtualMachineImpl* pimpl_vm_ = nullptr;
66 };
67 }
68 } // namespace simgrid::s4u
69
70 #endif /* SIMGRID_S4U_HOST_HPP */