include examples/c/async-waitany/async-waitany_d.xml
include examples/c/cloud-capping/cloud-capping.c
include examples/c/cloud-capping/cloud-capping.tesh
+include examples/c/cloud-migration/cloud-migration.c
+include examples/c/cloud-migration/cloud-migration.tesh
include examples/c/cloud-simple/cloud-simple.c
include examples/c/cloud-simple/cloud-simple.tesh
include examples/c/energy-exec/energy-exec.c
include teshsuite/msg/async-wait/async-wait3_d.xml
include teshsuite/msg/async-wait/async-wait4_d.xml
include teshsuite/msg/async-wait/async-wait_d.xml
-include teshsuite/msg/cloud-migration/cloud-migration.c
-include teshsuite/msg/cloud-migration/cloud-migration.tesh
include teshsuite/msg/cloud-two-tasks/cloud-two-tasks.c
include teshsuite/msg/cloud-two-tasks/cloud-two-tasks.tesh
include teshsuite/msg/energy-ptask/energy-ptask.c
.. example-tab:: examples/s4u/cloud-migration/s4u-cloud-migration.cpp
+ .. example-tab:: examples/c/cloud-migration/cloud-migration.c
+
=======================
Model-Checking Examples
=======================
actor-create actor-daemon actor-exiting actor-join actor-kill actor-migrate actor-suspend actor-yield
app-pingpong app-token-ring
async-waitall async-waitany
- cloud-capping cloud-simple
+ cloud-capping cloud-migration cloud-simple
exec-dvfs
energy-exec
io-disk-raw io-file-remote
actor-create actor-daemon actor-exiting actor-join actor-kill actor-migrate actor-suspend actor-yield
app-chainsend app-pingpong app-token-ring
async-waitall async-waitany
- cloud-capping cloud-simple
+ cloud-capping cloud-migration cloud-simple
exec-dvfs
energy-exec
io-disk-raw io-file-remote
--- /dev/null
+/* Copyright (c) 2007-2020. 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/actor.h"
+#include "simgrid/engine.h"
+#include "simgrid/host.h"
+#include "simgrid/mailbox.h"
+#include "simgrid/plugins/live_migration.h"
+#include "simgrid/vm.h"
+#include "xbt/log.h"
+#include "xbt/str.h"
+#include "xbt/sysdep.h"
+
+XBT_LOG_NEW_DEFAULT_CATEGORY(cloud_migration, "Messages specific for this example");
+
+static void vm_migrate(sg_vm_t vm, sg_host_t dst_pm)
+{
+ const_sg_host_t src_pm = sg_vm_get_pm(vm);
+ double mig_sta = simgrid_get_clock();
+ sg_vm_migrate(vm, dst_pm);
+ double mig_end = simgrid_get_clock();
+
+ XBT_INFO("%s migrated: %s->%s in %g s", sg_vm_get_name(vm), sg_host_get_name(src_pm), sg_host_get_name(dst_pm),
+ mig_end - mig_sta);
+}
+
+static void migration_worker_main(int argc, char* argv[])
+{
+ xbt_assert(argc == 3);
+ const char* vm_name = argv[1];
+ const char* dst_pm_name = argv[2];
+
+ sg_vm_t vm = (sg_vm_t)sg_host_by_name(vm_name);
+ sg_host_t dst_pm = sg_host_by_name(dst_pm_name);
+
+ vm_migrate(vm, dst_pm);
+}
+
+static void vm_migrate_async(const_sg_vm_t vm, const_sg_host_t dst_pm)
+{
+ const char* vm_name = sg_vm_get_name(vm);
+ const char* dst_pm_name = sg_host_get_name(dst_pm);
+
+ const char* argv[] = {"mig_work", vm_name, dst_pm_name, NULL};
+ sg_actor_t actor = sg_actor_init("mig_wrk", sg_host_self());
+ sg_actor_start(actor, migration_worker_main, 3, argv);
+}
+
+static void master_main(XBT_ATTRIB_UNUSED int argc, XBT_ATTRIB_UNUSED char* argv[])
+{
+ sg_host_t pm0 = sg_host_by_name("Fafard");
+ sg_host_t pm1 = sg_host_by_name("Tremblay");
+ const_sg_host_t pm2 = sg_host_by_name("Bourassa");
+
+ sg_vm_t vm0 = sg_vm_create_core(pm0, "VM0");
+ sg_vm_set_ramsize(vm0, 1e9); // 1Gbytes
+ sg_vm_start(vm0);
+
+ XBT_INFO("Test: Migrate a VM with %zu Mbytes RAM", sg_vm_get_ramsize(vm0) / 1000 / 1000);
+ vm_migrate(vm0, pm1);
+
+ sg_vm_destroy(vm0);
+
+ vm0 = sg_vm_create_core(pm0, "VM0");
+ sg_vm_set_ramsize(vm0, 1e8); // 100Mbytes
+ sg_vm_start(vm0);
+
+ XBT_INFO("Test: Migrate a VM with %zu Mbytes RAM", sg_vm_get_ramsize(vm0) / 1000 / 1000);
+ vm_migrate(vm0, pm1);
+
+ sg_vm_destroy(vm0);
+
+ vm0 = sg_vm_create_core(pm0, "VM0");
+ sg_vm_t vm1 = sg_vm_create_core(pm0, "VM1");
+
+ sg_vm_set_ramsize(vm0, 1e9); // 1Gbytes
+ sg_vm_set_ramsize(vm1, 1e9); // 1Gbytes
+ sg_vm_start(vm0);
+ sg_vm_start(vm1);
+
+ XBT_INFO("Test: Migrate two VMs at once from PM0 to PM1");
+ vm_migrate_async(vm0, pm1);
+ vm_migrate_async(vm1, pm1);
+ sg_actor_sleep_for(10000);
+
+ sg_vm_destroy(vm0);
+ sg_vm_destroy(vm1);
+
+ vm0 = sg_vm_create_core(pm0, "VM0");
+ vm1 = sg_vm_create_core(pm0, "VM1");
+
+ sg_vm_set_ramsize(vm0, 1e9); // 1Gbytes
+ sg_vm_set_ramsize(vm1, 1e9); // 1Gbytes
+ sg_vm_start(vm0);
+ sg_vm_start(vm1);
+
+ XBT_INFO("Test: Migrate two VMs at once to different PMs");
+ vm_migrate_async(vm0, pm1);
+ vm_migrate_async(vm1, pm2);
+ sg_actor_sleep_for(10000);
+
+ sg_vm_destroy(vm0);
+ sg_vm_destroy(vm1);
+}
+
+int main(int argc, char* argv[])
+{
+ /* Get the arguments */
+ simgrid_init(&argc, argv);
+ sg_vm_live_migration_plugin_init();
+
+ /* load the platform file */
+ simgrid_load_platform(argv[1]);
+
+ sg_actor_t actor = sg_actor_init("master_", sg_host_by_name("Fafard"));
+ sg_actor_start(actor, master_main, 0, NULL);
+
+ simgrid_run();
+ XBT_INFO("Bye (simulation time %g)", simgrid_get_clock());
+
+ return 0;
+}
-$ ${bindir:=.}/cloud-migration ${platfdir}/small_platform.xml --log=no_loc "--log=root.fmt:[%10.6r]%e(%i:%P@%h)%e%m%n"
+$ ${bindir:=.}/cloud-migration-c ${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] (7: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
+> [10362.620589] (13: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)
# C examples
foreach(x async-wait
- cloud-migration cloud-two-tasks
+ cloud-two-tasks
get_sender host_on_off host_on_off_recv
process-lifetime
energy-ptask platform-properties
foreach(x
async-wait
app-bittorrent
- cloud-migration cloud-two-tasks
+ cloud-two-tasks
host_on_off host_on_off_processes host_on_off_recv
get_sender
task_destroy_cancel task_listen_from task_progress
+++ /dev/null
-/* Copyright (c) 2007-2020. 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/msg.h"
-#include "simgrid/plugins/live_migration.h"
-
-XBT_LOG_NEW_DEFAULT_CATEGORY(msg_test, "Messages specific for this msg example");
-
-static void vm_migrate(msg_vm_t vm, msg_host_t dst_pm)
-{
- const_sg_host_t src_pm = MSG_vm_get_pm(vm);
- 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);
-}
-
-static int migration_worker_main(int argc, char* argv[])
-{
- xbt_assert(argc == 3);
- const char* vm_name = argv[1];
- const 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);
-
- vm_migrate(vm, dst_pm);
-
- return 0;
-}
-
-static void vm_migrate_async(const_sg_vm_t vm, const_sg_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* 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(XBT_ATTRIB_UNUSED int argc, XBT_ATTRIB_UNUSED char* argv[])
-{
- msg_host_t pm0 = MSG_host_by_name("Fafard");
- msg_host_t pm1 = MSG_host_by_name("Tremblay");
- const_sg_host_t pm2 = MSG_host_by_name("Bourassa");
-
- msg_vm_t vm0 = MSG_vm_create_core(pm0, "VM0");
- MSG_vm_set_ramsize(vm0, 1e9); // 1Gbytes
- MSG_vm_start(vm0);
-
- XBT_INFO("Test: Migrate a VM with %zu Mbytes RAM", MSG_vm_get_ramsize(vm0) / 1000 / 1000);
- vm_migrate(vm0, pm1);
-
- MSG_vm_destroy(vm0);
-
- vm0 = MSG_vm_create_core(pm0, "VM0");
- MSG_vm_set_ramsize(vm0, 1e8); // 100Mbytes
- MSG_vm_start(vm0);
-
- XBT_INFO("Test: Migrate a VM with %zu Mbytes RAM", MSG_vm_get_ramsize(vm0) / 1000 / 1000);
- vm_migrate(vm0, pm1);
-
- MSG_vm_destroy(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
- MSG_vm_set_ramsize(vm1, 1e9); // 1Gbytes
- MSG_vm_start(vm0);
- MSG_vm_start(vm1);
-
- XBT_INFO("Test: Migrate two VMs at once from PM0 to PM1");
- vm_migrate_async(vm0, pm1);
- vm_migrate_async(vm1, pm1);
- MSG_process_sleep(10000);
-
- MSG_vm_destroy(vm0);
- MSG_vm_destroy(vm1);
-
- vm0 = MSG_vm_create_core(pm0, "VM0");
- vm1 = MSG_vm_create_core(pm0, "VM1");
-
- MSG_vm_set_ramsize(vm0, 1e9); // 1Gbytes
- MSG_vm_set_ramsize(vm1, 1e9); // 1Gbytes
- MSG_vm_start(vm0);
- MSG_vm_start(vm1);
-
- XBT_INFO("Test: Migrate two VMs at once to different PMs");
- vm_migrate_async(vm0, pm1);
- vm_migrate_async(vm1, pm2);
- MSG_process_sleep(10000);
-
- MSG_vm_destroy(vm0);
- MSG_vm_destroy(vm1);
-
- return 0;
-}
-
-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;
-
- MSG_process_create_with_arguments(pr_name, master_main, NULL, host, 1, argv);
-}
-
-int main(int argc, char* argv[])
-{
- /* Get the arguments */
- MSG_init(&argc, argv);
- MSG_vm_live_migration_plugin_init();
-
- /* load the platform file */
- MSG_create_environment(argv[1]);
-
- msg_host_t pm0 = MSG_host_by_name("Fafard");
- launch_master(pm0);
-
- int res = MSG_main();
- XBT_INFO("Bye (simulation time %g)", MSG_get_clock());
-
- return !(res == MSG_OK);
-}