+const double virt_overhead = 1; // 0.95
+
+static void hostStateChange(s4u::Host& host)
+{
+ if (host.isOff()) { // just turned off.
+ std::vector<s4u::VirtualMachine*> trash;
+ /* Find all VMs living on that host */
+ for (s4u::VirtualMachine* const& vm : VirtualMachineImpl::allVms_)
+ if (vm->getPm() == &host)
+ trash.push_back(vm);
+ for (s4u::VirtualMachine* vm : trash)
+ vm->pimpl_vm_->shutdown(SIMIX_process_self());
+ }
+}
+VMModel::VMModel()
+{
+ s4u::Host::onStateChange.connect(hostStateChange);
+}