doc/msg-tuto-src/masterworker3
doc/msg-tuto-src/masterworker4
examples/msg/cloud-masterworker/cloud-masterworker
-examples/msg/cloud-migration/cloud-migration
examples/msg/dht-kademlia/dht-kademlia
examples/msg/dht-pastry/dht-pastry
examples/msg/energy-onoff/energy-onoff
examples/s4u/async-waitall/s4u-async-waitall
examples/s4u/async-waitany/s4u-async-waitany
examples/s4u/cloud-capping/s4u-cloud-capping
+examples/s4u/cloud-migration/s4u-cloud-migration
examples/s4u/cloud-simple/s4u-cloud-simple
examples/s4u/dht-chord/s4u-dht-chord
+examples/s4u/dht-kademlia/s4u-dht-kademlia
+examples/s4u/energy-boot/s4u-energy-boot
examples/s4u/energy-exec/s4u-energy-exec
examples/s4u/energy-link/s4u-energy-link
examples/s4u/energy-vm/s4u-energy-vm
teshsuite/msg/async-waitall/async-waitall
teshsuite/msg/async-waitany/async-waitany
teshsuite/msg/cloud-capping/cloud-capping
+teshsuite/msg/cloud-migration/cloud-migration
teshsuite/msg/cloud-sharing/cloud-sharing
teshsuite/msg/cloud-simple/cloud-simple
teshsuite/msg/cloud-two-tasks/cloud-two-tasks
# C examples
-foreach(x app-masterworker
- cloud-masterworker cloud-migration
+foreach(x app-masterworker cloud-masterworker
dht-pastry energy-vm platform-failures
process-create
synchro-semaphore trace-categories
${CMAKE_CURRENT_SOURCE_DIR}/network-ns3/one_cluster_d.xml
${CMAKE_CURRENT_SOURCE_DIR}/network-ns3/two_clusters_d.xml PARENT_SCOPE)
-foreach(x app-masterworker
- cloud-masterworker cloud-migration
+foreach(x app-masterworker cloud-masterworker
dht-pastry dht-kademlia platform-failures
energy-vm
process-create
foreach (example actor-create actor-daemon actor-join actor-kill actor-lifetime actor-migration actor-suspend actor-yield
app-chainsend app-masterworker app-pingpong app-token-ring
async-wait async-waitany async-waitall
- cloud-capping cloud-simple
+ cloud-capping cloud-migration cloud-simple
energy-exec energy-boot energy-link energy-vm
exec-async exec-basic exec-dvfs exec-monitor exec-ptask exec-remote
io-file-system io-file-remote io-storage-raw
foreach(example actor-create actor-daemon actor-join actor-kill actor-lifetime actor-migration actor-suspend actor-yield
app-bittorrent app-chainsend app-masterworker app-pingpong app-token-ring
async-wait async-waitall async-waitany
- cloud-capping cloud-simple
+ cloud-capping cloud-migration cloud-simple
dht-chord dht-kademlia
energy-exec energy-boot energy-link energy-vm
exec-async exec-basic exec-dvfs exec-monitor exec-ptask exec-remote
--- /dev/null
+/* Copyright (c) 2007-2015, 2017. The SimGrid Team.
+ * All rights reserved. */
+
+/* This program is free software; you can redistribute it and/or modify it
+ * under the terms of the license (GNU LGPL) which comes with this package. */
+
+#include "simgrid/s4u.hpp"
+#include "simgrid/plugins/live_migration.h"
+#include "simgrid/s4u/VirtualMachine.hpp"
+
+XBT_LOG_NEW_DEFAULT_CATEGORY(s4u_cloud_migration, "Messages specific for this example");
+
+static void vm_migrate(simgrid::s4u::VirtualMachine* vm, simgrid::s4u::Host* dst_pm)
+{
+ simgrid::s4u::Host* src_pm = vm->getPm();
+ double mig_sta = simgrid::s4u::Engine::getClock();
+ sg_vm_migrate(vm, dst_pm);
+ double mig_end = simgrid::s4u::Engine::getClock();
+
+ XBT_INFO("%s migrated: %s->%s in %g s", vm->getCname(), src_pm->getCname(), dst_pm->getCname(), mig_end - mig_sta);
+}
+
+static void vm_migrate_async(simgrid::s4u::VirtualMachine* vm, simgrid::s4u::Host* dst_pm)
+{
+ simgrid::s4u::Actor::createActor("mig_wrk", simgrid::s4u::Host::current(), vm_migrate, vm, dst_pm);
+}
+
+static void master_main()
+{
+ simgrid::s4u::Host* pm0 = simgrid::s4u::Host::by_name("Fafard");
+ simgrid::s4u::Host* pm1 = simgrid::s4u::Host::by_name("Tremblay");
+ simgrid::s4u::Host* pm2 = simgrid::s4u::Host::by_name("Bourassa");
+
+ simgrid::s4u::VirtualMachine* vm0 = new simgrid::s4u::VirtualMachine("VM0", pm0, 1);
+ vm0->setRamsize(1e9); // 1Gbytes
+ vm0->start();
+
+ XBT_INFO("Test: Migrate a VM with %zu Mbytes RAM", vm0->getRamsize() / 1000 / 1000);
+ vm_migrate(vm0, pm1);
+
+ vm0->destroy();
+
+ vm0 = new simgrid::s4u::VirtualMachine("VM0", pm0, 1);
+ vm0->setRamsize(1e8); // 100Mbytes
+ vm0->start();
+
+ XBT_INFO("Test: Migrate a VM with %zu Mbytes RAM", vm0->getRamsize() / 1000 / 1000);
+ vm_migrate(vm0, pm1);
+
+ vm0->destroy();
+
+ vm0 = new simgrid::s4u::VirtualMachine("VM0", pm0, 1);
+ simgrid::s4u::VirtualMachine* vm1 = new simgrid::s4u::VirtualMachine("VM1", pm0, 1);
+
+ vm0->setRamsize(1e9); // 1Gbytes
+ vm1->setRamsize(1e9); // 1Gbytes
+ vm0->start();
+ vm1->start();
+
+ XBT_INFO("Test: Migrate two VMs at once from PM0 to PM1");
+ vm_migrate_async(vm0, pm1);
+ vm_migrate_async(vm1, pm1);
+ simgrid::s4u::this_actor::sleep_for(10000);
+
+ vm0->destroy();
+ vm1->destroy();
+
+ vm0 = new simgrid::s4u::VirtualMachine("VM0", pm0, 1);
+ vm1 = new simgrid::s4u::VirtualMachine("VM1", pm0, 1);
+
+ vm0->setRamsize(1e9); // 1Gbytes
+ vm1->setRamsize(1e9); // 1Gbytes
+ vm0->start();
+ vm1->start();
+
+ XBT_INFO("Test: Migrate two VMs at once to different PMs");
+ vm_migrate_async(vm0, pm1);
+ vm_migrate_async(vm1, pm2);
+ simgrid::s4u::this_actor::sleep_for(10000);
+
+ vm0->destroy();
+ vm1->destroy();
+}
+
+int main(int argc, char* argv[])
+{
+ /* Get the arguments */
+ simgrid::s4u::Engine e(&argc, argv);
+ sg_vm_live_migration_plugin_init();
+
+ /* load the platform file */
+ e.loadPlatform(argv[1]);
+
+ simgrid::s4u::Actor::createActor("master_", simgrid::s4u::Host::by_name("Fafard"), master_main);
+
+ e.run();
+
+ XBT_INFO("Bye (simulation time %g)", simgrid::s4u::Engine::getClock());
+
+ return 0;
+}
--- /dev/null
+$ $SG_TEST_EXENV ${bindir:=.}/s4u-cloud-migration ${platfdir}/small_platform.xml --log=no_loc "--log=root.fmt:[%10.6r]%e(%i:%P@%h)%e%m%n"
+> [ 0.000000] (1:master_@Fafard) Test: Migrate a VM with 1000 Mbytes RAM
+> [132.765801] (1:master_@Fafard) VM0 migrated: Fafard->Tremblay in 132.766 s
+> [132.765801] (1:master_@Fafard) Test: Migrate a VM with 100 Mbytes RAM
+> [146.111793] (1:master_@Fafard) VM0 migrated: Fafard->Tremblay in 13.346 s
+> [146.111793] (1:master_@Fafard) Test: Migrate two VMs at once from PM0 to PM1
+> [411.566271] (8:mig_wrk@Fafard) VM1 migrated: Fafard->Tremblay in 265.454 s
+> [411.566271] (6:mig_wrk@Fafard) VM0 migrated: Fafard->Tremblay in 265.454 s
+> [10146.111793] (1:master_@Fafard) Test: Migrate two VMs at once to different PMs
+> [10362.620589] (14:mig_wrk@Fafard) VM1 migrated: Fafard->Bourassa in 216.509 s
+> [10411.547334] (12:mig_wrk@Fafard) VM0 migrated: Fafard->Tremblay in 265.436 s
+> [20146.111793] (0:maestro@) Bye (simulation time 20146.1)
foreach(x actions-comm actions-storage
app-pingpong app-token-ring
async-wait async-waitall async-waitany
- cloud-capping cloud-sharing cloud-two-tasks cloud-simple
+ cloud-capping cloud-migration cloud-sharing cloud-two-tasks cloud-simple
get_sender host_on_off host_on_off_recv host_on_off_processes
process-daemon process-kill process-join process-lifetime process-migration process-suspend process-yield
energy-consumption energy-ptask energy-pstate platform-properties
actions-comm actions-storage
async-wait async-waitall async-waitany
app-bittorrent app-chainsend app-pingpong app-token-ring
- cloud-capping cloud-two-tasks cloud-simple
+ cloud-capping cloud-migration cloud-two-tasks cloud-simple
energy-pstate
host_on_off host_on_off_processes host_on_off_recv
get_sender
static void vm_migrate(msg_vm_t vm, msg_host_t dst_pm)
{
msg_host_t src_pm = MSG_vm_get_pm(vm);
- double mig_sta = MSG_get_clock();
+ double mig_sta = MSG_get_clock();
MSG_vm_migrate(vm, dst_pm);
double mig_end = MSG_get_clock();
- XBT_INFO("%s migrated: %s->%s in %g s", MSG_vm_get_name(vm),
- MSG_host_get_name(src_pm), MSG_host_get_name(dst_pm),
- mig_end - mig_sta);
+ XBT_INFO("%s migrated: %s->%s in %g s", MSG_vm_get_name(vm), MSG_host_get_name(src_pm), MSG_host_get_name(dst_pm),
+ mig_end - mig_sta);
}
-static int migration_worker_main(int argc, char *argv[])
+static int migration_worker_main(int argc, char* argv[])
{
xbt_assert(argc == 3);
- char *vm_name = argv[1];
- char *dst_pm_name = argv[2];
+ char* vm_name = argv[1];
+ char* dst_pm_name = argv[2];
msg_vm_t vm = (msg_vm_t)MSG_host_by_name(vm_name);
msg_host_t dst_pm = MSG_host_by_name(dst_pm_name);
static void vm_migrate_async(msg_vm_t vm, msg_host_t dst_pm)
{
- const char *vm_name = MSG_vm_get_name(vm);
- const char *dst_pm_name = MSG_host_get_name(dst_pm);
- msg_host_t host = MSG_host_self();
+ const char* vm_name = MSG_vm_get_name(vm);
+ const char* dst_pm_name = MSG_host_get_name(dst_pm);
+ msg_host_t host = MSG_host_self();
- const char *pr_name = "mig_wrk";
- char **argv = xbt_new(char *, 4);
- argv[0] = xbt_strdup(pr_name);
- argv[1] = xbt_strdup(vm_name);
- argv[2] = xbt_strdup(dst_pm_name);
- argv[3] = NULL;
+ const char* pr_name = "mig_wrk";
+ char** argv = xbt_new(char*, 4);
+ argv[0] = xbt_strdup(pr_name);
+ argv[1] = xbt_strdup(vm_name);
+ argv[2] = xbt_strdup(dst_pm_name);
+ argv[3] = NULL;
MSG_process_create_with_arguments(pr_name, migration_worker_main, NULL, host, 3, argv);
}
-static int master_main(int argc, char *argv[])
+static int master_main(int argc, char* argv[])
{
msg_host_t pm0 = MSG_host_by_name("Fafard");
msg_host_t pm1 = MSG_host_by_name("Tremblay");
MSG_vm_destroy(vm0);
- vm0 = MSG_vm_create_core(pm0, "VM0");
+ vm0 = MSG_vm_create_core(pm0, "VM0");
msg_vm_t vm1 = MSG_vm_create_core(pm0, "VM1");
MSG_vm_set_ramsize(vm0, 1e9); // 1Gbytes
static void launch_master(msg_host_t host)
{
- const char *pr_name = "master_";
- char **argv = xbt_new(char *, 2);
- argv[0] = xbt_strdup(pr_name);
- argv[1] = NULL;
+ const char* pr_name = "master_";
+ char** argv = xbt_new(char*, 2);
+ argv[0] = xbt_strdup(pr_name);
+ argv[1] = NULL;
MSG_process_create_with_arguments(pr_name, master_main, NULL, host, 1, argv);
}
-int main(int argc, char *argv[])
+int main(int argc, char* argv[])
{
/* Get the arguments */
MSG_init(&argc, argv);
/* load the platform file */
MSG_create_environment(argv[1]);
- msg_host_t pm0 = MSG_host_by_name("Fafard");
+ msg_host_t pm0 = MSG_host_by_name("Fafard");
launch_master(pm0);
int res = MSG_main();