xbt_dynar_t storageList = (xbt_dynar_t)xbt_lib_get_or_null(storage_lib, name, ROUTING_STORAGE_HOST_LEVEL);
HostImpl *host = new simgrid::surf::HostImpl(surf_host_model, name, storageList, cpu);
- XBT_DEBUG("Create host %s with %ld mounted disks", name, xbt_dynar_length(host->p_storage));
+ XBT_DEBUG("Create host %s with %ld mounted disks", name, xbt_dynar_length(host->storage_));
return host;
}
/* iterate for all virtual machines */
for (VirtualMachine *ws_vm : VirtualMachine::allVms_) {
- Cpu *cpu = ws_vm->p_cpu;
+ Cpu *cpu = ws_vm->cpu_;
int is_active = lmm_constraint_used(cpu->getModel()->getMaxminSystem(), cpu->getConstraint());
HostImpl::HostImpl(simgrid::surf::HostModel *model, const char *name, xbt_dynar_t storage, Cpu *cpu)
: Resource(model, name)
, PropertyHolder(nullptr)
- , p_storage(storage), p_cpu(cpu)
+ , storage_(storage), cpu_(cpu)
{
if (!EXTENSION_ID.valid())
EXTENSION_ID = simgrid::s4u::Host::extension_create<simgrid::surf::HostImpl>();
- p_params.ramsize = 0;
+ params_.ramsize = 0;
}
HostImpl::HostImpl(simgrid::surf::HostModel *model, const char *name, lmm_constraint_t constraint,
xbt_dynar_t storage, Cpu *cpu)
: Resource(model, name, constraint)
, PropertyHolder(nullptr)
- , p_storage(storage), p_cpu(cpu)
+ , storage_(storage), cpu_(cpu)
{
- p_params.ramsize = 0;
+ params_.ramsize = 0;
}
/** @brief use destroy() instead of this destructor */
void HostImpl::attach(simgrid::s4u::Host* host)
{
- if (piface != nullptr)
+ if (piface_ != nullptr)
xbt_die("Already attached to host %s", host->name().c_str());
host->extension_set(this);
- piface = host;
+ piface_ = host;
}
bool HostImpl::isOn() const {
- return p_cpu->isOn();
+ return cpu_->isOn();
}
bool HostImpl::isOff() const {
- return p_cpu->isOff();
+ return cpu_->isOff();
}
void HostImpl::turnOn(){
if (isOff()) {
- p_cpu->turnOn();
- simgrid::s4u::Host::onStateChange(*this->piface);
+ cpu_->turnOn();
+ simgrid::s4u::Host::onStateChange(*this->piface_);
}
}
void HostImpl::turnOff(){
if (isOn()) {
- p_cpu->turnOff();
- simgrid::s4u::Host::onStateChange(*this->piface);
+ cpu_->turnOff();
+ simgrid::s4u::Host::onStateChange(*this->piface_);
}
}
unsigned int cursor;
XBT_DEBUG("Search for storage name '%s' on '%s'", mount, getName());
- xbt_dynar_foreach(p_storage,cursor,mnt){
+ xbt_dynar_foreach(storage_,cursor,mnt){
XBT_DEBUG("See '%s'",mnt.name);
if(!strcmp(mount,mnt.name)){
st = static_cast<simgrid::surf::Storage*>(mnt.storage);
xbt_dict_t storage_list = xbt_dict_new_homogeneous(nullptr);
char *storage_name = nullptr;
- xbt_dynar_foreach(p_storage,i,mnt){
+ xbt_dynar_foreach(storage_,i,mnt){
storage_name = (char *)static_cast<simgrid::surf::Storage*>(mnt.storage)->getName();
xbt_dict_set(storage_list,mnt.name,storage_name,nullptr);
}
char *mount_name = nullptr;
XBT_DEBUG("Search for storage name for '%s' on '%s'", fullpath, getName());
- xbt_dynar_foreach(p_storage,cursor,mnt)
+ xbt_dynar_foreach(storage_,cursor,mnt)
{
XBT_DEBUG("See '%s'",mnt.name);
file_mount_name = (char *) xbt_malloc ((strlen(mnt.name)+1));
void HostImpl::getParams(vm_params_t params)
{
- *params = p_params;
+ *params = params_;
}
void HostImpl::setParams(vm_params_t params)
{
/* may check something here. */
- p_params = *params;
+ params_ = *params;
}
}}
{THROW_IMPOSSIBLE;} // FIXME: Host should not be a Resource
public:
- xbt_dynar_t p_storage;
- Cpu *p_cpu;
- simgrid::s4u::Host* piface = nullptr;
+ xbt_dynar_t storage_;
+ Cpu *cpu_;
+ simgrid::s4u::Host* piface_ = nullptr;
/** @brief Get the list of virtual machines on the current Host */
xbt_dynar_t getVms();
void getParams(vm_params_t params);
/** @brief Sets the params of that VM/PM */
void setParams(vm_params_t params);
- simgrid::s4u::Host* getHost() { return piface; }
+ simgrid::s4u::Host* getHost() { return piface_; }
private:
- s_vm_params_t p_params;
+ s_vm_params_t params_;
};
}
double start_time = this->last_updated;
double finish_time = surf_get_clock();
double cpu_load;
- if (surf_host->p_cpu->speed_.peak <= 0)
+ if (surf_host->cpu_->speed_.peak <= 0)
// Some users declare a pstate of speed 0 flops (e.g., to model boot time).
// We consider that the machine is then fully loaded. That's arbitrary but it avoids a NaN
cpu_load = 1;
else
- cpu_load = lmm_constraint_get_usage(surf_host->p_cpu->getConstraint()) / surf_host->p_cpu->speed_.peak;
+ cpu_load = lmm_constraint_get_usage(surf_host->cpu_->getConstraint()) / surf_host->cpu_->speed_.peak;
if (cpu_load > 1) // A machine with a load > 1 consumes as much as a fully loaded machine, not mores
cpu_load = 1;
this->last_updated = finish_time;
XBT_DEBUG("[update_energy of %s] period=[%.2f-%.2f]; current power peak=%.0E flop/s; consumption change: %.2f J -> %.2f J",
- surf_host->getName(), start_time, finish_time, surf_host->p_cpu->speed_.peak, previous_energy, energy_this_step);
+ surf_host->getName(), start_time, finish_time, surf_host->cpu_->speed_.peak, previous_energy, energy_this_step);
}
HostEnergy::HostEnergy(simgrid::s4u::Host *ptr) : host(ptr), last_updated(surf_get_clock())
if (vm) // If it's a VM, take the corresponding PM
host = vm->getPm()->extension<simgrid::surf::HostImpl>();
- HostEnergy *host_energy = host->piface->extension<HostEnergy>();
+ HostEnergy *host_energy = host->piface_->extension<HostEnergy>();
if(host_energy->last_updated < surf_get_clock())
host_energy->update();
, hostPM_(hostPM)
{
allVms_.push_back(this);
- piface = simgrid::s4u::Host::by_name_or_create(name);
- piface->extension_set<simgrid::surf::HostImpl>(this);
+ piface_ = simgrid::s4u::Host::by_name_or_create(name);
+ piface_->extension_set<simgrid::surf::HostImpl>(this);
}
/*
}
e_surf_vm_state_t VirtualMachine::getState() {
- return p_vm_state;
+ return vmState_;
}
void VirtualMachine::setState(e_surf_vm_state_t state) {
- p_vm_state = state;
+ vmState_ = state;
}
void VirtualMachine::turnOn() {
if (isOff()) {
static std::deque<VirtualMachine*> allVms_;
protected:
- e_surf_vm_state_t p_vm_state = SURF_VM_STATE_CREATED;
+ e_surf_vm_state_t vmState_ = SURF_VM_STATE_CREATED;
};
/*********
{
VirtualMachine* vm = new VMHL13(this, name, host_PM);
onVmCreation(vm);
- return vm->piface;
+ return vm->piface_;
}
/* In the real world, processes on the guest operating system will be somewhat degraded due to virtualization overhead.
/* iterate for all virtual machines */
for (VirtualMachine *ws_vm : VirtualMachine::allVms_) {
- Cpu *cpu = ws_vm->p_cpu;
+ Cpu *cpu = ws_vm->cpu_;
xbt_assert(cpu, "cpu-less host");
double solved_value = ws_vm->action_->getVariable()->value;
: VirtualMachine(model, name, host_PM)
{
/* Currently, we assume a VM has no storage. */
- p_storage = nullptr;
+ storage_ = nullptr;
/* Currently, a VM uses the network resource of its physical host. In
* host_lib, this network resource object is referred from two different keys.
sg_host_t host_VM = simgrid::s4u::Host::by_name_or_create(name);
host_VM->pimpl_netcard = host_PM->pimpl_netcard;
- p_vm_state = SURF_VM_STATE_CREATED;
+ vmState_ = SURF_VM_STATE_CREATED;
// //// CPU RELATED STUFF ////
// Roughly, create a vcpu resource by using the values of the sub_cpu one.
- CpuCas01 *sub_cpu = static_cast<CpuCas01*>(host_PM->pimpl_cpu);
+ CpuCas01 *sub_cpu = dynamic_cast<CpuCas01*>(host_PM->pimpl_cpu);
- p_cpu = surf_cpu_model_vm->createCpu(host_VM, // the machine hosting the VM
+ cpu_ = surf_cpu_model_vm->createCpu(host_VM, // the machine hosting the VM
sub_cpu->getSpeedPeakList(), 1 /*cores*/);
if (sub_cpu->getPState() != 0)
- p_cpu->setPState(sub_cpu->getPState());
+ cpu_->setPState(sub_cpu->getPState());
/* We create cpu_action corresponding to a VM process on the host operating system. */
/* FIXME: TODO: we have to periodically input GUESTOS_NOISE to the system? how ? */
action_ = sub_cpu->execution_start(0);
- XBT_VERB("Create VM(%s)@PM(%s) with %ld mounted disks", name, hostPM_->name().c_str(), xbt_dynar_length(p_storage));
+ XBT_VERB("Create VM(%s)@PM(%s) with %ld mounted disks", name, hostPM_->name().c_str(), xbt_dynar_length(storage_));
}
VMHL13::~VMHL13() {
- delete p_cpu;
+ delete cpu_;
}
void VMHL13::suspend()
{
action_->suspend();
- p_vm_state = SURF_VM_STATE_SUSPENDED;
+ vmState_ = SURF_VM_STATE_SUSPENDED;
}
void VMHL13::resume()
{
action_->resume();
- p_vm_state = SURF_VM_STATE_RUNNING;
+ vmState_ = SURF_VM_STATE_RUNNING;
}
void VMHL13::save()
{
- p_vm_state = SURF_VM_STATE_SAVING;
+ vmState_ = SURF_VM_STATE_SAVING;
/* FIXME: do something here */
action_->suspend();
- p_vm_state = SURF_VM_STATE_SAVED;
+ vmState_ = SURF_VM_STATE_SAVED;
}
void VMHL13::restore()
{
- p_vm_state = SURF_VM_STATE_RESTORING;
+ vmState_ = SURF_VM_STATE_RESTORING;
/* FIXME: do something here */
action_->resume();
- p_vm_state = SURF_VM_STATE_RUNNING;
+ vmState_ = SURF_VM_STATE_RUNNING;
}
/* Update the physical host of the given VM */