X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/61e365017e7f57fdf87fa41347e851a3cd4eab60..d83142e8e1b7e87719cb05ff96b4108ca7138f36:/teshsuite/s4u/vm-live-migration/vm-live-migration.cpp diff --git a/teshsuite/s4u/vm-live-migration/vm-live-migration.cpp b/teshsuite/s4u/vm-live-migration/vm-live-migration.cpp index b5b78b2220..11fd36ab73 100644 --- a/teshsuite/s4u/vm-live-migration/vm-live-migration.cpp +++ b/teshsuite/s4u/vm-live-migration/vm-live-migration.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2007-2020. The SimGrid Team. +/* Copyright (c) 2007-2021. The SimGrid Team. * All rights reserved. */ /* This program is free software; you can redistribute it and/or modify it @@ -19,9 +19,10 @@ static void task_executor() simgrid::s4u::this_actor::sleep_for(3); // Breaks everything ptr->wait(); - XBT_INFO("Task done. It's running on %s@%s that runs at %.0ef/s. host2 runs at %.0ef/s", ptr->get_host()->get_cname(), - dynamic_cast(ptr->get_host())->get_pm()->get_cname(), - ptr->get_host()->get_speed(), simgrid::s4u::Host::by_name("host2")->get_speed()); + const auto* vm = dynamic_cast(ptr->get_host()); + xbt_assert(vm != nullptr, "Hey, I expected to run on a VM"); + XBT_INFO("Task done. It's running on %s@%s that runs at %.0ef/s. host2 runs at %.0ef/s", vm->get_cname(), + vm->get_pm()->get_cname(), vm->get_speed(), simgrid::s4u::Host::by_name("host2")->get_speed()); } int main(int argc, char* argv[]) @@ -35,14 +36,14 @@ int main(int argc, char* argv[]) xbt_assert(argc == 2, "Usage: %s platform.xml\n", argv[0]); e.load_platform(argv[1]); - auto* pm = simgrid::s4u::Host::by_name("host1"); - auto* vm = new simgrid::s4u::VirtualMachine("VM0", pm, 1 /*nCores*/); + auto* pm = e.host_by_name("host1"); + auto* vm = pm->create_vm("VM0", 1 /*nCores*/); vm->set_ramsize(1250000000)->start(); simgrid::s4u::Actor::create("executor", vm, task_executor); simgrid::s4u::Actor::create("migration", pm, [vm]() { XBT_INFO("%s migration started", vm->get_cname()); - auto* old = vm->get_pm(); + const auto* old = vm->get_pm(); sg_vm_migrate(vm, simgrid::s4u::Host::by_name("host2"));