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.


Enhancements to VNET and to halting:
[palacios.git] / linux_module / iface-host-dev.c
index 5ef4d16..ca5de91 100644 (file)
@@ -138,9 +138,6 @@ struct palacios_host_dev {
 #define SHALLOW_DEBUG_PRINT(fmt, args...) 
 #endif
 
-// Moved to palacios.h
-//define ERROR(fmt, args...)
-//define INFO(fmt, args...)
 
 struct palacios_host_device_user {
     spinlock_t lock;
@@ -171,14 +168,14 @@ struct palacios_host_device_user {
 static void palacios_host_dev_user_free(struct palacios_host_device_user *dev)
 {
     if (dev->req) {
-       kfree(dev->req);
+       palacios_free(dev->req);
        dev->req=0;
     } 
     if (dev->resp) { 
-       kfree(dev->resp);
+       palacios_free(dev->resp);
        dev->resp=0;
     }
-    kfree(dev);
+    palacios_free(dev);
 }
 
 
@@ -216,8 +213,8 @@ static int palacios_resize_reqresp(struct palacios_host_dev_host_request_respons
     if ((*r)==0) { 
        // allocate it
        DEEP_DEBUG_PRINT("palacios: hostdev: attempt alloc\n");
-       *r = kmalloc(sizeof(struct palacios_host_dev_host_request_response)+data_size,GFP_KERNEL);
-       DEEP_DEBUG_PRINT("palacios: hostdev: kmalloc done\n");
+       *r = palacios_alloc(sizeof(struct palacios_host_dev_host_request_response)+data_size);
+       DEEP_DEBUG_PRINT("palacios: hostdev: palacios_alloc done\n");
        if ((*r)==0) { 
            ERROR("palacios: hostdev: failed to allocate\n");
            return -1;
@@ -238,10 +235,10 @@ static int palacios_resize_reqresp(struct palacios_host_dev_host_request_respons
            struct palacios_host_dev_host_request_response *new;
 
            if (!copy) { 
-               kfree(*r);
+               palacios_free(*r);
                *r=0;
            }
-           new = kmalloc(sizeof(struct palacios_host_dev_host_request_response)+data_size,GFP_KERNEL);
+           new = palacios_alloc(sizeof(struct palacios_host_dev_host_request_response)+data_size);
            if (!new) { 
                ERROR("palacios: hostdev: failed to reallocate\n");
                return -1;
@@ -250,7 +247,7 @@ static int palacios_resize_reqresp(struct palacios_host_dev_host_request_respons
                if (copy) { 
                    memcpy(new->data,(*r)->data,(*r)->data_len-sizeof(struct palacios_host_dev_host_request_response));
                    new->data_len=(*r)->data_len;
-                   kfree(*r);
+                   palacios_free(*r);
                }
                *r=new;
                DEEP_DEBUG_PRINT("palacios: hostdev: reallocated\n");
@@ -370,7 +367,7 @@ static long host_dev_ioctl(struct file * fp, unsigned int val, unsigned long arg
            
            switch (op.type) { 
                case PALACIOS_HOST_DEV_USER_REQUEST_READ_GUEST: {
-                   void *temp = kmalloc(op.len,GFP_KERNEL);
+                   void *temp = palacios_alloc(op.len);
 
                    DEEP_DEBUG_PRINT("palacios: hostdev: read guest\n");
 
@@ -385,17 +382,17 @@ static long host_dev_ioctl(struct file * fp, unsigned int val, unsigned long arg
                                                   temp,
                                                   op.len) != op.len) {
                        ERROR("palacios: unable to read enough from guest for host device \"%s\"\n",dev->url);
-                       kfree(temp);
+                       palacios_free(temp);
                        return -EFAULT;
                    }
                    
                    if (copy_to_user(op.data,temp,op.len)) { 
                        ERROR("palacios: unable to copy to user for host device \"%s\"\n",dev->url);
-                       kfree(temp);
+                       palacios_free(temp);
                        return -EFAULT;
                    }
 
-                   kfree(temp);
+                   palacios_free(temp);
 
                    return op.len;
                }
@@ -407,7 +404,7 @@ static long host_dev_ioctl(struct file * fp, unsigned int val, unsigned long arg
                    
                    DEEP_DEBUG_PRINT("palacios: hostdev: write guest\n");
 
-                   temp = kmalloc(op.len,GFP_KERNEL);
+                   temp = palacios_alloc(op.len);
 
                    if (!temp) { 
                        ERROR("palacios: unable to allocate enough for write guest request for host device \"%s\"\n",dev->url);
@@ -416,7 +413,7 @@ static long host_dev_ioctl(struct file * fp, unsigned int val, unsigned long arg
                    
                    if (copy_from_user(temp,op.data,op.len)) { 
                        ERROR("palacios: unable to copy from user for host device \"%s\"\n",dev->url);
-                       kfree(temp);
+                       palacios_free(temp);
                        return -EFAULT;
                    }
                    
@@ -426,11 +423,11 @@ static long host_dev_ioctl(struct file * fp, unsigned int val, unsigned long arg
                                                    temp,
                                                    op.len) != op.len) {
                        ERROR("palacios: unable to write enough to guest for host device \"%s\"\n",dev->url);
-                       kfree(temp);
+                       palacios_free(temp);
                        return -EFAULT;
                    }
 
-                   kfree(temp);
+                   palacios_free(temp);
                    
                    return op.len;
                }
@@ -653,11 +650,11 @@ static int host_dev_connect(struct v3_guest * guest, unsigned int cmd, unsigned
                    dev->connected=1;
                    dev->waiting=0;
                    if (dev->req) { 
-                       kfree(dev->req);
+                       palacios_free(dev->req);
                        dev->req=0;
                    } 
                    if (dev->resp) { 
-                       kfree(dev->resp);
+                       palacios_free(dev->resp);
                        dev->resp=0;
                    }
                    INFO("palacios: connected fd for device \"%s\"\n",url);
@@ -775,7 +772,7 @@ static v3_host_dev_t palacios_host_dev_open_deferred(char *url,
 
     INFO("palacios: creating host device \"%s\"\n",url);
 
-    dev = kmalloc(sizeof(struct palacios_host_device_user),GFP_KERNEL);
+    dev = palacios_alloc(sizeof(struct palacios_host_device_user));
     
     if (!dev) { 
        ERROR("palacios: cannot allocate for host device \"%s\"\n",url);
@@ -1324,7 +1321,7 @@ static int host_dev_init( void ) {
 
 
 static int host_dev_guest_init(struct v3_guest * guest, void ** vm_data ) {
-    struct palacios_host_dev * host_dev = kmalloc(sizeof(struct palacios_host_dev), GFP_KERNEL);
+    struct palacios_host_dev * host_dev = palacios_alloc(sizeof(struct palacios_host_dev));
 
     if (!host_dev) { 
        ERROR("palacios: failed to do guest_init for host device\n");
@@ -1344,6 +1341,12 @@ static int host_dev_guest_init(struct v3_guest * guest, void ** vm_data ) {
 }
 
 
+static int host_dev_guest_deinit(struct v3_guest * guest, void * vm_data) {
+
+    palacios_free(vm_data);
+    return 0;
+}
+
 
 
 
@@ -1352,7 +1355,7 @@ static struct linux_ext host_dev_ext = {
     .init = host_dev_init,
     .deinit = NULL,
     .guest_init = host_dev_guest_init,
-    .guest_deinit = NULL
+    .guest_deinit = host_dev_guest_deinit
 };