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.


Minor changes to eliminate warnings, and second-try allocation for pages
[palacios.git] / linux_module / vm.c
index 1e9b275..54d5efd 100644 (file)
@@ -93,6 +93,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 +114,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));
+
+    kfree(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);
+
+       kfree(ctrl);
+    }
+}
 
 
 
@@ -199,7 +230,7 @@ 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) {
                WARNING("Error Loading VM state\n");
@@ -209,6 +240,53 @@ static long v3_vm_ioctl(struct file * filp,
            break;
        }
 #endif
+
+#ifdef V3_CONFIG_LIVE_MIGRATION  
+       case V3_VM_SEND: {
+           struct v3_chkpt_info chkpt_info;
+           void __user * argp = (void __user *)arg;
+           
+           memset(&chkpt_info,0, sizeof(struct v3_chkpt_info));
+           
+           if(copy_from_user(&chkpt_info, argp, sizeof(struct v3_chkpt_info))){
+               WARNING("Copy from user error getting checkpoint info\n");
+               return -EFAULT;
+           }
+           
+           
+           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) {
+               WARNING("Error sending VM\n");
+               return -EFAULT;
+           }
+           
+           break;
+       }
+
+       case V3_VM_RECEIVE: {
+           struct v3_chkpt_info chkpt_info;
+           void __user * argp = (void __user *)arg;
+           
+           memset(&chkpt_info,0, sizeof(struct v3_chkpt_info));
+
+           if(copy_from_user(&chkpt_info, argp, sizeof(struct v3_chkpt_info))){
+               WARNING("Copy from user error getting checkpoint info\n");
+               return -EFAULT;
+           }
+           
+           
+           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) {
+               WARNING("Error receiving VM\n");
+               return -EFAULT;
+           }
+           
+           break;
+       }
+#endif
+
        case V3_VM_DEBUG: {
            struct v3_debug_cmd cmd;
            struct v3_debug_event evt;
@@ -355,12 +433,17 @@ 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));
 
+    free_guest_ctrls(guest);
+
+
     vfree(guest->img);
     palacios_free(guest);