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.


userspace changes to break apart VM lifecycle management
[palacios.git] / linux_module / vm.c
index 890cb69..9869334 100644 (file)
@@ -127,10 +127,25 @@ static long v3_vm_ioctl(struct file * filp,
     printk("V3 IOCTL %d\n", ioctl);
 
     switch (ioctl) {
+       case V3_VM_LAUNCH: {
+           printk("palacios: launching vm\n");
 
+           if (v3_start_vm(guest->v3_ctx, 0xfffffffe) < 0) { 
+               printk("palacios: launch of vm failed\n");
+               return -1;
+           }
+           
+           break;
+       }
        case V3_VM_STOP: {
-           printk("Stopping VM (%s)\n", guest->name);
-           stop_palacios_vm(guest);
+           printk("Stopping VM (%s) (%p)\n", guest->name, guest);
+
+           if (irqs_disabled()) {
+               printk("WHAT!!?? IRQs are disabled??\n");
+               break;
+           }
+
+           v3_stop_vm(guest->v3_ctx);
            break;
        }
        case V3_VM_PAUSE: {
@@ -143,7 +158,65 @@ static long v3_vm_ioctl(struct file * filp,
            v3_continue_vm(guest->v3_ctx);
            break;
        }
+#ifdef V3_CONFIG_CHECKPOINT
+       case V3_VM_SAVE: {
+           struct v3_chkpt_info chkpt;
+           void __user * argp = (void __user *)arg;
+
+           memset(&chkpt, 0, sizeof(struct v3_chkpt_info));
+
+           if (copy_from_user(&chkpt, argp, sizeof(struct v3_chkpt_info))) {
+               printk("Copy from user error getting checkpoint info\n");
+               return -EFAULT;
+           }
+           
+           printk("Saving Guest to %s:%s\n", chkpt.store, chkpt.url);
+
+           if (v3_save_vm(guest->v3_ctx, chkpt.store, chkpt.url) == -1) {
+               printk("Error checkpointing VM state\n");
+               return -EFAULT;
+           }
+           
+           break;
+       }
+       case V3_VM_LOAD: {
+           struct v3_chkpt_info chkpt;
+           void __user * argp = (void __user *)arg;
+
+           memset(&chkpt, 0, sizeof(struct v3_chkpt_info));
+
+           if (copy_from_user(&chkpt, argp, sizeof(struct v3_chkpt_info))) {
+               printk("Copy from user error getting checkpoint info\n");
+               return -EFAULT;
+           }
+           
+           printk("Loading Guest to %s:%s\n", chkpt.store, chkpt.url);
+
+           if (v3_load_vm(guest->v3_ctx, chkpt.store, chkpt.url) == -1) {
+               printk("Error Loading VM state\n");
+               return -EFAULT;
+           }
+           
+           break;
+       }
+#endif
+       case V3_VM_MOVE_CORE: {
+           struct v3_core_move_cmd cmd;
+           void __user * argp = (void __user *)arg;
+
+           memset(&cmd, 0, sizeof(struct v3_core_move_cmd));
+           
+           if (copy_from_user(&cmd, argp, sizeof(struct v3_core_move_cmd))) {
+               printk("copy from user error getting migrate command...\n");
+               return -EFAULT;
+           }
+       
+           printk("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);
 
+           break;
+       }
        default: {
            struct vm_ctrl * ctrl = get_ctrl(guest, ioctl);
 
@@ -194,22 +267,15 @@ extern u32 pg_frees;
 extern u32 mallocs;
 extern u32 frees;
 
-int start_palacios_vm(void * arg)  {
-    struct v3_guest * guest = (struct v3_guest *)arg;
+int create_palacios_vm(struct v3_guest * guest)  {
     int err;
 
-
-    daemonize(guest->name);
-    // allow_signal(SIGKILL);
-
-    
     init_vm_extensions(guest);
 
     guest->v3_ctx = v3_create_vm(guest->img, (void *)guest, guest->name);
 
     if (guest->v3_ctx == NULL) { 
        printk("palacios: failed to create vm\n");
-       complete(&(guest->start_done));
        return -1;
     }
 
@@ -228,7 +294,6 @@ int start_palacios_vm(void * arg)  {
     if (err) {
        printk("Fails to add cdev\n");
        v3_free_vm(guest->v3_ctx);
-       complete(&(guest->start_done));
        return -1;
     }
 
@@ -236,25 +301,10 @@ int start_palacios_vm(void * arg)  {
        printk("Fails to create device\n");
        cdev_del(&(guest->cdev));
        v3_free_vm(guest->v3_ctx);
-       complete(&(guest->start_done));
        return -1;
     }
 
-    complete(&(guest->start_done));
-
-    printk("palacios: launching vm\n");
-
-    if (v3_start_vm(guest->v3_ctx, 0xffffffff) < 0) { 
-       printk("palacios: launch of vm failed\n");
-       device_destroy(v3_class, guest->vm_dev);
-       cdev_del(&(guest->cdev));
-       v3_free_vm(guest->v3_ctx);
-       return -1;
-    }
-    
-    complete(&(guest->thread_done));
-
-    printk("palacios: vm completed.  returning.\n");
+    printk("palacios: vm created at /dev/v3-vm%d\n", MINOR(guest->vm_dev));
 
     return 0;
 }
@@ -262,14 +312,11 @@ int start_palacios_vm(void * arg)  {
 
 
 
-int stop_palacios_vm(struct v3_guest * guest) {
-
-    v3_stop_vm(guest->v3_ctx);
 
-    wait_for_completion(&(guest->thread_done));
+int free_palacios_vm(struct v3_guest * guest) {
 
     v3_free_vm(guest->v3_ctx);
-    
+
     device_destroy(v3_class, guest->vm_dev);
 
     cdev_del(&(guest->cdev));