X-Git-Url: http://v3vee.org/palacios/gitweb/gitweb.cgi?a=blobdiff_plain;f=linux_module%2Fvm.c;h=ac1b363c5d00a71f66dfdeb2e1ad7c7410209eaf;hb=4a63fd4cef38da57f4b44d8ac88737faa0a12846;hp=b14cff42c57cdfa4579a5b9a746b1594d22f43a6;hpb=4b9f54d875c87a0b06337fb64239278d6cfc02fa;p=palacios.releases.git diff --git a/linux_module/vm.c b/linux_module/vm.c index b14cff4..ac1b363 100644 --- a/linux_module/vm.c +++ b/linux_module/vm.c @@ -12,7 +12,6 @@ #include #include #include -#include #include #include #include @@ -93,6 +92,8 @@ int add_guest_ctrl(struct v3_guest * guest, unsigned int cmd, } + + static struct vm_ctrl * get_ctrl(struct v3_guest * guest, unsigned int cmd) { struct rb_node * n = guest->vm_ctrls.rb_node; struct vm_ctrl * ctrl = NULL; @@ -112,6 +113,35 @@ static struct vm_ctrl * get_ctrl(struct v3_guest * guest, unsigned int cmd) { return NULL; } +int remove_guest_ctrl(struct v3_guest * guest, unsigned int cmd) { + struct vm_ctrl * ctrl = get_ctrl(guest, cmd); + + if (ctrl == NULL) { + INFO("Could not find control (%d) to remove\n", cmd); + return -1; + } + + rb_erase(&(ctrl->tree_node), &(guest->vm_ctrls)); + + palacios_free(ctrl); + + return 0; +} + +static void free_guest_ctrls(struct v3_guest * guest) { + struct rb_node * node = rb_first(&(guest->vm_ctrls)); + struct vm_ctrl * ctrl = NULL; + + while (node) { + ctrl = rb_entry(node, struct vm_ctrl, tree_node); + + node = rb_next(node); + + WARNING("Cleaning up guest ctrl that was not removed explicitly (%d)\n", ctrl->cmd); + + palacios_free(ctrl); + } +} @@ -181,7 +211,7 @@ static long v3_vm_ioctl(struct file * filp, NOTICE("Saving Guest to %s:%s\n", chkpt.store, chkpt.url); - if (v3_save_vm(guest->v3_ctx, chkpt.store, chkpt.url) == -1) { + if (v3_save_vm(guest->v3_ctx, chkpt.store, chkpt.url, chkpt.opts) == -1) { WARNING("Error checkpointing VM state\n"); return -EFAULT; } @@ -199,9 +229,9 @@ static long v3_vm_ioctl(struct file * filp, return -EFAULT; } - NOTICE("Loading Guest to %s:%s\n", chkpt.store, chkpt.url); + NOTICE("Loading Guest from %s:%s\n", chkpt.store, chkpt.url); - if (v3_load_vm(guest->v3_ctx, chkpt.store, chkpt.url) == -1) { + if (v3_load_vm(guest->v3_ctx, chkpt.store, chkpt.url, chkpt.opts) == -1) { WARNING("Error Loading VM state\n"); return -EFAULT; } @@ -225,7 +255,7 @@ static long v3_vm_ioctl(struct file * filp, NOTICE("Sending (live-migrating) Guest to %s:%s\n",chkpt_info.store, chkpt_info.url); - if (v3_send_vm(guest->v3_ctx, chkpt_info.store, chkpt_info.url) == -1) { + if (v3_send_vm(guest->v3_ctx, chkpt_info.store, chkpt_info.url, chkpt_info.opts) == -1) { WARNING("Error sending VM\n"); return -EFAULT; } @@ -247,7 +277,7 @@ static long v3_vm_ioctl(struct file * filp, NOTICE("Receiving (live-migrating) Guest to %s:%s\n",chkpt_info.store, chkpt_info.url); - if (v3_receive_vm(guest->v3_ctx, chkpt_info.store, chkpt_info.url) == -1) { + if (v3_receive_vm(guest->v3_ctx, chkpt_info.store, chkpt_info.url, chkpt_info.opts) == -1) { WARNING("Error receiving VM\n"); return -EFAULT; } @@ -402,13 +432,18 @@ out_err: int free_palacios_vm(struct v3_guest * guest) { - v3_free_vm(guest->v3_ctx); + if (v3_free_vm(guest->v3_ctx)<0) { + return -1; + } device_destroy(v3_class, guest->vm_dev); cdev_del(&(guest->cdev)); - vfree(guest->img); + free_guest_ctrls(guest); + + + palacios_vfree(guest->img); palacios_free(guest); return 0;