From: Martin Quinson Date: Sun, 28 Aug 2016 16:56:10 +0000 (+0200) Subject: VM: code simplification by ensuring that the piface field is set X-Git-Tag: v3_14~470 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/bfed90d7c58bf90f06017312bc82965a416986eb VM: code simplification by ensuring that the piface field is set - that field points to the s4u vision of myself. - Fix the prototype of surf::VMModel::createVM() to ease the life of its unique user --- diff --git a/src/simix/libsmx.cpp b/src/simix/libsmx.cpp index 91447fe93c..f31aa0e01c 100644 --- a/src/simix/libsmx.cpp +++ b/src/simix/libsmx.cpp @@ -194,8 +194,7 @@ e_smx_state_t simcall_execution_wait(smx_activity_t execution) sg_host_t simcall_vm_create(const char *name, sg_host_t phys_host) { return simgrid::simix::kernelImmediate([&] { - surf_vm_model->createVM(name, phys_host); - sg_host_t host = sg_host_by_name(name); + sg_host_t host = surf_vm_model->createVM(name, phys_host); SIMIX_host_create(host); return host; diff --git a/src/surf/virtual_machine.cpp b/src/surf/virtual_machine.cpp index 4b4a8957df..ea65bc75d1 100644 --- a/src/surf/virtual_machine.cpp +++ b/src/surf/virtual_machine.cpp @@ -39,7 +39,8 @@ VirtualMachine::VirtualMachine(HostModel *model, const char *name, simgrid::s4u: , hostPM_(hostPM) { VMModel::ws_vms.push_back(*this); - simgrid::s4u::Host::by_name_or_create(name)->extension_set(this); + piface = simgrid::s4u::Host::by_name_or_create(name); + piface->extension_set(this); } /* diff --git a/src/surf/virtual_machine.hpp b/src/surf/virtual_machine.hpp index c69a11ca16..2ba18598d0 100644 --- a/src/surf/virtual_machine.hpp +++ b/src/surf/virtual_machine.hpp @@ -114,7 +114,7 @@ public: * @param name The name of the new VM * @param host_PM The real machine hosting the VM */ - virtual VirtualMachine *createVM(const char *name, sg_host_t host_PM)=0; + virtual s4u::Host *createVM(const char *name, sg_host_t host_PM)=0; void adjustWeightOfDummyCpuActions() {}; typedef boost::intrusive::member_hook< diff --git a/src/surf/vm_hl13.cpp b/src/surf/vm_hl13.cpp index c51615efaa..09cb6630b6 100644 --- a/src/surf/vm_hl13.cpp +++ b/src/surf/vm_hl13.cpp @@ -28,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; + return vm->piface; } /* In the real world, processes on the guest operating system will be somewhat degraded due to virtualization overhead. diff --git a/src/surf/vm_hl13.hpp b/src/surf/vm_hl13.hpp index 478b5092a0..54642d3f4e 100644 --- a/src/surf/vm_hl13.hpp +++ b/src/surf/vm_hl13.hpp @@ -33,7 +33,7 @@ public: VMHL13Model(); ~VMHL13Model(){}; - VirtualMachine *createVM(const char *name, sg_host_t host_PM) override; + s4u::Host *createVM(const char *name, sg_host_t host_PM) override; double next_occuring_event(double now) override; void adjustWeightOfDummyCpuActions() override {}; void updateActionsState(double /*now*/, double /*delta*/) override;