This makes room for a s4u::VirtualMachine class that should arrive soon.
#include <simgrid/simix/blocking_simcall.hpp>
-#include "src/mc/mc_replay.h"
+#include "mc/mc.h"
#include "smx_private.h"
+#include "src/kernel/activity/SynchroComm.hpp"
#include "src/mc/mc_forward.hpp"
-#include "xbt/ex.h"
-#include "mc/mc.h"
+#include "src/mc/mc_replay.h"
#include "src/simix/smx_host_private.h"
-#include "src/kernel/activity/SynchroComm.hpp"
-#include "src/surf/virtual_machine.hpp"
-
+#include "src/surf/VirtualMachineImpl.hpp"
+#include "xbt/ex.h"
#include <simgrid/simix.hpp>
/* This program is free software; you can redistribute it and/or modify it
* under the terms of the license (GNU LGPL) which comes with this package. */
-#include "smx_private.h"
-#include <xbt/ex.hpp>
-#include "xbt/sysdep.h"
#include "mc/mc.h"
+#include "smx_private.h"
#include "src/mc/mc_replay.h"
-#include "src/surf/virtual_machine.hpp"
#include "src/surf/HostImpl.hpp"
+#include "src/surf/VirtualMachineImpl.hpp"
+#include "xbt/sysdep.h"
+#include <xbt/ex.hpp>
#include "src/kernel/activity/SynchroExec.hpp"
#include "src/kernel/activity/SynchroComm.hpp"
host_list_cpy[i] = host_list[i];
/* Check that we are not mixing VMs and PMs in the parallel task */
- bool is_a_vm = (nullptr != dynamic_cast<simgrid::surf::VirtualMachine*>(host_list[0]->pimpl_));
+ bool is_a_vm = (nullptr != dynamic_cast<simgrid::surf::VirtualMachineImpl*>(host_list[0]->pimpl_));
for (int i = 1; i < host_nb; i++) {
- bool tmp_is_a_vm = (nullptr != dynamic_cast<simgrid::surf::VirtualMachine*>(host_list[i]->pimpl_));
+ bool tmp_is_a_vm = (nullptr != dynamic_cast<simgrid::surf::VirtualMachineImpl*>(host_list[i]->pimpl_));
xbt_assert(is_a_vm == tmp_is_a_vm, "parallel_execute: mixing VMs and PMs is not supported (yet).");
}
/* This program is free software; you can redistribute it and/or modify it
* under the terms of the license (GNU LGPL) which comes with this package. */
-#include "smx_private.h"
#include "mc/mc.h"
-#include "src/surf/virtual_machine.hpp"
+#include "smx_private.h"
#include "src/surf/HostImpl.hpp"
+#include "src/surf/VirtualMachineImpl.hpp"
XBT_LOG_NEW_DEFAULT_SUBCATEGORY(simix_vm, simix, "Logging specific to SIMIX Virtual Machines");
void SIMIX_vm_start(sg_host_t vm)
{
if (__can_be_started(vm))
- static_cast<simgrid::surf::VirtualMachine*>(vm->pimpl_)->setState(SURF_VM_STATE_RUNNING);
+ static_cast<simgrid::surf::VirtualMachineImpl*>(vm->pimpl_)->setState(SURF_VM_STATE_RUNNING);
else
THROWF(vm_error, 0, "The VM %s cannot be started", vm->name().c_str());
}
e_surf_vm_state_t SIMIX_vm_get_state(sg_host_t vm)
{
- return static_cast<simgrid::surf::VirtualMachine*>(vm->pimpl_)->getState();
+ return static_cast<simgrid::surf::VirtualMachineImpl*>(vm->pimpl_)->getState();
}
/**
}
/* FIXME: we may have to do something at the surf layer, e.g., vcpu action */
- static_cast<simgrid::surf::VirtualMachine*>(vm->pimpl_)->setState(SURF_VM_STATE_CREATED);
+ static_cast<simgrid::surf::VirtualMachineImpl*>(vm->pimpl_)->setState(SURF_VM_STATE_CREATED);
}
void simcall_HANDLER_vm_shutdown(smx_simcall_t simcall, sg_host_t vm)
#include "src/surf/HostImpl.hpp"
#include "simgrid/sg_config.h"
+#include "VirtualMachineImpl.hpp"
#include "network_interface.hpp"
-#include "virtual_machine.hpp"
XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_host, surf, "Logging specific to the SURF host module");
void HostModel::adjustWeightOfDummyCpuActions()
{
/* iterate for all virtual machines */
- for (VirtualMachine *ws_vm : VirtualMachine::allVms_) {
+ for (VirtualMachineImpl* ws_vm : VirtualMachineImpl::allVms_) {
Cpu* cpu = ws_vm->piface_->pimpl_cpu;
xbt_dynar_t HostImpl::getVms()
{
- xbt_dynar_t dyn = xbt_dynar_new(sizeof(simgrid::surf::VirtualMachine*), nullptr);
+ xbt_dynar_t dyn = xbt_dynar_new(sizeof(simgrid::surf::VirtualMachineImpl*), nullptr);
- for (VirtualMachine *ws_vm : VirtualMachine::allVms_) {
+ for (VirtualMachineImpl* ws_vm : VirtualMachineImpl::allVms_) {
if (this == ws_vm->getPm()->pimpl_)
xbt_dynar_push(dyn, &ws_vm);
}
/* This program is free software; you can redistribute it and/or modify it
* under the terms of the license (GNU LGPL) which comes with this package. */
+#include "VirtualMachineImpl.hpp"
+
#include <xbt/signal.hpp>
#include "cpu_cas01.hpp"
-#include "virtual_machine.hpp"
XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_vm, surf, "Logging specific to the SURF VM module");
-simgrid::surf::VMModel *surf_vm_model = nullptr;
+simgrid::surf::VMModel* surf_vm_model = nullptr;
-void surf_vm_model_init_HL13(){
+void surf_vm_model_init_HL13()
+{
if (surf_cpu_model_vm) {
surf_vm_model = new simgrid::surf::VMModel();
all_existing_models->push_back(surf_vm_model);
namespace simgrid {
namespace surf {
-
/*************
* Callbacks *
*************/
-simgrid::xbt::signal<void(simgrid::surf::VirtualMachine*)> onVmCreation;
-simgrid::xbt::signal<void(simgrid::surf::VirtualMachine*)> onVmDestruction;
-simgrid::xbt::signal<void(simgrid::surf::VirtualMachine*)> onVmStateChange;
+simgrid::xbt::signal<void(simgrid::surf::VirtualMachineImpl*)> onVmCreation;
+simgrid::xbt::signal<void(simgrid::surf::VirtualMachineImpl*)> onVmDestruction;
+simgrid::xbt::signal<void(simgrid::surf::VirtualMachineImpl*)> onVmStateChange;
/*********
* Model *
*********/
-std::deque<VirtualMachine*> VirtualMachine::allVms_;
+std::deque<VirtualMachineImpl*> VirtualMachineImpl::allVms_;
-s4u::Host *VMModel::createVM(const char *name, sg_host_t host_PM)
+s4u::Host* VMModel::createVM(const char* name, sg_host_t host_PM)
{
- VirtualMachine* vm = new VirtualMachine(name, host_PM);
+ VirtualMachineImpl* vm = new VirtualMachineImpl(name, host_PM);
return vm->piface_;
}
**/
/* iterate for all virtual machines */
- for (VirtualMachine *ws_vm : VirtualMachine::allVms_) {
+ for (VirtualMachineImpl* ws_vm : VirtualMachineImpl::allVms_) {
Cpu* cpu = ws_vm->piface_->pimpl_cpu;
xbt_assert(cpu, "cpu-less host");
return surf_cpu_model_vm->nextOccuringEvent(now);
}
-
/************
* Resource *
************/
-VirtualMachine::VirtualMachine(const char* name, simgrid::s4u::Host* host_PM)
+VirtualMachineImpl::VirtualMachineImpl(const char* name, simgrid::s4u::Host* host_PM)
: HostImpl(new simgrid::s4u::Host(name), nullptr /*storage*/), hostPM_(host_PM)
{
/* Register this VM to the list of all VMs */
// //// CPU RELATED STUFF ////
// Roughly, create a vcpu resource by using the values of the sub_cpu one.
- CpuCas01 *sub_cpu = dynamic_cast<CpuCas01*>(host_PM->pimpl_cpu);
+ CpuCas01* sub_cpu = dynamic_cast<CpuCas01*>(host_PM->pimpl_cpu);
piface_->pimpl_cpu = surf_cpu_model_vm->createCpu(piface_, sub_cpu->getSpeedPeakList(), 1 /*cores*/);
if (sub_cpu->getPState() != 0)
/*
* A physical host does not disappear in the current SimGrid code, but a VM may disappear during a simulation.
*/
-VirtualMachine::~VirtualMachine()
+VirtualMachineImpl::~VirtualMachineImpl()
{
onVmDestruction(this);
- allVms_.erase( find(allVms_.begin(), allVms_.end(), this) );
+ allVms_.erase(find(allVms_.begin(), allVms_.end(), this));
/* Free the cpu_action of the VM. */
XBT_ATTRIB_UNUSED int ret = action_->unref();
xbt_assert(ret == 1, "Bug: some resource still remains");
}
-e_surf_vm_state_t VirtualMachine::getState() {
+e_surf_vm_state_t VirtualMachineImpl::getState()
+{
return vmState_;
}
-void VirtualMachine::setState(e_surf_vm_state_t state)
+void VirtualMachineImpl::setState(e_surf_vm_state_t state)
{
vmState_ = state;
}
-void VirtualMachine::suspend()
+void VirtualMachineImpl::suspend()
{
action_->suspend();
vmState_ = SURF_VM_STATE_SUSPENDED;
}
-void VirtualMachine::resume()
+void VirtualMachineImpl::resume()
{
action_->resume();
vmState_ = SURF_VM_STATE_RUNNING;
}
-void VirtualMachine::save()
+void VirtualMachineImpl::save()
{
vmState_ = SURF_VM_STATE_SAVING;
action_->suspend();
vmState_ = SURF_VM_STATE_SAVED;
}
-void VirtualMachine::restore()
+void VirtualMachineImpl::restore()
{
vmState_ = SURF_VM_STATE_RESTORING;
action_->resume();
}
/** @brief returns the physical machine on which the VM is running **/
-sg_host_t VirtualMachine::getPm() {
+sg_host_t VirtualMachineImpl::getPm()
+{
return hostPM_;
}
/* Update the physical host of the given VM */
-void VirtualMachine::migrate(sg_host_t host_dest)
+void VirtualMachineImpl::migrate(sg_host_t host_dest)
{
const char* vm_name = piface_->name().c_str();
const char* pm_name_src = hostPM_->name().c_str();
if (old_bound != 0) {
XBT_DEBUG("migrate VM(%s): set bound (%f) at %s", vm_name, old_bound, pm_name_dst);
new_cpu_action->setBound(old_bound);
- }
+ }
- XBT_ATTRIB_UNUSED int ret = action_->unref();
- xbt_assert(ret == 1, "Bug: some resource still remains");
+ XBT_ATTRIB_UNUSED int ret = action_->unref();
+ xbt_assert(ret == 1, "Bug: some resource still remains");
- action_ = new_cpu_action;
+ action_ = new_cpu_action;
- XBT_DEBUG("migrate VM(%s): change PM (%s to %s)", vm_name, pm_name_src, pm_name_dst);
+ XBT_DEBUG("migrate VM(%s): change PM (%s to %s)", vm_name, pm_name_src, pm_name_dst);
}
-void VirtualMachine::setBound(double bound){
- action_->setBound(bound);
+void VirtualMachineImpl::setBound(double bound)
+{
+ action_->setBound(bound);
}
-
-
}
}
/* This program is free software; you can redistribute it and/or modify it
* under the terms of the license (GNU LGPL) which comes with this package. */
-#include <deque>
#include <boost/intrusive/list.hpp>
+#include <deque>
#include <xbt/base.h>
***********/
class XBT_PRIVATE VMModel;
-class XBT_PRIVATE VirtualMachine;
+class XBT_PRIVATE VirtualMachineImpl;
/*************
* Callbacks *
/** @ingroup SURF_callbacks
* @brief Callbacks fired after VM creation. Signature: `void(VirtualMachine*)`
*/
-extern XBT_PRIVATE simgrid::xbt::signal<void(simgrid::surf::VirtualMachine*)> onVmCreation;
+extern XBT_PRIVATE simgrid::xbt::signal<void(simgrid::surf::VirtualMachineImpl*)> onVmCreation;
/** @ingroup SURF_callbacks
* @brief Callbacks fired after VM destruction. Signature: `void(VirtualMachine*)`
*/
-extern XBT_PRIVATE simgrid::xbt::signal<void(simgrid::surf::VirtualMachine*)> onVmDestruction;
+extern XBT_PRIVATE simgrid::xbt::signal<void(simgrid::surf::VirtualMachineImpl*)> onVmDestruction;
/** @ingroup SURF_callbacks
* @brief Callbacks after VM State changes. Signature: `void(VirtualMachine*)`
*/
-extern XBT_PRIVATE simgrid::xbt::signal<void(simgrid::surf::VirtualMachine*)> onVmStateChange;
+extern XBT_PRIVATE simgrid::xbt::signal<void(simgrid::surf::VirtualMachineImpl*)> onVmStateChange;
/************
* Resource *
* @brief SURF VM interface class
* @details A VM represent a virtual machine
*/
-class VirtualMachine : public HostImpl {
+class VirtualMachineImpl : public HostImpl {
public:
- VirtualMachine(const char* name, simgrid::s4u::Host* host);
- ~VirtualMachine();
+ VirtualMachineImpl(const char* name, simgrid::s4u::Host* host);
+ ~VirtualMachineImpl();
/** @brief Suspend the VM */
virtual void suspend();
virtual void setBound(double bound);
/* The vm object of the lower layer */
- CpuAction *action_ = nullptr;
+ CpuAction* action_ = nullptr;
+
protected:
- simgrid::s4u::Host *hostPM_;
+ simgrid::s4u::Host* hostPM_;
public:
e_surf_vm_state_t getState();
void setState(e_surf_vm_state_t state);
- static std::deque<VirtualMachine*> allVms_;
+ static std::deque<VirtualMachineImpl*> allVms_;
protected:
e_surf_vm_state_t vmState_ = SURF_VM_STATE_CREATED;
* @param name The name of the new VM
* @param host_PM The real machine hosting the VM
*/
- s4u::Host *createVM(const char *name, sg_host_t host_PM);
- void adjustWeightOfDummyCpuActions() override {};
+ s4u::Host* createVM(const char* name, sg_host_t host_PM);
+ void adjustWeightOfDummyCpuActions() override{};
double nextOccuringEvent(double now) override;
- void updateActionsState(double /*now*/, double /*delta*/) override {};
-
+ void updateActionsState(double /*now*/, double /*delta*/) override{};
};
-
}
}
#include "host_clm03.hpp"
+#include "VirtualMachineImpl.hpp"
#include "cpu_cas01.hpp"
#include "simgrid/sg_config.h"
-#include "virtual_machine.hpp"
XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(surf_host);
#include "simgrid/plugins/energy.h"
#include "simgrid/simix.hpp"
-#include "src/surf/plugins/energy.hpp"
+#include "src/surf/VirtualMachineImpl.hpp"
#include "src/surf/cpu_interface.hpp"
-#include "src/surf/virtual_machine.hpp"
-
+#include "src/surf/plugins/energy.hpp"
#include <utility>
/** @addtogroup SURF_plugin_energy
/* **************************** events callback *************************** */
static void onCreation(simgrid::s4u::Host& host) {
- if (dynamic_cast<simgrid::surf::VirtualMachine*>(host.pimpl_)) // Ignore virtual machines
+ if (dynamic_cast<simgrid::surf::VirtualMachineImpl*>(host.pimpl_)) // Ignore virtual machines
return;
host.extension_set(new HostEnergy(&host));
}
if(sghost == nullptr)
continue;
simgrid::surf::HostImpl* host = sghost->pimpl_;
- simgrid::surf::VirtualMachine *vm = dynamic_cast<simgrid::surf::VirtualMachine*>(host);
+ simgrid::surf::VirtualMachineImpl* vm = dynamic_cast<simgrid::surf::VirtualMachineImpl*>(host);
if (vm) // If it's a VM, take the corresponding PM
host = vm->getPm()->pimpl_;
}
static void onHostStateChange(simgrid::s4u::Host &host) {
- if (dynamic_cast<simgrid::surf::VirtualMachine*>(host.pimpl_)) // Ignore virtual machines
+ if (dynamic_cast<simgrid::surf::VirtualMachineImpl*>(host.pimpl_)) // Ignore virtual machines
return;
HostEnergy *host_energy = host.extension<HostEnergy>();
static void onHostDestruction(simgrid::s4u::Host& host) {
// Ignore virtual machines
- if (dynamic_cast<simgrid::surf::VirtualMachine*>(host.pimpl_))
+ if (dynamic_cast<simgrid::surf::VirtualMachineImpl*>(host.pimpl_))
return;
HostEnergy *host_energy = host.extension<HostEnergy>();
host_energy->update();
/* This program is free software; you can redistribute it and/or modify it
* under the terms of the license (GNU LGPL) which comes with this package. */
-#include "src/surf/HostImpl.hpp"
-#include "surf_interface.hpp"
+#include "VirtualMachineImpl.hpp"
#include "network_interface.hpp"
-#include "src/instr/instr_private.h"
#include "plugins/energy.hpp"
-#include "virtual_machine.hpp"
+#include "src/instr/instr_private.h"
+#include "src/surf/HostImpl.hpp"
+#include "surf_interface.hpp"
XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(surf_kernel);
return host->pimpl_;
}
-static simgrid::surf::VirtualMachine *get_casted_vm(sg_host_t host){
- return static_cast<simgrid::surf::VirtualMachine*>(host->pimpl_);
+static simgrid::surf::VirtualMachineImpl* get_casted_vm(sg_host_t host)
+{
+ return static_cast<simgrid::surf::VirtualMachineImpl*>(host->pimpl_);
}
extern double NOW;
/* This program is free software; you can redistribute it and/or modify it
* under the terms of the license (GNU LGPL) which comes with this package. */
-#include "src/internal_config.h"
-#include "surf_private.h"
#include "surf_interface.hpp"
-#include "network_interface.hpp"
+#include "VirtualMachineImpl.hpp"
#include "cpu_interface.hpp"
-#include "src/surf/HostImpl.hpp"
-#include "src/simix/smx_host_private.h"
-#include "surf_routing.hpp"
-#include "simgrid/sg_config.h"
#include "mc/mc.h"
-#include "virtual_machine.hpp"
-#include "src/instr/instr_private.h" // TRACE_is_enabled(). FIXME: remove by subscribing tracing to the surf signals
+#include "network_interface.hpp"
#include "simgrid/s4u/engine.hpp"
+#include "simgrid/sg_config.h"
+#include "src/instr/instr_private.h" // TRACE_is_enabled(). FIXME: remove by subscribing tracing to the surf signals
+#include "src/internal_config.h"
+#include "src/simix/smx_host_private.h"
+#include "src/surf/HostImpl.hpp"
+#include "surf_private.h"
+#include "surf_routing.hpp"
#include <vector>
XBT_LOG_NEW_CATEGORY(surf, "All SURF categories");
src/surf/surf_private.h
src/surf/surf_routing.hpp
src/surf/PropertyHolder.hpp
- src/surf/virtual_machine.hpp
+ src/surf/VirtualMachineImpl.hpp
src/surf/host_clm03.hpp
src/surf/HostImpl.hpp
src/surf/ptask_L07.hpp
src/surf/xml/surfxml_parseplatf.cpp
src/surf/trace_mgr.hpp
src/surf/trace_mgr.cpp
- src/surf/virtual_machine.cpp
+ src/surf/VirtualMachineImpl.cpp
src/surf/host_clm03.cpp
src/surf/HostImpl.cpp
src/surf/ptask_L07.cpp