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.


Expose VM reset capability to Linux and Linux user
[palacios.git] / linux_module / vm.c
index b7425e4..440ff69 100644 (file)
@@ -12,7 +12,6 @@
 #include <linux/poll.h>
 #include <linux/anon_inodes.h>
 #include <linux/sched.h>
-#include <linux/vmalloc.h>
 #include <linux/file.h>
 #include <linux/spinlock.h>
 #include <linux/rbtree.h>
@@ -124,7 +123,7 @@ int remove_guest_ctrl(struct v3_guest * guest, unsigned int cmd) {
 
     rb_erase(&(ctrl->tree_node), &(guest->vm_ctrls));
 
-    kfree(ctrl);
+    palacios_free(ctrl);
 
     return 0;
 }
@@ -140,7 +139,7 @@ static void free_guest_ctrls(struct v3_guest * guest) {
        
        WARNING("Cleaning up guest ctrl that was not removed explicitly (%d)\n", ctrl->cmd);
 
-       kfree(ctrl);
+       palacios_free(ctrl);
     }
 }
 
@@ -157,7 +156,7 @@ static long v3_vm_ioctl(struct file * filp,
 
     struct v3_guest * guest = filp->private_data;
 
-    INFO("V3 IOCTL %d\n", ioctl);
+    DEBUG("V3 IOCTL %d\n", ioctl);
 
     switch (ioctl) {
        case V3_VM_LAUNCH: {
@@ -196,6 +195,38 @@ static long v3_vm_ioctl(struct file * filp,
            v3_simulate_vm(guest->v3_ctx, arg);
            break;
        }
+       case V3_VM_RESET: {
+           struct v3_reset_cmd r;
+           void __user * argp = (void __user *)arg;
+           v3_vm_reset_type t;
+           uint32_t core_range[2];
+
+           if (copy_from_user(&r, argp, sizeof(struct v3_reset_cmd))) {
+               WARNING("Copy from user error getting reset info\n");
+               return -EFAULT;
+           }
+           
+           if (r.type==V3_RESET_VM_ALL) { 
+               t=V3_VM_RESET_ALL;
+           } else if (r.type==V3_RESET_VM_HRT) {
+               t=V3_VM_RESET_HRT;
+           } else if (r.type==V3_RESET_VM_ROS) {
+               t=V3_VM_RESET_ROS;
+           } else if (r.type==V3_RESET_VM_CORE_RANGE){
+               t=V3_VM_RESET_CORE_RANGE;
+               core_range[0]=r.first_core;
+               core_range[1]=r.first_core+r.num_cores-1;
+           } else {
+               ERROR("Unknown reset type %d requested\n",r.type);
+               return -EFAULT;
+           }
+           
+           if (v3_reset_vm_extended(guest->v3_ctx, t, core_range) == -1) {
+               WARNING("Error reseting VM\n");
+               return -EFAULT;
+           }
+           break;
+       }
 
 
 #ifdef V3_CONFIG_CHECKPOINT
@@ -318,13 +349,36 @@ static long v3_vm_ioctl(struct file * filp,
            memset(&cmd, 0, sizeof(struct v3_core_move_cmd));
            
            if (copy_from_user(&cmd, argp, sizeof(struct v3_core_move_cmd))) {
-               WARNING("copy from user error getting migrate command...\n");
+               WARNING("copy from user error getting migrate core command...\n");
                return -EFAULT;
            }
        
            INFO("moving guest %s vcore %d to CPU %d\n", guest->name, cmd.vcore_id, cmd.pcore_id);
 
-           v3_move_vm_core(guest->v3_ctx, cmd.vcore_id, cmd.pcore_id);
+           if (v3_move_vm_core(guest->v3_ctx, cmd.vcore_id, cmd.pcore_id)) { 
+               ERROR("Could not move core\n");
+               return -EFAULT;
+           }
+
+           break;
+       }
+       case V3_VM_MOVE_MEM: {
+           struct v3_mem_move_cmd cmd;
+           void __user * argp = (void __user *)arg;
+
+           memset(&cmd, 0, sizeof(struct v3_mem_move_cmd));
+           
+           if (copy_from_user(&cmd, argp, sizeof(struct v3_mem_move_cmd))) {
+               WARNING("copy from user error getting migrate memory command...\n");
+               return -EFAULT;
+           }
+       
+           INFO("moving guest %s memory at gpa %p to memory with affinity for CPU %d\n", guest->name, (void*)(cmd.gpa), cmd.pcore_id);
+
+           if (v3_move_vm_mem(guest->v3_ctx, (void*)(cmd.gpa), cmd.pcore_id)) {
+               ERROR("Could not move memory\n");
+               return -EFAULT;
+           }
 
            break;
        }
@@ -386,7 +440,7 @@ int create_palacios_vm(struct v3_guest * guest)  {
         return -1;
     }
 
-    guest->v3_ctx = v3_create_vm(guest->img, (void *)guest, guest->name);
+    guest->v3_ctx = v3_create_vm(guest->img, (void *)guest, guest->name, (0x1 << num_online_cpus()) - 1);
 
     if (guest->v3_ctx == NULL) { 
        WARNING("palacios: failed to create vm\n");
@@ -443,8 +497,9 @@ int free_palacios_vm(struct v3_guest * guest) {
 
     free_guest_ctrls(guest);
 
+    deinit_vm_extensions(guest);
 
-    vfree(guest->img);
+    palacios_vfree(guest->img);
     palacios_free(guest);
 
     return 0;