Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Cannot destroy iface before impl.
[simgrid.git] / src / plugins / vm / VirtualMachineImpl.hpp
index b2597a50338a2a4aadad28bf2011688d12fb9a35..031c355cfb9fe851dd763ef987911a4f35af7d5d 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2004-2020. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2004-2021. 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. */
@@ -38,15 +38,16 @@ public:
 
   static std::deque<s4u::VirtualMachine*> allVms_;
 
-  explicit VirtualMachineImpl(s4u::VirtualMachine* piface, s4u::Host* host, int core_amount, size_t ramsize);
+  explicit VirtualMachineImpl(const std::string& name, s4u::VirtualMachine* piface, s4u::Host* host, int core_amount,
+                              size_t ramsize);
   ~VirtualMachineImpl() override;
 
-  virtual void suspend(kernel::actor::ActorImpl* issuer);
-  virtual void resume();
-  virtual void shutdown(kernel::actor::ActorImpl* issuer);
+  void suspend(kernel::actor::ActorImpl* issuer);
+  void resume();
+  void shutdown(kernel::actor::ActorImpl* issuer);
 
   /** @brief Change the physical host on which the given VM is running */
-  virtual void set_physical_host(s4u::Host* dest);
+  void set_physical_host(s4u::Host* dest);
   /** @brief Get the physical host on which the given VM is running */
   s4u::Host* get_physical_host() const { return physical_host_; }
 
@@ -59,7 +60,10 @@ public:
   unsigned int get_core_amount() const { return core_amount_; }
   kernel::resource::Action* get_action() const { return action_; }
 
-  virtual void set_bound(double bound);
+  const s4u::VirtualMachine* get_iface() const override { return piface_; }
+  s4u::VirtualMachine* get_iface() override { return piface_; }
+
+  void set_bound(double bound);
 
   void update_action_weight();
 
@@ -71,6 +75,7 @@ public:
   bool is_migrating() const { return is_migrating_; }
 
 private:
+  s4u::VirtualMachine* piface_;
   kernel::resource::Action* action_ = nullptr;
   unsigned int active_execs_        = 0;
   s4u::Host* physical_host_;
@@ -90,7 +95,7 @@ private:
  */
 class XBT_PRIVATE VMModel : public surf::HostModel {
 public:
-  VMModel();
+  explicit VMModel(const std::string& name);
 
   double next_occurring_event(double now) override;
   void update_actions_state(double /*now*/, double /*delta*/) override{};
@@ -100,9 +105,7 @@ public:
     return nullptr;
   };
 };
-}
-}
-
-XBT_PUBLIC_DATA simgrid::vm::VMModel* surf_vm_model;
+} // namespace vm
+} // namespace simgrid
 
 #endif /* VM_INTERFACE_HPP_ */