Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Remove SIMIX_host_get_properties() and SIMIX_host_get_process_list()
[simgrid.git] / src / simix / smx_vm.cpp
index dae28e7..6be0a15 100644 (file)
@@ -9,6 +9,8 @@
 #include "xbt/log.h"
 #include "xbt/dict.h"
 #include "mc/mc.h"
+#include "src/surf/host_interface.hpp"
+#include "src/surf/virtual_machine.hpp"
 
 //If you need to log some stuffs, just uncomment these two lines and uses XBT_DEBUG for instance
 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(simix_vm, simix, "Logging specific to SIMIX (vms)");
@@ -61,7 +63,7 @@ static int __can_be_started(sg_host_t vm)
   }
 
   if (pm_overcommit) {
-    XBT_INFO("%s allows memory overcommit.", pm->key);
+    XBT_INFO("%s allows memory overcommit.", sg_host_get_name(pm));
     return 1;
   }
 
@@ -78,7 +80,8 @@ static int __can_be_started(sg_host_t vm)
 
   if (vm_ramsize > pm_ramsize - total_ramsize_of_vms) {
     XBT_WARN("cannnot start %s@%s due to memory shortage: vm_ramsize %ld, free %ld, pm_ramsize %ld (bytes).",
-        vm->key, pm->key, vm_ramsize, pm_ramsize - total_ramsize_of_vms, pm_ramsize);
+        sg_host_get_name(vm), sg_host_get_name(pm),
+        vm_ramsize, pm_ramsize - total_ramsize_of_vms, pm_ramsize);
     xbt_dynar_free(&dyn_vms);
     return 0;
   }
@@ -90,16 +93,19 @@ static int __can_be_started(sg_host_t vm)
 void SIMIX_vm_start(sg_host_t ind_vm)
 {
   if (__can_be_started(ind_vm))
-    surf_host_set_state(surf_host_resource_priv(ind_vm),
-                            (e_surf_resource_state_t) SURF_VM_STATE_RUNNING);
+    static_cast<simgrid::surf::VirtualMachine*>(
+      ind_vm->extension<simgrid::surf::Host>()
+    )->setState(SURF_VM_STATE_RUNNING);
   else
     THROWF(vm_error, 0, "The VM %s cannot be started", SIMIX_host_get_name(ind_vm));
 }
 
 
-int SIMIX_vm_get_state(sg_host_t ind_vm)
+e_surf_vm_state_t SIMIX_vm_get_state(sg_host_t ind_vm)
 {
-  return surf_host_get_state(surf_host_resource_priv(ind_vm));
+  return static_cast<simgrid::surf::VirtualMachine*>(
+    ind_vm->extension<simgrid::surf::Host>()
+  )->getState();
 }
 
 /**
@@ -342,8 +348,9 @@ void SIMIX_vm_shutdown(sg_host_t ind_vm, smx_process_t issuer)
   }
 
   /* FIXME: we may have to do something at the surf layer, e.g., vcpu action */
-  surf_host_set_state(surf_host_resource_priv(ind_vm),
-          (e_surf_resource_state_t) SURF_VM_STATE_CREATED);
+  static_cast<simgrid::surf::VirtualMachine*>(
+    ind_vm->extension<simgrid::surf::Host>()
+  )->setState(SURF_VM_STATE_CREATED);
 }
 
 void simcall_HANDLER_vm_shutdown(smx_simcall_t simcall, sg_host_t ind_vm)