+ s4u::VirtualMachine::on_start(*get_iface());
+ get_iface()->on_this_start(*get_iface());
+ s4u::VmHostExt::ensureVmExtInstalled();
+
+ if (physical_host_->extension<s4u::VmHostExt>() == nullptr)
+ physical_host_->extension_set(new s4u::VmHostExt());
+
+ if (size_t pm_ramsize = physical_host_->extension<s4u::VmHostExt>()->ramsize;
+ pm_ramsize &&
+ not physical_host_->extension<s4u::VmHostExt>()->overcommit) { /* Need to verify that we don't overcommit */
+ /* Retrieve the memory occupied by the VMs on that host. Yep, we have to traverse all VMs of all hosts for that */
+ size_t total_ramsize_of_vms = 0;
+ for (auto const* ws_vm : allVms_)
+ if (physical_host_ == ws_vm->get_pm())
+ total_ramsize_of_vms += ws_vm->get_ramsize();
+
+ if (total_ramsize_of_vms + get_ramsize() > pm_ramsize) {
+ XBT_WARN("cannot start %s@%s due to memory shortage: get_ramsize() %zu, free %zu, pm_ramsize %zu (bytes).",
+ get_cname(), physical_host_->get_cname(), get_ramsize(), pm_ramsize - total_ramsize_of_vms, pm_ramsize);
+ throw VmFailureException(XBT_THROW_POINT,
+ xbt::string_printf("Memory shortage on host '%s', VM '%s' cannot be started",
+ physical_host_->get_cname(), get_cname()));
+ }
+ }
+ vm_state_ = s4u::VirtualMachine::State::RUNNING;
+
+ s4u::VirtualMachine::on_started(*get_iface());
+ get_iface()->on_this_started(*get_iface());
+}
+
+void VirtualMachineImpl::suspend(const actor::ActorImpl* issuer)
+{
+ s4u::VirtualMachine::on_suspend(*get_iface());
+ get_iface()->on_this_suspend(*get_iface());
+