// const double virt_overhead = 0.95;
const double virt_overhead = 1;
+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);
+}
+
double VMModel::nextOccuringEvent(double now)
{
/* TODO: update action's cost with the total cost of processes on the VM. */
THROW_IMPOSSIBLE;
break;
}
- XBT_VERB("Shuting down the VM %s even if it's not running but %s", piface_->getCname(), stateName);
+ XBT_VERB("Shutting down the VM %s even if it's not running but %s", piface_->getCname(), stateName);
}
xbt_swag_t process_list = piface_->extension<simgrid::simix::Host>()->process_list;
smx_actor_t smx_process;
smx_actor_t smx_process_safe;
xbt_swag_foreach_safe(smx_process, smx_process_safe, process_list) {
- XBT_DEBUG("kill %s", smx_process->cname());
+ XBT_DEBUG("kill %s@%s on behalf of %s which shutdown that VM.", smx_process->cname(), smx_process->host->getCname(),
+ issuer->cname());
SIMIX_process_kill(smx_process, issuer);
}
*/
class VMModel : public surf::HostModel {
public:
+ VMModel();
void ignoreEmptyVmInPmLMM() override{};
double nextOccuringEvent(double now) override;
Host::~Host()
{
- /* Clean Simulator data */
+ /* All processes should be gone when the host is turned off (by the end of the simulation). */
if (xbt_swag_size(process_list) != 0) {
std::string msg = std::string("Shutting down host, but it's not empty:");
smx_actor_t process = nullptr;
smx_actor_t process = nullptr;
xbt_swag_foreach(process, host->process_list) {
SIMIX_process_kill(process, issuer);
- XBT_DEBUG("Killing %s@%s on behalf of %s", process->cname(), process->host->getCname(), issuer->cname());
+ XBT_DEBUG("Killing %s@%s on behalf of %s which turned off that host.", process->cname(),
+ process->host->getCname(), issuer->cname());
}
}
} else {
static void task_cleanup_handler(void *task)
{
- MSG_task_destroy(task);
+ if (task)
+ MSG_task_destroy(task);
}
static int process_daemon(int argc, char *argv[])
MSG_process_sleep(10);
XBT_INFO(" Turn Jupiter off");
MSG_host_off(jupiter);
- XBT_INFO("Test 5 seems ok, cool !(number of Process : %d, it should be 2", MSG_process_get_number());
+ XBT_INFO("Test 5 seems ok (number of Process: %d, it should be 2)", MSG_process_get_number());
}
test =6;
> [Tremblay:commTX:(3) 10.000000] [msg_test/INFO] Start TX
> [Tremblay:test_launcher:(1) 10.000000] [msg_test/INFO] number of processes: 3
> [Tremblay:test_launcher:(1) 20.000000] [msg_test/INFO] Turn Jupiter off
-> [Tremblay:test_launcher:(1) 20.000000] [msg_test/INFO] Test 5 seems ok, cool !(number of Process : 2, it should be 2
+> [Tremblay:test_launcher:(1) 20.000000] [msg_test/INFO] Test 5 seems ok (number of Process: 2, it should be 2)
> [Tremblay:test_launcher:(1) 20.000000] [msg_test/INFO] Test done. See you!
> [Tremblay:commTX:(3) 40.000000] [msg_test/INFO] TX done
> [40.000000] [msg_test/INFO] Simulation time 40