From 894300bd1f239a44c84e2ba084b009bd532f9d60 Mon Sep 17 00:00:00 2001 From: Takahiro Hirofuchi Date: Thu, 28 Feb 2013 12:24:44 +0100 Subject: [PATCH] Fix problems so that the VM example works --- src/msg/msg_vm.c | 10 ++++++++-- src/simix/smx_vm.c | 11 ++++++++--- src/surf/vm_workstation.c | 2 +- src/surf/workstation_private.h | 1 + 4 files changed, 18 insertions(+), 6 deletions(-) diff --git a/src/msg/msg_vm.c b/src/msg/msg_vm.c index 45c9bf843d..33ece79472 100644 --- a/src/msg/msg_vm.c +++ b/src/msg/msg_vm.c @@ -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); diff --git a/src/simix/smx_vm.c b/src/simix/smx_vm.c index d68acb2c00..9eac836efd 100644 --- a/src/simix/smx_vm.c +++ b/src/simix/smx_vm.c @@ -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); } diff --git a/src/surf/vm_workstation.c b/src/surf/vm_workstation.c index 0509432348..571caa14b6 100644 --- a/src/surf/vm_workstation.c +++ b/src/surf/vm_workstation.c @@ -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; diff --git a/src/surf/workstation_private.h b/src/surf/workstation_private.h index 5b63d3f8d4..7c8a7500dc 100644 --- a/src/surf/workstation_private.h +++ b/src/surf/workstation_private.h @@ -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); -- 2.20.1