Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
8a8e190c39abb1b2bc01cfbae91ab0ece915976b
[simgrid.git] / src / s4u / s4u_VirtualMachine.cpp
1 /* Copyright (c) 2015-2016. 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 #include "simgrid/datatypes.h"
7 #include "simgrid/s4u/VirtualMachine.hpp"
8 #include "simgrid/s4u/host.hpp"
9 #include "simgrid/simix.hpp"
10 #include "src/surf/HostImpl.hpp"
11 #include "src/surf/VirtualMachineImpl.hpp"
12 #include "xbt/asserts.h"
13
14 namespace simgrid {
15 namespace s4u {
16
17 VirtualMachine::VirtualMachine(const char* name, s4u::Host* Pm) : Host(name)
18 {
19   pimpl_ = new surf::VirtualMachineImpl(this, Pm);
20 }
21
22 VirtualMachine::~VirtualMachine()
23 {
24   onDestruction(*this);
25 }
26
27 /** @brief Retrieve a copy of the parameters of that VM/PM
28  *  @details The ramsize and overcommit fields are used on the PM too */
29 void VirtualMachine::parameters(vm_params_t params)
30 {
31   static_cast<surf::VirtualMachineImpl*>(pimpl_)->getParams(params);
32 }
33 /** @brief Sets the params of that VM/PM */
34 void VirtualMachine::setParameters(vm_params_t params)
35 {
36   simgrid::simix::kernelImmediate([&]() { static_cast<surf::VirtualMachineImpl*>(pimpl_)->setParams(params); });
37 }
38
39 } // namespace simgrid
40 } // namespace s4u