X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/f3e4803befab19389587dd1d9af5ecdeffec551e..a34d8237b8267686bbd259670f27da273ff5236e:/src/surf/vm_interface.hpp diff --git a/src/surf/vm_interface.hpp b/src/surf/vm_interface.hpp index c050250d70..961a04e864 100644 --- a/src/surf/vm_interface.hpp +++ b/src/surf/vm_interface.hpp @@ -1,9 +1,11 @@ -/* Copyright (c) 2004-2014. The SimGrid Team. +/* Copyright (c) 2004-2015. The SimGrid Team. * All rights reserved. */ /* 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 + #include "host_interface.hpp" #ifndef VM_INTERFACE_HPP_ @@ -16,8 +18,8 @@ * Classes * ***********/ -class VMModel; -class VM; +class XBT_PRIVATE VMModel; +class XBT_PRIVATE VM; /************* * Callbacks * @@ -26,45 +28,17 @@ class VM; /** @ingroup SURF_callbacks * @brief Callbacks fired after VM creation. Signature: `void(VM*)` */ -extern surf_callback(void, VM*) VMCreatedCallbacks; +extern XBT_PRIVATE surf_callback(void, VM*) VMCreatedCallbacks; /** @ingroup SURF_callbacks * @brief Callbacks fired after VM destruction. Signature: `void(VM*)` */ -extern surf_callback(void, VM*) VMDestructedCallbacks; +extern XBT_PRIVATE surf_callback(void, VM*) VMDestructedCallbacks; /** @ingroup SURF_callbacks * @brief Callbacks after VM State changes. Signature: `void(VMAction*)` */ -extern surf_callback(void, VM*) VMStateChangedCallbacks; - -/********* - * Model * - *********/ -/** @ingroup SURF_vm_interface - * @brief SURF VM model interface class - * @details A model is an object which handle the interactions between its Resources and its Actions - */ -class VMModel : public HostModel { -public: - VMModel() :HostModel(){} - ~VMModel(){}; - - Host *createHost(const char *name){DIE_IMPOSSIBLE;} - - /** - * @brief Create a new VM - * - * @param name The name of the new VM - * @param host_PM The real machine hosting the VM - * - */ - virtual VM *createVM(const char *name, surf_resource_t host_PM)=0; - void adjustWeightOfDummyCpuActions() {}; - - typedef boost::intrusive::list > vm_list_t; - static vm_list_t ws_vms; -}; +extern XBT_PRIVATE surf_callback(void, VM*) VMStateChangedCallbacks; /************ * Resource * @@ -74,11 +48,10 @@ public: * @brief SURF VM interface class * @details A VM represent a virtual machine */ -class VM : public Host, - public boost::intrusive::list_base_hook<> { +class VM : public Host { public: /** - * @brief VM constructor + * @brief Constructor * * @param model VMModel associated to this VM * @param name The name of the VM @@ -89,9 +62,7 @@ public: VM(Model *model, const char *name, xbt_dict_t props, RoutingEdge *netElm, Cpu *cpu); - /** - * @brief WdorkstationVM destructor - */ + /** @brief Destructor */ ~VM(); void setState(e_surf_resource_state_t state); @@ -108,11 +79,8 @@ public: /** @brief Restore the VM (Not yet implemented) */ virtual void restore()=0; - /** @brief Migrate the VM to the destination host - * - * @param ind_vm_ws_dest The destination host - */ - virtual void migrate(surf_resource_t ind_vm_ws_dest)=0; + /** @brief Migrate the VM to the destination host */ + virtual void migrate(surf_resource_t dest_PM)=0; /** @brief Get the physical machine hosting the VM */ virtual surf_resource_t getPm()=0; @@ -124,6 +92,38 @@ public: CpuAction *p_action; Host *p_subWs; // Pointer to the ''host'' OS e_surf_vm_state_t p_currentState; +public: + boost::intrusive::list_member_hook<> vm_hook; +}; + +/********* + * Model * + *********/ +/** @ingroup SURF_vm_interface + * @brief SURF VM model interface class + * @details A model is an object which handle the interactions between its Resources and its Actions + */ +class VMModel : public HostModel { +public: + VMModel() :HostModel(){} + ~VMModel(){}; + + Host *createHost(const char *name){DIE_IMPOSSIBLE;} + + /** + * @brief Create a new VM + * + * @param name The name of the new VM + * @param host_PM The real machine hosting the VM + * + */ + virtual VM *createVM(const char *name, surf_resource_t host_PM)=0; + void adjustWeightOfDummyCpuActions() {}; + + typedef boost::intrusive::member_hook< + VM, boost::intrusive::list_member_hook<>, &VM::vm_hook> VmOptions; + typedef boost::intrusive::list > vm_list_t; + static vm_list_t ws_vms; }; /**********