Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Add a MSG_vm_destroy function to free a virtual machine
authorSamuel Lepetit <samuel.lepetit@inria.fr>
Thu, 14 Jun 2012 16:08:43 +0000 (18:08 +0200)
committerSamuel Lepetit <samuel.lepetit@inria.fr>
Thu, 14 Jun 2012 16:08:43 +0000 (18:08 +0200)
examples/msg/cloud/masterslave_virtual_machines.c
include/msg/msg.h
src/msg/msg_vm.c

index 7db2605..ed1ac27 100644 (file)
@@ -124,6 +124,7 @@ int master(int argc, char *argv[]) {
   for (i=0;i<xbt_dynar_length(vms);i++) {
     msg_vm_t vm = xbt_dynar_get_as(vms,i,msg_vm_t);
     MSG_vm_shutdown(vm);
+    MSG_vm_destroy(vm);
   }
 
   XBT_INFO("Goodbye now!");
@@ -158,6 +159,7 @@ int slave_fun(int argc, char *argv[])
     MSG_task_destroy(task);
     task = NULL;
   }
+
   free(mailbox_name);
   return 0;
 }                               /* end_of_slave */
index 4d92827..0e4838d 100644 (file)
@@ -314,6 +314,8 @@ XBT_PUBLIC(void) MSG_vm_resume(msg_vm_t vm);  // Simulate the fact of reading th
 
 XBT_PUBLIC(void) MSG_vm_shutdown(msg_vm_t vm); // killall
 
+XBT_PUBLIC(void) MSG_vm_destroy(msg_vm_t vm);
+
 XBT_PUBLIC(xbt_dynar_t) MSG_vms_as_dynar(void);
 
 /*
index 948c8de..4eb77b0 100644 (file)
@@ -158,3 +158,18 @@ void MSG_vm_shutdown(msg_vm_t vm) {
        MSG_process_kill(process);
   }
 }
+
+/** @brief Destroy a msg_vm_t.
+ *  @ingroup msg_VMs
+ */
+void MSG_vm_destroy(msg_vm_t vm) {
+       unsigned int cpt;
+       m_process_t process;
+       xbt_dynar_foreach(vm->processes,cpt,process) {
+               //FIXME: Slow ?
+               simdata_process_t simdata = simcall_process_get_data(process);
+               simdata->vm = NULL;
+       }
+       xbt_dynar_free(&vm->processes);
+       xbt_free(vm);
+}