void surf_vm_model_init_HL13(){
if (surf_cpu_model_vm) {
surf_vm_model = new simgrid::surf::VMHL13Model();
- simgrid::surf::Model *model = surf_vm_model;
- xbt_dynar_push(all_existing_models, &model);
+ all_existing_models->push_back(surf_vm_model);
}
}
void VMHL13Model::updateActionsState(double /*now*/, double /*delta*/) {}
-VirtualMachine *VMHL13Model::createVM(const char *name, sg_host_t host_PM)
+s4u::Host *VMHL13Model::createVM(const char *name, sg_host_t host_PM)
{
VirtualMachine* vm = new VMHL13(this, name, host_PM);
- VMCreatedCallbacks(vm);
- return vm;
+ onVmCreation(vm);
+ 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 (VMModel::vm_list_t::iterator iter = VMModel::ws_vms.begin(); iter != VMModel::ws_vms.end(); ++iter) {
- VirtualMachine *ws_vm = &*iter;
- Cpu *cpu = ws_vm->p_cpu;
+ for (VirtualMachine *ws_vm : VirtualMachine::allVms_) {
+ 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;
-}
-
-void VMHL13::resume()
-{
- action_->resume();
- p_vm_state = SURF_VM_STATE_RUNNING;
-}
-
-void VMHL13::save()
-{
- p_vm_state = SURF_VM_STATE_SAVING;
-
- /* FIXME: do something here */
- action_->suspend();
- p_vm_state = SURF_VM_STATE_SAVED;
-}
-
-void VMHL13::restore()
-{
- p_vm_state = SURF_VM_STATE_RESTORING;
-
- /* FIXME: do something here */
- action_->resume();
- p_vm_state = SURF_VM_STATE_RUNNING;
-}
/* Update the physical host of the given VM */
void VMHL13::migrate(sg_host_t host_dest)
action_->setBound(bound);
}
-void VMHL13::setAffinity(Cpu *cpu, unsigned long mask){
- action_->setAffinity(cpu, mask);
-}
-
}
}