1 /* Copyright (c) 2015-2018. The SimGrid Team. All rights reserved. */
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. */
6 #ifndef SIMGRID_S4U_VM_HPP
7 #define SIMGRID_S4U_VM_HPP
9 #include "simgrid/s4u/Host.hpp"
10 #include "simgrid/s4u/forward.hpp"
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
21 class VirtualMachineImpl;
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.
34 class XBT_PUBLIC VirtualMachine : public s4u::Host {
35 simgrid::vm::VirtualMachineImpl* pimpl_vm_ = nullptr;
36 virtual ~VirtualMachine();
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);
43 VirtualMachine(VirtualMachine const&) = delete;
44 VirtualMachine& operator=(VirtualMachine const&) = delete;
46 simgrid::vm::VirtualMachineImpl* getImpl() { return pimpl_vm_; }
53 simgrid::s4u::Host* getPm();
54 void setPm(simgrid::s4u::Host * pm);
56 void setRamsize(size_t ramsize);
57 void setBound(double bound);
59 e_surf_vm_state_t getState();
60 static simgrid::xbt::signal<void(simgrid::s4u::VirtualMachine*)> onVmShutdown;
63 } // namespace simgrid::s4u