X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/7c047878cb2905079a6a0544f1a15134ae3ab3a6..e5fdc0f90b4c3ec53803150b783320e9cd4ebc75:/src/surf/vm_hl13.cpp diff --git a/src/surf/vm_hl13.cpp b/src/surf/vm_hl13.cpp index 399d2ce02a..41b183d503 100644 --- a/src/surf/vm_hl13.cpp +++ b/src/surf/vm_hl13.cpp @@ -11,11 +11,10 @@ XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(surf_vm); -void surf_vm_model_init_HL13(void){ +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); } } @@ -29,11 +28,11 @@ VMHL13Model::VMHL13Model() : VMModel() {} 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. @@ -68,9 +67,8 @@ double VMHL13Model::next_occuring_event(double now) **/ /* 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; @@ -97,7 +95,7 @@ VMHL13::VMHL13(VMModel *model, const char* name, sg_host_t host_PM) : 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. @@ -105,59 +103,30 @@ VMHL13::VMHL13(VMModel *model, const char* name, sg_host_t host_PM) * from the VM name, we have to make sure that the system does not call the * free callback for the network resource object. The network resource object * is still used by the physical machine. */ - sg_host_t host_VM = sg_host_by_name_or_create(name); + 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(host_PM->pimpl_cpu); + CpuCas01 *sub_cpu = dynamic_cast(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) @@ -203,9 +172,5 @@ void VMHL13::setBound(double bound){ action_->setBound(bound); } -void VMHL13::setAffinity(Cpu *cpu, unsigned long mask){ - action_->setAffinity(cpu, mask); -} - } }