Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Merge branch 'coverity_scan' of github.com:mquinson/simgrid
[simgrid.git] / src / msg / msg_vm.cpp
index de7f683..cbfb739 100644 (file)
@@ -46,8 +46,7 @@ const char *MSG_vm_get_property_value(msg_vm_t vm, const char *name)
 xbt_dict_t MSG_vm_get_properties(msg_vm_t vm)
 {
   xbt_assert((vm != NULL), "Invalid parameters (vm is NULL)");
-
-  return (simcall_host_get_properties(vm));
+  return vm->properties();
 }
 
 /** \ingroup m_host_management
@@ -165,6 +164,9 @@ int MSG_vm_is_restoring(msg_vm_t vm)
 /** @brief Create a new VM with specified parameters.
  *  @ingroup msg_VMs*
  *  @param pm        Physical machine that will host the VM
+ *  @param name      [TODO]
+ *  @param ncpus     [TODO]
+ *  @param ramsize   [TODO]
  *  @param net_cap   Maximal bandwidth that the VM can consume (in MByte/s)
  *  @param disk_path (unused) Path to the image that boots
  *  @param disksize  (unused) will represent the size of the VM (will be used during migrations)
@@ -195,7 +197,7 @@ msg_vm_t MSG_vm_create(msg_host_t pm, const char *name,
   params.mig_speed = (double)mig_netspeed * 1024 * 1024; // mig_speed
 
   //XBT_INFO("dp rate %f migspeed : %f intensity mem : %d, updatespeed %f, hostspeed %f",params.dp_rate, params.mig_speed, dp_intensity, update_speed, host_speed);
-  simcall_host_set_params(vm, &params);
+  vm->set_parameters(&params);
 
   return vm;
 }
@@ -210,10 +212,11 @@ msg_vm_t MSG_vm_create_core(msg_host_t ind_pm, const char *name)
 {
   /* make sure the VM of the same name does not exit */
   {
-    xbt_dictelm_t ind_host_tmp = xbt_lib_get_elm_or_null(host_lib, name);
-    if (ind_host_tmp && sg_host_simix(ind_host_tmp) != NULL) {
+    simgrid::s4u::Host* ind_host_tmp =
+      (simgrid::s4u::Host*) xbt_dict_get_or_null(host_list, name);
+    if (ind_host_tmp != nullptr && sg_host_simix(ind_host_tmp) != nullptr) {
       XBT_ERROR("host %s already exits", name);
-      return NULL;
+      return nullptr;
     }
   }
 
@@ -251,8 +254,6 @@ void MSG_vm_destroy(msg_vm_t vm)
   /* Then, destroy the VM object */
   simcall_vm_destroy(vm);
 
-  __MSG_host_destroy(vm);
-
   TRACE_msg_vm_end(vm);
 }
 
@@ -293,45 +294,45 @@ void MSG_vm_shutdown(msg_vm_t vm)
  * migration. The names of these mailboxes must not conflict with others. */
 static inline char *get_mig_mbox_src_dst(msg_vm_t vm, msg_host_t src_pm, msg_host_t dst_pm)
 {
-  char *vm_name = sg_host_get_name(vm);
-  char *src_pm_name = sg_host_get_name(src_pm);
-  char *dst_pm_name = sg_host_get_name(dst_pm);
+  const char *vm_name = sg_host_get_name(vm);
+  const char *src_pm_name = sg_host_get_name(src_pm);
+  const char *dst_pm_name = sg_host_get_name(dst_pm);
 
   return bprintf("__mbox_mig_src_dst:%s(%s-%s)", vm_name, src_pm_name, dst_pm_name);
 }
 
 static inline char *get_mig_mbox_ctl(msg_vm_t vm, msg_host_t src_pm, msg_host_t dst_pm)
 {
-  char *vm_name = sg_host_get_name(vm);
-  char *src_pm_name = sg_host_get_name(src_pm);
-  char *dst_pm_name = sg_host_get_name(dst_pm);
+  const char *vm_name = sg_host_get_name(vm);
+  const char *src_pm_name = sg_host_get_name(src_pm);
+  const char *dst_pm_name = sg_host_get_name(dst_pm);
 
   return bprintf("__mbox_mig_ctl:%s(%s-%s)", vm_name, src_pm_name, dst_pm_name);
 }
 
 static inline char *get_mig_process_tx_name(msg_vm_t vm, msg_host_t src_pm, msg_host_t dst_pm)
 {
-  char *vm_name = sg_host_get_name(vm);
-  char *src_pm_name = sg_host_get_name(src_pm);
-  char *dst_pm_name = sg_host_get_name(dst_pm);
+  const char *vm_name = sg_host_get_name(vm);
+  const char *src_pm_name = sg_host_get_name(src_pm);
+  const char *dst_pm_name = sg_host_get_name(dst_pm);
 
   return bprintf("__pr_mig_tx:%s(%s-%s)", vm_name, src_pm_name, dst_pm_name);
 }
 
 static inline char *get_mig_process_rx_name(msg_vm_t vm, msg_host_t src_pm, msg_host_t dst_pm)
 {
-  char *vm_name = sg_host_get_name(vm);
-  char *src_pm_name = sg_host_get_name(src_pm);
-  char *dst_pm_name = sg_host_get_name(dst_pm);
+  const char *vm_name = sg_host_get_name(vm);
+  const char *src_pm_name = sg_host_get_name(src_pm);
+  const char *dst_pm_name = sg_host_get_name(dst_pm);
 
   return bprintf("__pr_mig_rx:%s(%s-%s)", vm_name, src_pm_name, dst_pm_name);
 }
 
 static inline char *get_mig_task_name(msg_vm_t vm, msg_host_t src_pm, msg_host_t dst_pm, int stage)
 {
-  char *vm_name = sg_host_get_name(vm);
-  char *src_pm_name = sg_host_get_name(src_pm);
-  char *dst_pm_name = sg_host_get_name(dst_pm);
+  const char *vm_name = sg_host_get_name(vm);
+  const char *src_pm_name = sg_host_get_name(src_pm);
+  const char *dst_pm_name = sg_host_get_name(dst_pm);
 
   return bprintf("__task_mig_stage%d:%s(%s-%s)", stage, vm_name, src_pm_name, dst_pm_name);
 }
