X-Git-Url: http://v3vee.org/palacios/gitweb/gitweb.cgi?a=blobdiff_plain;f=linux_module%2Fiface-host-dev.c;h=ca5de91f7ff1092500a0ac39ad6200c9dcccf70c;hb=a47bf8387bc195230e95edb4b0c9ffb81e50ac9f;hp=cfcf4c09b1e101997fafcfa68e93aa3b46fe649d;hpb=db0b003cd20ee08be24c6f3e7f2b5cc578d57aae;p=palacios.git diff --git a/linux_module/iface-host-dev.c b/linux_module/iface-host-dev.c index cfcf4c0..ca5de91 100644 --- a/linux_module/iface-host-dev.c +++ b/linux_module/iface-host-dev.c @@ -127,21 +127,18 @@ struct palacios_host_dev { #define SHALLOW_DEBUG 0 #if DEEP_DEBUG -#define DEEP_DEBUG_PRINT(fmt, args...) printk((fmt), ##args) +#define DEEP_DEBUG_PRINT(fmt, args...) DEBUG((fmt), ##args) #else #define DEEP_DEBUG_PRINT(fmt, args...) #endif #if SHALLOW_DEBUG -#define SHALLOW_DEBUG_PRINT(fmt, args...) printk((fmt), ##args) +#define SHALLOW_DEBUG_PRINT(fmt, args...) INFO((fmt), ##args) #else #define SHALLOW_DEBUG_PRINT(fmt, args...) #endif -#define ERROR(fmt, args...) printk((fmt), ##args) -#define INFO(fmt, args...) printk((fmt), ##args) - struct palacios_host_device_user { spinlock_t lock; int connected; // is the user space connected to this? @@ -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; } @@ -616,7 +613,7 @@ static int host_dev_connect(struct v3_guest * guest, unsigned int cmd, unsigned if (copy_from_user(url, argp, MAX_URL)) { - printk("copy from user error getting url for host device connect...\n"); + ERROR("copy from user error getting url for host device connect...\n"); return -EFAULT; } @@ -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); @@ -750,7 +747,7 @@ static v3_host_dev_t palacios_host_dev_open_deferred(char *url, host_dev = get_vm_ext_data(guest, "HOST_DEVICE_INTERFACE"); if (host_dev == NULL) { - printk("Error locating vm host data for HOST_DEVICE_INTERFACE\n"); + ERROR("Error locating vm host data for HOST_DEVICE_INTERFACE\n"); return 0; } @@ -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 };