Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
isolate VM migration parameters from others
[simgrid.git] / examples / msg / cloud-simple / cloud-simple.c
index 3af0a8c..f576b25 100644 (file)
@@ -1,5 +1,4 @@
-/* Copyright (c) 2007-2015. The SimGrid Team.
- * All rights reserved.                                                     */
+/* Copyright (c) 2007-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. */
@@ -85,17 +84,16 @@ static int communication_rx_fun(int argc, char *argv[])
 static void launch_communication_worker(msg_host_t tx_host, msg_host_t rx_host)
 {
   char *mbox = bprintf("MBOX:%s-%s", MSG_host_get_name(tx_host), MSG_host_get_name(rx_host));
-  char **argv = NULL;
-  
   const char *pr_name_tx =  "comm_tx";
-  argv = xbt_new(char *, 3);
+
+  char** argv = xbt_new(char*, 3);
   argv[0] = xbt_strdup(pr_name_tx);
   argv[1] = xbt_strdup(mbox);
   argv[2] = NULL;
 
   MSG_process_create_with_arguments(pr_name_tx, communication_tx_fun, NULL, tx_host, 2, argv);
 
-  const char *pr_name_rx =  "comm_rx";  
+  const char *pr_name_rx =  "comm_rx";
   argv = xbt_new(char *, 3);
   argv[0] = xbt_strdup(pr_name_rx);
   argv[1] = xbt_strdup(mbox);
@@ -136,7 +134,7 @@ static int master_main(int argc, char *argv[])
   XBT_INFO("### Put a VM on a PM, and put a task to the VM");
   msg_vm_t vm0 = MSG_vm_create_core(pm0, "VM0");
   MSG_vm_start(vm0);
-  launch_computation_worker(vm0);
+  launch_computation_worker((msg_host_t)vm0);
   MSG_process_sleep(2);
   MSG_vm_destroy(vm0);
 
@@ -161,8 +159,8 @@ static int master_main(int argc, char *argv[])
   msg_vm_t vm1 = MSG_vm_create_core(pm0, "VM1");
   MSG_vm_start(vm0);
   MSG_vm_start(vm1);
-  launch_computation_worker(vm0);
-  launch_computation_worker(vm1);
+  launch_computation_worker((msg_host_t)vm0);
+  launch_computation_worker((msg_host_t)vm1);
   MSG_process_sleep(2);
   MSG_vm_destroy(vm0);
   MSG_vm_destroy(vm1);
@@ -172,8 +170,8 @@ static int master_main(int argc, char *argv[])
   vm1 = MSG_vm_create_core(pm1, "VM1");
   MSG_vm_start(vm0);
   MSG_vm_start(vm1);
-  launch_computation_worker(vm0);
-  launch_computation_worker(vm1);
+  launch_computation_worker((msg_host_t)vm0);
+  launch_computation_worker((msg_host_t)vm1);
   MSG_process_sleep(2);
   MSG_vm_destroy(vm0);
   MSG_vm_destroy(vm1);
@@ -192,29 +190,29 @@ static int master_main(int argc, char *argv[])
   XBT_INFO("### Make a connection between PM0 and VM0@PM0");
   vm0 = MSG_vm_create_core(pm0, "VM0");
   MSG_vm_start(vm0);
-  launch_communication_worker(pm0, vm0);
+  launch_communication_worker(pm0, (msg_host_t)vm0);
   MSG_process_sleep(5);
   MSG_vm_destroy(vm0);
 
   XBT_INFO("### Make a connection between PM0 and VM0@PM1");
   vm0 = MSG_vm_create_core(pm1, "VM0");
   MSG_vm_start(vm0);
-  launch_communication_worker(pm0, vm0);
+  launch_communication_worker(pm0, (msg_host_t)vm0);
   MSG_process_sleep(5);
   MSG_vm_destroy(vm0);
 
   XBT_INFO("### Make two connections between PM0 and VM0@PM1");
   vm0 = MSG_vm_create_core(pm1, "VM0");
   MSG_vm_start(vm0);
-  launch_communication_worker(pm0, vm0);
-  launch_communication_worker(pm0, vm0);
+  launch_communication_worker(pm0, (msg_host_t)vm0);
+  launch_communication_worker(pm0, (msg_host_t)vm0);
   MSG_process_sleep(5);
   MSG_vm_destroy(vm0);
 
   XBT_INFO("### Make a connection between PM0 and VM0@PM1, and also make a connection between PM0 and PM1");
   vm0 = MSG_vm_create_core(pm1, "VM0");
   MSG_vm_start(vm0);
-  launch_communication_worker(pm0, vm0);
+  launch_communication_worker(pm0, (msg_host_t)vm0);
   launch_communication_worker(pm0, pm1);
   MSG_process_sleep(5);
   MSG_vm_destroy(vm0);
@@ -224,8 +222,8 @@ static int master_main(int argc, char *argv[])
   vm1 = MSG_vm_create_core(pm1, "VM1");
   MSG_vm_start(vm0);
   MSG_vm_start(vm1);
-  launch_communication_worker(vm0, vm1);
-  launch_communication_worker(vm0, vm1);
+  launch_communication_worker((msg_host_t)vm0, (msg_host_t)vm1);
+  launch_communication_worker((msg_host_t)vm0, (msg_host_t)vm1);
   MSG_process_sleep(5);
   MSG_vm_destroy(vm0);
   MSG_vm_destroy(vm1);
@@ -236,13 +234,10 @@ static int master_main(int argc, char *argv[])
            " network one");
   XBT_INFO("### Relocate VM0 between PM0 and PM1");
   vm0 = MSG_vm_create_core(pm0, "VM0");
-  s_vm_params_t params;
-  memset(&params, 0, sizeof(params));
-  params.ramsize = 1L * 1024 * 1024 * 1024; // 1Gbytes
-  MSG_host_set_params(vm0, &params);
+  MSG_vm_set_ramsize(vm0, 1L * 1024 * 1024 * 1024); // 1GiB
 
   MSG_vm_start(vm0);
-  launch_communication_worker(vm0, pm2);
+  launch_communication_worker((msg_host_t)vm0, pm2);
   MSG_process_sleep(0.01);
   MSG_vm_migrate(vm0, pm1);
   MSG_process_sleep(0.01);
@@ -270,8 +265,10 @@ int main(int argc, char *argv[])
   MSG_init(&argc, argv);
 
   /* load the platform file */
-  xbt_assert(argc == 2);
-  MSG_create_environment(argv[1]);
+  const char* platform = "../../platforms/small_platform.xml";
+  if (argc == 2)
+     platform = argv[1];
+  MSG_create_environment(platform);
 
   msg_host_t pm0 = MSG_host_by_name("Fafard");
   launch_master(pm0);