Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Fix problems so that the VM example works
authorTakahiro Hirofuchi <t.hirofuchi+sg@aist.go.jp>
Thu, 28 Feb 2013 11:24:44 +0000 (12:24 +0100)
committerTakahiro Hirofuchi <t.hirofuchi+sg@aist.go.jp>
Thu, 28 Feb 2013 11:24:44 +0000 (12:24 +0100)
src/msg/msg_vm.c
src/simix/smx_vm.c
src/surf/vm_workstation.c
src/surf/workstation_private.h

index 45c9bf8..33ece79 100644 (file)
@@ -366,8 +366,14 @@ void MSG_vm_restore(msg_vm_t vm)
  */
 void MSG_vm_destroy(msg_vm_t vm)
 {
-  /* First, terminate all processes on the VM */
-  simcall_vm_shutdown(vm);
+  /* First, terminate all processes on the VM if necessary */
+  if (MSG_vm_is_running(vm))
+      simcall_vm_shutdown(vm);
+
+  if (!MSG_vm_is_created(vm)) {
+    XBT_CRITICAL("shutdown the given VM before destroying it");
+    DIE_IMPOSSIBLE;
+  }
 
   /* Then, destroy the VM object */
   simcall_vm_destroy(vm);
index d68acb2..9eac836 100644 (file)
@@ -34,7 +34,7 @@ smx_host_t SIMIX_vm_create(const char *name, smx_host_t ind_phys_host)
       xbt_swag_new(xbt_swag_offset(proc, host_proc_hookup));
 
   /* Update global variables */
-  xbt_lib_set(host_lib,name,SIMIX_HOST_LEVEL,smx_host);
+  xbt_lib_set(host_lib, name, SIMIX_HOST_LEVEL, smx_host);
 
   /* Create surf associated resource */
   // TODO change phys_host into the right workstation surf model
@@ -91,11 +91,13 @@ void SIMIX_vm_start(smx_host_t ind_vm)
 void SIMIX_pre_vm_start(smx_simcall_t simcall, smx_host_t ind_vm)
 {
   SIMIX_vm_start(ind_vm);
+  SIMIX_simcall_answer(simcall);
 }
 
 /* ***** set/get state of a VM ***** */
 void SIMIX_vm_set_state(smx_host_t ind_vm, int state)
 {
+  /* jump to vm_ws_set_state */
   surf_vm_workstation_model->extension.vm_workstation.set_state(ind_vm, state);
 }
 
@@ -134,6 +136,7 @@ void SIMIX_vm_migrate(smx_host_t ind_vm, smx_host_t ind_dst_pm)
 void SIMIX_pre_vm_migrate(smx_simcall_t simcall, smx_host_t ind_vm, smx_host_t ind_dst_pm)
 {
   SIMIX_vm_migrate(ind_vm, ind_dst_pm);
+  SIMIX_simcall_answer(simcall);
 }
 
 
@@ -352,6 +355,8 @@ void SIMIX_vm_destroy(smx_host_t ind_vm)
   surf_vm_workstation_model->extension.vm_workstation.destroy(ind_vm);
 }
 
-void SIMIX_pre_vm_destroy(smx_simcall_t simcall, smx_host_t ind_vm){
-   SIMIX_vm_destroy(ind_vm);
+void SIMIX_pre_vm_destroy(smx_simcall_t simcall, smx_host_t ind_vm)
+{
+  SIMIX_vm_destroy(ind_vm);
+  SIMIX_simcall_answer(simcall);
 }
index 0509432..571caa1 100644 (file)
@@ -420,7 +420,7 @@ static void surf_vm_workstation_model_init_internal(void)
   model->name = "Virtual Workstation";
   model->type = SURF_MODEL_TYPE_VM_WORKSTATION;
 
-  // model->action_unref     = ws_action_unref;
+  model->action_unref     = ws_action_unref;
   model->action_cancel    = vm_ws_action_cancel;
   // model->action_state_set = ws_action_state_set;
 
index 5b63d3f..7c8a750 100644 (file)
@@ -12,6 +12,7 @@ typedef struct workstation_CLM03 {
   xbt_dynar_t storage;
 } s_workstation_CLM03_t, *workstation_CLM03_t;
 
+int ws_action_unref(surf_action_t action);
 
 int ws_resource_used(void *resource_id);
 double ws_share_resources(surf_model_t workstation_model, double now);