1 /* Copyright (c) 2015-2019. 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>
18 * A VM represents a virtual machine (or a container) that hosts actors.
19 * The total computing power that the contained actors can get is constrained to the virtual machine size.
22 class XBT_PUBLIC VirtualMachine : public s4u::Host {
23 vm::VirtualMachineImpl* const pimpl_vm_;
24 virtual ~VirtualMachine();
27 explicit VirtualMachine(const std::string& name, Host* physical_host, int core_amount);
28 explicit VirtualMachine(const std::string& name, Host* physical_host, int core_amount, size_t ramsize);
31 VirtualMachine(VirtualMachine const&) = delete;
32 VirtualMachine& operator=(VirtualMachine const&) = delete;
35 CREATED, /**< created, but not yet started */
37 SUSPENDED, /**< Suspend/resume does not involve disk I/O, so we assume there is no transition states. */
41 vm::VirtualMachineImpl* get_impl() const { return pimpl_vm_; }
49 void set_pm(Host* pm);
51 void set_ramsize(size_t ramsize);
52 void set_bound(double bound);
54 VirtualMachine::state get_state();
55 static xbt::signal<void(VirtualMachine const&)> on_start;
56 static xbt::signal<void(VirtualMachine const&)> on_started;
57 static xbt::signal<void(VirtualMachine const&)> on_shutdown;
58 static xbt::signal<void(VirtualMachine const&)> on_suspend;
59 static xbt::signal<void(VirtualMachine const&)> on_resume;
60 static xbt::signal<void(VirtualMachine const&)> on_migration_start;
61 static xbt::signal<void(VirtualMachine const&)> on_migration_end;
64 } // namespace simgrid