Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
rename MSG_host_(get/set)_params into MSG_vm_(get/set)_params
[simgrid.git] / src / msg / msg_vm.cpp
index 351a03c..0b985ba 100644 (file)
@@ -9,6 +9,11 @@
  * 2. use parallel tasks to simulate CPU overhead and remove the experimental code generating micro computation tasks
  */
 
+#include <xbt/ex.hpp>
+
+#include <simgrid/s4u/VirtualMachine.hpp>
+#include <simgrid/s4u/host.hpp>
+
 #include "msg_private.h"
 #include "xbt/sysdep.h"
 #include "xbt/log.h"
@@ -54,6 +59,27 @@ void MSG_vm_set_property_value(msg_vm_t vm, const char *name, void *value, void_
 {
   xbt_dict_set(MSG_host_get_properties(vm), name, value, free_ctn);
 }
+/** \ingroup m_vm_management
+ * \brief Set the parameters of a given host
+ *
+ * \param vm a vm
+ * \param params a parameter object
+ */
+void MSG_vm_set_params(msg_vm_t vm, vm_params_t params)
+{
+  static_cast<simgrid::s4u::VirtualMachine*>(vm)->setParameters(params);
+}
+
+/** \ingroup m_vm_management
+ * \brief Get the parameters of a given host
+ *
+ * \param host a host
+ * \param params a prameter object
+ */
+void MSG_vm_get_params(msg_vm_t vm, vm_params_t params)
+{
+  static_cast<simgrid::s4u::VirtualMachine*>(vm)->parameters(params);
+}
 
 /** \ingroup msg_vm_management
  * \brief Finds a msg_vm_t using its name.
@@ -178,7 +204,7 @@ msg_vm_t MSG_vm_create(msg_host_t pm, const char *name, int ncpus, int ramsize,
 
   //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);
-  vm->setParameters(&params);
+  static_cast<simgrid::s4u::VirtualMachine*>(vm)->setParameters(&params);
 
   return vm;
 }
@@ -192,7 +218,7 @@ 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 */
   {
-    simgrid::s4u::Host* ind_host_tmp = (simgrid::s4u::Host*) xbt_dict_get_or_null(host_list, name);
+    simgrid::s4u::Host* ind_host_tmp = sg_host_by_name(name);
     if (ind_host_tmp != nullptr && sg_host_simix(ind_host_tmp) != nullptr) {
       XBT_ERROR("host %s already exits", name);
       return nullptr;
@@ -201,7 +227,7 @@ msg_vm_t MSG_vm_create_core(msg_host_t ind_pm, const char *name)
 
   /* Note: ind_vm and vm_workstation point to the same elm object. */
   /* Ask the SIMIX layer to create the surf vm resource */
-  sg_host_t ind_vm_workstation =  (sg_host_t) simcall_vm_create(name, ind_pm);
+  sg_host_t ind_vm_workstation = simcall_vm_create(name, ind_pm);
 
   msg_vm_t ind_vm = (msg_vm_t) __MSG_host_create(ind_vm_workstation);
 
@@ -328,7 +354,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;
-  ms->vm->parameters(&params);
+  static_cast<simgrid::s4u::VirtualMachine*>(ms->vm)->parameters(&params);
 
   int need_exit = 0;
 
@@ -365,12 +391,9 @@ static int migration_rx_fun(int argc, char *argv[])
    msg_vm_t vm = ms->vm;
    msg_host_t src_pm = ms->src_pm;
    msg_host_t dst_pm = ms-> dst_pm;
-   msg_host_priv_t priv = sg_host_msg(vm);
 
 // TODO: we have an issue, if the DST node is turning off during the three next calls, then the VM is in an inconsistent
 //       state. I should check with Takahiro in order to make this portion of code atomic
-//  /* deinstall the current affinity setting for the CPU */
-//  simcall_vm_set_affinity(vm, src_pm, 0);
 //
 //  /* Update the vm location */
 //  simcall_vm_migrate(vm, dst_pm);
@@ -380,15 +403,6 @@ static int migration_rx_fun(int argc, char *argv[])
 //
    simcall_vm_migratefrom_resumeto(vm, src_pm, dst_pm); 
 
-  /* install the affinity setting of the VM on the destination pm */
-  {
-
-    unsigned long affinity_mask =
-       (unsigned long)(uintptr_t) xbt_dict_get_or_null_ext(priv->affinity_mask_db, (char *)dst_pm, sizeof(msg_host_t));
-    simcall_vm_set_affinity(vm, dst_pm, affinity_mask);
-    XBT_DEBUG("set affinity(0x%04lx@%s) for %s", affinity_mask, MSG_host_get_name(dst_pm), MSG_host_get_name(vm));
-  }
-
   {
    // 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);
@@ -644,7 +658,7 @@ static int migration_tx_fun(int argc, char *argv[])
   migration_session *ms = (migration_session *) MSG_process_get_data(MSG_process_self());
 
   s_vm_params_t params;
-  ms->vm->parameters(&params);
+  static_cast<simgrid::s4u::VirtualMachine*>(ms->vm)->parameters(&params);
   const sg_size_t ramsize   = params.ramsize;
   const sg_size_t devsize   = params.devsize;
   const int skip_stage1     = params.skip_stage1;
@@ -665,7 +679,7 @@ static int migration_tx_fun(int argc, char *argv[])
   if (ramsize == 0)
     XBT_WARN("migrate a VM, but ramsize is zero");
 
-  if (max_downtime == 0) {
+  if (max_downtime <= 0) {
     XBT_WARN("use the default max_downtime value 30ms");
     max_downtime = 0.03;
   }
@@ -1030,26 +1044,3 @@ void MSG_vm_set_bound(msg_vm_t vm, double bound)
 {
   simcall_vm_set_bound(vm, bound);
 }
-
-/** @brief Set the CPU affinity of a given VM.
- *  @ingroup msg_VMs
- *
- * This function changes the CPU affinity of a given VM. Usage is the same as
- * MSG_task_set_affinity(). See the MSG_task_set_affinity() for details.
- */
-void MSG_vm_set_affinity(msg_vm_t vm, msg_host_t pm, unsigned long mask)
-{
-  msg_host_priv_t priv = sg_host_msg(vm);
-
-  if (mask == 0)
-    xbt_dict_remove_ext(priv->affinity_mask_db, (char *) pm, sizeof(pm));
-  else
-    xbt_dict_set_ext(priv->affinity_mask_db, (char *) pm, sizeof(pm), (void *)(uintptr_t) mask, nullptr);
-
-  msg_host_t pm_now = MSG_vm_get_pm(vm);
-  if (pm_now == pm) {
-    XBT_DEBUG("set affinity(0x%04lx@%s) for %s", mask, MSG_host_get_name(pm), MSG_host_get_name(vm));
-    simcall_vm_set_affinity(vm, pm, mask);
-  } else
-    XBT_DEBUG("set affinity(0x%04lx@%s) for %s (not active now)", mask, MSG_host_get_name(pm), MSG_host_get_name(vm));
-}