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>
11 enum e_surf_vm_state_t {
12 SURF_VM_STATE_CREATED, /**< created, but not yet started */
13 SURF_VM_STATE_RUNNING,
14 SURF_VM_STATE_SUSPENDED, /**< Suspend/resume does not involve disk I/O, so we assume there is no transition states. */
15 SURF_VM_STATE_DESTROYED
20 class VirtualMachineImpl;
29 * A VM represents a virtual machine (or a container) that hosts actors.
30 * The total computing power that the contained actors can get is constrained to the virtual machine size.
33 class XBT_PUBLIC VirtualMachine : public s4u::Host {
34 simgrid::vm::VirtualMachineImpl* pimpl_vm_ = nullptr;
35 virtual ~VirtualMachine();
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);
42 VirtualMachine(VirtualMachine const&) = delete;
43 VirtualMachine& operator=(VirtualMachine const&) = delete;
45 simgrid::vm::VirtualMachineImpl* getImpl() { return pimpl_vm_; }
52 simgrid::s4u::Host* getPm();
53 void setPm(simgrid::s4u::Host * pm);
55 void setRamsize(size_t ramsize);
56 void setBound(double bound);
58 e_surf_vm_state_t getState();
59 static simgrid::xbt::signal<void(simgrid::s4u::VirtualMachine*)> onVmShutdown;
62 } // namespace simgrid::s4u