XBT_PUBLIC(void *) xbt_dict_get(xbt_dict_t dict, const char *key);
XBT_PUBLIC(void *) xbt_dict_get_or_null(xbt_dict_t dict, const char *key);
XBT_PUBLIC(char *) xbt_dict_get_key(xbt_dict_t dict, const void *data);
+XBT_PUBLIC(char *) xbt_dict_get_elm_key(xbt_dictelm_t elem);
XBT_PUBLIC(xbt_dictelm_t) xbt_dict_get_elm(xbt_dict_t dict, const char *key);
XBT_PUBLIC(xbt_dictelm_t) xbt_dict_get_elm_or_null(xbt_dict_t dict, const char *key);
static inline void *surf_workstation_resource_priv(const void *host){
return (void*)xbt_lib_get_level((xbt_dictelm_t)host, SURF_WKS_LEVEL);
}
+static inline void *surf_routing_resource_priv(const void *host){
+ return (void*)xbt_lib_get_level((xbt_dictelm_t)host, ROUTING_HOST_LEVEL);
+}
static inline void *surf_storage_resource_priv(const void *storage){
return (void*)xbt_lib_get_level((xbt_dictelm_t)storage, SURF_STORAGE_LEVEL);
}
}
}
}
+ /*xbt_dynar_t vms = surf_workstation_get_vms(h);
+ unsigned int cpt;
+ smx_host_t vm;
+ xbt_dynar_foreach(vms, cpt, vm) {
+ SIMIX_vm_shutdown(vm, issuer);
+ SIMIX_vm_destroy(vm);
+ }
+ xbt_dynar_free(&vms);*/
}
/**
return static_cast<WorkstationPtr>(surf_workstation_resource_priv(resource));
}
+static RoutingEdgePtr get_casted_routing(surf_resource_t resource){
+ return static_cast<RoutingEdgePtr>(surf_routing_resource_priv(resource));
+}
+
static WorkstationVMPtr get_casted_vm_workstation(surf_resource_t resource){
return static_cast<WorkstationVMPtr>(surf_workstation_resource_priv(resource));
}
}
xbt_dynar_t surf_workstation_get_vms(surf_resource_t resource){
- return get_casted_workstation(resource)->getVms();
+ xbt_dynar_t vms = get_casted_workstation(resource)->getVms();
+ xbt_dynar_t vms_ = xbt_dynar_new(sizeof(smx_host_t), NULL);
+ unsigned int cpt;
+ WorkstationVMPtr vm;
+ xbt_dynar_foreach(vms, cpt, vm) {
+ smx_host_t vm_ = xbt_lib_get_elm_or_null(host_lib, vm->getName());
+ xbt_dynar_push(vms_, &vm_);
+ }
+ xbt_dynar_free(&vms);
+ return vms_;
}
void surf_workstation_get_params(surf_resource_t resource, ws_params_t params){
}
void surf_vm_workstation_destroy(surf_resource_t resource){
- delete get_casted_vm_workstation(resource);
+ /* ind_phys_workstation equals to smx_host_t */
+ //surf_resource_t ind_vm_workstation = xbt_lib_get_elm_or_null(host_lib, getName());
+
+ /* Before clearing the entries in host_lib, we have to pick up resources. */
+ CpuPtr cpu = get_casted_cpu(resource);
+ WorkstationVMPtr vm = get_casted_vm_workstation(resource);
+ RoutingEdgePtr routing = get_casted_routing(resource);
+ char* name = xbt_dict_get_elm_key(resource);
+ /* We deregister objects from host_lib, without invoking the freeing callback
+ * of each level.
+ *
+ * Do not call xbt_lib_remove() here. It deletes all levels of the key,
+ * including MSG_HOST_LEVEL and others. We should unregister only what we know.
+ */
+ xbt_lib_unset(host_lib, name, SURF_CPU_LEVEL, 0);
+ xbt_lib_unset(host_lib, name, ROUTING_HOST_LEVEL, 0);
+ xbt_lib_unset(host_lib, name, SURF_WKS_LEVEL, 0);
+
+ /* TODO: comment out when VM storage is implemented. */
+ // xbt_lib_unset(host_lib, name, SURF_STORAGE_LEVEL, 0);
+
+ delete cpu;
+ delete vm;
+ delete routing;
}
void surf_vm_workstation_suspend(surf_resource_t resource){
* from the VM name, we have to make sure that the system does not call the
* free callback for the network resource object. The network resource object
* is still used by the physical machine. */
- p_netElm = static_cast<RoutingEdgePtr>(xbt_lib_get_or_null(host_lib, sub_ws->getName(), ROUTING_HOST_LEVEL));
+ p_netElm = new RoutingEdgeWrapper(static_cast<RoutingEdgePtr>(xbt_lib_get_or_null(host_lib, sub_ws->getName(), ROUTING_HOST_LEVEL)));
xbt_lib_set(host_lib, name, ROUTING_HOST_LEVEL, p_netElm);
p_subWs = sub_ws;
*/
WorkstationVMHL13::~WorkstationVMHL13()
{
- /* ind_phys_workstation equals to smx_host_t */
- surf_resource_t ind_vm_workstation = xbt_lib_get_elm_or_null(host_lib, getName());
-
- /* Before clearing the entries in host_lib, we have to pick up resources. */
- CpuCas01Ptr cpu = static_cast<CpuCas01Ptr>(surf_cpu_resource_priv(ind_vm_workstation));
-
- /* We deregister objects from host_lib, without invoking the freeing callback
- * of each level.
- *
- * Do not call xbt_lib_remove() here. It deletes all levels of the key,
- * including MSG_HOST_LEVEL and others. We should unregister only what we know.
- */
- xbt_lib_unset(host_lib, getName(), SURF_CPU_LEVEL, 0);
- xbt_lib_unset(host_lib, getName(), ROUTING_HOST_LEVEL, 0);
- xbt_lib_unset(host_lib, getName(), SURF_WKS_LEVEL, 0);
-
- /* TODO: comment out when VM storage is implemented. */
- // xbt_lib_unset(host_lib, name, SURF_STORAGE_LEVEL, 0);
-
-
/* Free the cpu_action of the VM. */
int ret = p_action->unref();
xbt_assert(ret == 1, "Bug: some resource still remains");
-
- /* Free the cpu resource of the VM. If using power_trace, we will have to */
- delete cpu;
-
- /* Free the network resource of the VM. */
- // Nothing has to be done, because net_elmts is just a pointer on the physical one
-
- /* Free the storage resource of the VM. */
- // Not relevant yet
-
- /* Free the workstation resource of the VM. */
}
void WorkstationVMHL13::updateState(tmgr_trace_event_t /*event_type*/, double /*value*/, double /*date*/) {
/* update net_elm with that of the destination physical host */
RoutingEdgePtr old_net_elm = p_netElm;
- RoutingEdgePtr new_net_elm = static_cast<RoutingEdgePtr>(xbt_lib_get_or_null(host_lib, pm_name_dst, ROUTING_HOST_LEVEL));
+ RoutingEdgePtr new_net_elm = new RoutingEdgeWrapper(static_cast<RoutingEdgePtr>(xbt_lib_get_or_null(host_lib, pm_name_dst, ROUTING_HOST_LEVEL)));
xbt_assert(new_net_elm);
/* Unregister the current net_elm from host_lib. Do not call the free callback. */
XBT_DEBUG("migrate VM(%s): change net_elm (%p to %p)", vm_name, old_net_elm, new_net_elm);
XBT_DEBUG("migrate VM(%s): change PM (%s to %s)", vm_name, pm_name_src, pm_name_dst);
+ delete old_net_elm;
}
void WorkstationVMHL13::setBound(double bound){
xbt_dynar_t Workstation::getVms()
{
- xbt_dynar_t dyn = xbt_dynar_new(sizeof(smx_host_t), NULL);
+ xbt_dynar_t dyn = xbt_dynar_new(sizeof(WorkstationVMPtr), NULL);
/* iterate for all virtual machines */
for (WorkstationVMModel::vm_list_t::iterator iter =
iter != WorkstationVMModel::ws_vms.end(); ++iter) {
WorkstationVMPtr ws_vm = &*iter;
- if (this == ws_vm-> p_subWs)
- xbt_dynar_push(dyn, &ws_vm->p_subWs);
+ if (this == ws_vm->p_subWs)
+ xbt_dynar_push(dyn, &ws_vm);
}
return dyn;
return NULL;
}
+/**
+ * @brief retrieve the key associated to that xbt_dictelm_t.
+ *
+ */
+char *xbt_dict_get_elm_key(xbt_dictelm_t elm)
+{
+ return elm->key;
+}
+
/**
* \brief Retrieve data from the dict (null-terminated key)
*
XBT_INLINE void *xbt_dict_get_or_null(xbt_dict_t dict, const char *key)
{
xbt_dictelm_t current = xbt_dict_get_elm_or_null(dict, key);
-
+
if (current == NULL)
return NULL;
)
set(txt_files
${txt_files}
- ${CMAKE_CURRENT_SOURCE_DIR}/README
PARENT_SCOPE
)
argvF = xbt_new(char*, 2);
argvF[0] = xbt_strdup("process_daemon");
MSG_process_create_with_arguments("process_daemon", process_daemon, NULL, jupiter, 1, argvF);
+ MSG_process_sleep(3);
XBT_INFO(" Turn off Jupiter");
MSG_host_off(jupiter);
MSG_process_sleep(10);
test =6;
if (xbt_dynar_member(tests, &test)){
- /*XBT_INFO("Test 5: Turn on Jupiter, assign a VM on Jupiter, launch a process inside the VM, and turn off the node");
+ XBT_INFO("Test 6: Turn on Jupiter, assign a VM on Jupiter, launch a process inside the VM, and turn off the node");
// Create VM0
int dpRate = 70;
msg_vm_t vm0;
-MSG_vm_create (msg_host_t ind_pm, const char *name, int ncpus, int ramsize, int net_cap, char *disk_path, int disksize, int mig_netspeed, int dp_intensity)
- vm0 = MSG_vm_create_core(jupiter, "vm0");
- params.ramsize = 1L * 1000 * 1000 * 1000; // 1Gbytes
- MSG_host_set_params(vm0, ¶ms);
- MSG_vm_start(vm0);
- XVM vm0 = null;
- vm0 = new XVM(
- host1,
- "vm0",
- 1, // Nb of vcpu
- 2048, // Ramsize,
- 125, // Net Bandwidth
- null, //VM disk image
- -1, //size of disk image,
- 125, // Net bandwidth,
- dpRate // Memory intensity
- );
- vm0.start();
- vm0.setLoad(90);
-
- host1.off();
- Msg.info("Test 5 is also weird: when the node host1 is turned off once again, the VM and its daemon are not killed." +
- " However, the issue regarding the shutdown of hosted VMs can be seen a feature not a bug ;)\n");*/
+ msg_process_t daemon;
+
+ vm0 = MSG_vm_create (jupiter, "vm0", 1, 2048, 125, NULL, -1, 125, dpRate);
+ MSG_vm_start(vm0);
+
+ argvF = xbt_new(char*, 2);
+ argvF[0] = xbt_strdup("process_daemon");
+ daemon = MSG_process_create_with_arguments("process_daemon", process_daemon, NULL, vm0, 1, argvF);
+
+ argvF = xbt_new(char*, 2);
+ argvF[0] = xbt_strdup("process_daemonJUPI");
+ MSG_process_create_with_arguments("process_daemonJUPI", process_daemon, NULL, jupiter, 1, argvF);
+
+ MSG_process_suspend(daemon);
+ MSG_vm_set_bound(vm0, 90);
+ MSG_process_resume(daemon);
+
+ MSG_process_sleep(10);
+
+ XBT_INFO(" Turn Jupiter off");
+ MSG_host_off(jupiter);
+ XBT_INFO(" Shutdown vm0");
+ MSG_vm_shutdown(vm0);
+ XBT_INFO(" Destroy vm0");
+ MSG_vm_destroy(vm0);
+ XBT_INFO("Test 6 is also weird: when the node Jupiter is turned off once again, the VM and its daemon are not killed. However, the issue regarding the shutdown of hosted VMs can be seen a feature not a bug ;)");
}
test = 7;
int process_daemon(int argc, char *argv[])
{
msg_task_t task = NULL;
+ XBT_INFO(" Start daemon on %s (%f)", MSG_host_get_name(MSG_host_self()), MSG_get_host_speed(MSG_host_self()));
for(;;){
- task = MSG_task_create("deamon", 100*MSG_get_host_speed(MSG_host_self()), 0, NULL);
+ task = MSG_task_create("deamon", MSG_get_host_speed(MSG_host_self()), 0, NULL);
XBT_INFO(" Execute deamon");
+ MSG_task_execute(task);
MSG_task_destroy(task);
}
- MSG_task_execute(task);
XBT_INFO(" Deamon done. See you!");
return 0;
}
$ ./host_on_off_processes ${srcdir:=.}/../../../examples/platforms/small_platform.xml ${srcdir:=.}/host_on_off_processes_d.xml 1 --log=no_loc --log=msg.thresh:error --log=surf_maxmin.thresh:error
> [Tremblay:test_launcher:(1) 0.000000] [msg_test/INFO] Test 1:
> [Tremblay:test_launcher:(1) 0.000000] [msg_test/INFO] Create a process on Jupiter
+> [Jupiter:process_daemon:(2) 0.000000] [msg_test/INFO] Start daemon on Jupiter (76296000.000000)
> [Jupiter:process_daemon:(2) 0.000000] [msg_test/INFO] Execute deamon
-> [Tremblay:test_launcher:(1) 0.000000] [msg_test/INFO] Turn off Jupiter
-> [Tremblay:test_launcher:(1) 10.000000] [msg_test/INFO] Test 1 seems ok, cool !(number of Process : 1, it should be 1 (i.e. the Test one))
-> [Tremblay:test_launcher:(1) 10.000000] [msg_test/INFO] Test done. See you!
-> [10.000000] [msg_test/INFO] Simulation time 10
+> [Jupiter:process_daemon:(2) 1.000000] [msg_test/INFO] Execute deamon
+> [Jupiter:process_daemon:(2) 2.000000] [msg_test/INFO] Execute deamon
+> [Tremblay:test_launcher:(1) 3.000000] [msg_test/INFO] Turn off Jupiter
+> [Tremblay:test_launcher:(1) 13.000000] [msg_test/INFO] Test 1 seems ok, cool !(number of Process : 1, it should be 1 (i.e. the Test one))
+> [Tremblay:test_launcher:(1) 13.000000] [msg_test/INFO] Test done. See you!
+> [13.000000] [msg_test/INFO] Simulation time 13
$ ./host_on_off_processes ${srcdir:=.}/../../../examples/platforms/small_platform.xml ${srcdir:=.}/host_on_off_processes_d.xml 2 --log=no_loc --log=msg.thresh:error --log=surf_maxmin.thresh:error
> [Tremblay:test_launcher:(1) 0.000000] [msg_test/INFO] Test 2:
> [Tremblay:test_launcher:(1) 20.000000] [msg_test/INFO] Test done. See you!
> [Tremblay:commTX:(3) 40.000000] [msg_test/INFO] TX done
> [40.000000] [msg_test/INFO] Simulation time 40
+
+$ ./host_on_off_processes ${srcdir:=.}/../../../examples/platforms/small_platform.xml ${srcdir:=.}/host_on_off_processes_d.xml 6 --log=no_loc --log=msg.thresh:error --log=surf_maxmin.thresh:error
+> [Tremblay:test_launcher:(1) 0.000000] [msg_test/INFO] Test 6: Turn on Jupiter, assign a VM on Jupiter, launch a process inside the VM, and turn off the node
+> [0.000000] [surf_vm_workstation/INFO] Create VM(vm0)@PM(Jupiter) with 0 mounted disks
+> [vm0:process_daemon:(2) 0.000000] [msg_test/INFO] Start daemon on vm0 (76296000.000000)
+> [vm0:process_daemon:(2) 0.000000] [msg_test/INFO] Execute deamon
+> [Jupiter:process_daemonJUPI:(3) 0.000000] [msg_test/INFO] Start daemon on Jupiter (76296000.000000)
+> [Jupiter:process_daemonJUPI:(3) 0.000000] [msg_test/INFO] Execute deamon
+> [Jupiter:process_daemonJUPI:(3) 1.000001] [msg_test/INFO] Execute deamon
+> [Jupiter:process_daemonJUPI:(3) 2.000002] [msg_test/INFO] Execute deamon
+> [Jupiter:process_daemonJUPI:(3) 3.000004] [msg_test/INFO] Execute deamon
+> [Jupiter:process_daemonJUPI:(3) 4.000005] [msg_test/INFO] Execute deamon
+> [Jupiter:process_daemonJUPI:(3) 5.000006] [msg_test/INFO] Execute deamon
+> [Jupiter:process_daemonJUPI:(3) 6.000007] [msg_test/INFO] Execute deamon
+> [Jupiter:process_daemonJUPI:(3) 7.000008] [msg_test/INFO] Execute deamon
+> [Jupiter:process_daemonJUPI:(3) 8.000009] [msg_test/INFO] Execute deamon
+> [Jupiter:process_daemonJUPI:(3) 9.000011] [msg_test/INFO] Execute deamon
+> [Tremblay:test_launcher:(1) 10.000000] [msg_test/INFO] Turn Jupiter off
+> [Tremblay:test_launcher:(1) 10.000000] [msg_test/INFO] Shutdown vm0
+> [Tremblay:test_launcher:(1) 10.000000] [msg_test/INFO] Destroy vm0
+> [Tremblay:test_launcher:(1) 10.000000] [msg_test/INFO] Test 6 is also weird: when the node Jupiter is turned off once again, the VM and its daemon are not killed. However, the issue regarding the shutdown of hosted VMs can be seen a feature not a bug ;)
+> [Tremblay:test_launcher:(1) 10.000000] [msg_test/INFO] Test done. See you!
+> [10.000000] [msg_test/INFO] Simulation time 10