@@ -359,7 +360,7 @@ static int migration_rx_fun(int argc, char *argv[])
   struct migration_session *ms = (migration_session *) MSG_process_get_data(MSG_process_self());
 
   s_vm_params_t params;
-  simcall_host_get_params(ms->vm, &params);
+  ms->vm->get_parameters(&params);
 
   int need_exit = 0;
 
@@ -423,7 +424,9 @@ static int migration_rx_fun(int argc, char *argv[])
    // Now the VM is running on the new host (the migration is completed) (even if the SRC crash)
    msg_host_priv_t priv = sg_host_msg(vm);
    priv->is_migrating = 0;
-   XBT_DEBUG("VM(%s) moved from PM(%s) to PM(%s)", ms->vm->key, ms->src_pm->key, ms->dst_pm->key);
+   XBT_DEBUG("VM(%s) moved from PM(%s) to PM(%s)",
+      sg_host_get_name(ms->vm), sg_host_get_name(ms->src_pm),
+      sg_host_get_name(ms->dst_pm));
    TRACE_msg_vm_change_host(ms->vm, ms->src_pm, ms->dst_pm);
   }
   // Inform the SRC that the migration has been correctly performed
@@ -482,25 +485,6 @@ static void stop_dirty_page_tracking(msg_vm_t vm)
   priv->dp_enabled = 0;
 }
 
-#if 0
-/* It might be natural that we define dp_rate for each task. But, we will also
- * have to care about how each task behavior affects the memory update behavior
- * at the operating system level. It may not be easy to model it with a simple algorithm. */
-double calc_updated_pages(char *key, msg_vm_t vm, dirty_page_t dp, double remaining, double clock)
-{
-    double computed = dp->prev_remaining - remaining;
-    double duration = clock - dp->prev_clock;
-    double updated = dp->task->dp_rate * computed;
-
-    XBT_INFO("%s@%s: computated %f ops (remaining %f -> %f) in %f secs (%f -> %f)",
-        key, sg_host_name(vm), computed, dp->prev_remaining, remaining, duration, dp->prev_clock, clock);
-    XBT_INFO("%s@%s: updated %f bytes, %f Mbytes/s",
-        key, sg_host_name(vm), updated, updated / duration / 1000 / 1000);
-
-    return updated;
-}
-#endif
-
 static double get_computed(char *key, msg_vm_t vm, dirty_page_t dp, double remaining, double clock)
 {
   double computed = dp->prev_remaining - remaining;
@@ -705,7 +689,7 @@ static int migration_tx_fun(int argc, char *argv[])
     (migration_session *) MSG_process_get_data(MSG_process_self());
 
   s_vm_params_t params;
-  simcall_host_get_params(ms->vm, &params);
+  ms->vm->get_parameters(&params);
   const sg_size_t ramsize   = params.ramsize;
   const sg_size_t devsize   = params.devsize;
   const int skip_stage1     = params.skip_stage1;