Palacios Public Git Repository

To checkout Palacios execute

  git clone http://v3vee.org/palacios/palacios.web/palacios.git
This will give you the master branch. You probably want the devel branch or one of the release branches. To switch to the devel branch, simply execute
  cd palacios
  git checkout --track -b devel origin/devel
The other branches are similar.


Special-cased handling of zero-byte mallocs since Linux does this insanely Also inclu...
[palacios.git] / linux_module / iface-file.c
index 46d4a28..da5aabb 100644 (file)
@@ -237,7 +237,7 @@ static void * palacios_file_open(const char * path, int mode, void * private_dat
     strncpy(pfile->path, path, strlen(path));
     pfile->guest = guest;
     
-    spin_lock_init(&(pfile->lock));
+    palacios_spinlock_init(&(pfile->lock));
 
     if (guest == NULL) {
        list_add(&(pfile->file_node), &(global_files));
@@ -342,8 +342,14 @@ static int file_init( void ) {
 
 
 static int file_deinit( void ) {
-    if (!list_empty(&(global_files))) {
-       ERROR("Error removing module with open files\n");
+    struct palacios_file * pfile = NULL;
+    struct palacios_file * tmp = NULL;
+    
+    list_for_each_entry_safe(pfile, tmp, &(global_files), file_node) { 
+        filp_close(pfile->filp, NULL);
+        list_del(&(pfile->file_node));
+        palacios_free(pfile->path);    
+        palacios_free(pfile);
     }
 
     return 0;
@@ -368,9 +374,18 @@ static int guest_file_init(struct v3_guest * guest, void ** vm_data) {
 
 
 static int guest_file_deinit(struct v3_guest * guest, void * vm_data) {
+    struct vm_file_state * state = (struct vm_file_state *)vm_data;
+    struct palacios_file * pfile = NULL;
+    struct palacios_file * tmp = NULL;
     
-    palacios_free(vm_data);
+    list_for_each_entry_safe(pfile, tmp, &(state->open_files), file_node) { 
+        filp_close(pfile->filp, NULL);
+        list_del(&(pfile->file_node));
+        palacios_free(pfile->path);    
+        palacios_free(pfile);
+    }
 
+    palacios_free(state);
     return 0;
 }