X-Git-Url: http://v3vee.org/palacios/gitweb/gitweb.cgi?a=blobdiff_plain;f=linux_module%2Fvm.c;h=1e9b2758249221359da492b9a04a88ad152664d9;hb=cfedaa152e9e6b3518b547d06fed1df371dc90e8;hp=40cfa0621ca9e00592562c7ac71fbd3315404e19;hpb=e784113618800cede961f9a86084a96d20179e1c;p=palacios.releases.git diff --git a/linux_module/vm.c b/linux_module/vm.c index 40cfa06..1e9b275 100644 --- a/linux_module/vm.c +++ b/linux_module/vm.c @@ -70,7 +70,7 @@ int add_guest_ctrl(struct v3_guest * guest, unsigned int cmd, unsigned int cmd, unsigned long arg, void * priv_data), void * priv_data) { - struct vm_ctrl * ctrl = kmalloc(sizeof(struct vm_ctrl), GFP_KERNEL); + struct vm_ctrl * ctrl = palacios_alloc(sizeof(struct vm_ctrl)); if (ctrl == NULL) { WARNING("Error: Could not allocate vm ctrl %d\n", cmd); @@ -83,7 +83,7 @@ int add_guest_ctrl(struct v3_guest * guest, unsigned int cmd, if (__insert_ctrl(guest, ctrl) != NULL) { WARNING("Could not insert guest ctrl %d\n", cmd); - kfree(ctrl); + palacios_free(ctrl); return -1; } @@ -217,17 +217,17 @@ static long v3_vm_ioctl(struct file * filp, memset(&cmd, 0, sizeof(struct v3_debug_cmd)); if (copy_from_user(&cmd, argp, sizeof(struct v3_debug_cmd))) { - printk("Error: Could not copy debug command from user space\n"); + ERROR("Error: Could not copy debug command from user space\n"); return -EFAULT; } evt.core_id = cmd.core; evt.cmd = cmd.cmd; - printk("Debugging VM\n"); + INFO("Debugging VM\n"); if (v3_deliver_debug_event(guest->v3_ctx, &evt) == -1) { - printk("Error could not deliver debug cmd\n"); + ERROR("Error could not deliver debug cmd\n"); return -EFAULT; } @@ -303,16 +303,18 @@ extern u32 frees; int create_palacios_vm(struct v3_guest * guest) { int err; - init_vm_extensions(guest); + if (init_vm_extensions(guest) < 0) { + WARNING("palacios: failed to initialize extensions\n"); + return -1; + } guest->v3_ctx = v3_create_vm(guest->img, (void *)guest, guest->name); if (guest->v3_ctx == NULL) { WARNING("palacios: failed to create vm\n"); - return -1; + goto out_err; } - NOTICE("Creating VM device: Major %d, Minor %d\n", MAJOR(guest->vm_dev), MINOR(guest->vm_dev)); cdev_init(&(guest->cdev), &v3_vm_fops); @@ -326,20 +328,25 @@ int create_palacios_vm(struct v3_guest * guest) { if (err) { WARNING("Fails to add cdev\n"); - v3_free_vm(guest->v3_ctx); - return -1; + goto out_err1; } if (device_create(v3_class, NULL, guest->vm_dev, guest, "v3-vm%d", MINOR(guest->vm_dev)) == NULL){ WARNING("Fails to create device\n"); - cdev_del(&(guest->cdev)); - v3_free_vm(guest->v3_ctx); - return -1; + goto out_err2; } NOTICE("palacios: vm created at /dev/v3-vm%d\n", MINOR(guest->vm_dev)); return 0; + +out_err2: + cdev_del(&(guest->cdev)); +out_err1: + v3_free_vm(guest->v3_ctx); +out_err: + deinit_vm_extensions(guest); + return -1; } @@ -355,7 +362,7 @@ int free_palacios_vm(struct v3_guest * guest) { cdev_del(&(guest->cdev)); vfree(guest->img); - kfree(guest); + palacios_free(guest); return 0; }