- * The total CPU share these processes get is smaller than that of the VM process gets on a host operating system. */
-// const double virt_overhead = 0.95;
-const double virt_overhead = 1;
+ * The total CPU share these processes get is smaller than that of the VM process gets on a host operating system.
+ * FIXME: add a configuration flag for this
+ */
+const double virt_overhead = 1; // 0.95
+
+static void host_state_change(s4u::Host const& host)
+{
+ if (not host.is_on()) { // just turned off.
+ std::vector<s4u::VirtualMachine*> trash;
+ /* Find all VMs living on that host */
+ for (s4u::VirtualMachine* const& vm : VirtualMachineImpl::allVms_)
+ if (vm->get_pm() == &host)
+ trash.push_back(vm);
+ for (s4u::VirtualMachine* vm : trash)
+ vm->shutdown();
+ }
+}
+
+static void add_active_exec(s4u::Actor const&, s4u::Exec const& task)
+{
+ s4u::VirtualMachine* vm = dynamic_cast<s4u::VirtualMachine*>(task.get_host());
+ if (vm != nullptr) {
+ VirtualMachineImpl* vm_impl = vm->get_impl();
+ vm_impl->active_tasks_ = vm_impl->active_tasks_ + 1;
+ vm_impl->update_action_weight();
+ }
+}
+
+static void remove_active_exec(s4u::Actor const&, s4u::Exec const& task)
+{
+ s4u::VirtualMachine* vm = dynamic_cast<s4u::VirtualMachine*>(task.get_host());
+ if (vm != nullptr) {
+ VirtualMachineImpl* vm_impl = vm->get_impl();
+ vm_impl->active_tasks_ = vm_impl->active_tasks_ - 1;
+ vm_impl->update_action_weight();
+ }
+}