X-Git-Url: http://v3vee.org/palacios/gitweb/gitweb.cgi?a=blobdiff_plain;f=linux_module%2Fvm.c;h=d352c36439805e251cca9a936417221994685e31;hb=145dbb97d24518a80348a2aec5494b6d7805081b;hp=5584b381439e2559c14a5398cd1eef1349a08ea3;hpb=3c1a150e4bdf5bd3a8b572dd2021ba95cbb35f1a;p=palacios.git diff --git a/linux_module/vm.c b/linux_module/vm.c index 5584b38..d352c36 100644 --- a/linux_module/vm.c +++ b/linux_module/vm.c @@ -12,7 +12,6 @@ #include #include #include -#include #include #include #include @@ -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; } @@ -132,16 +131,15 @@ int remove_guest_ctrl(struct v3_guest * guest, unsigned int cmd) { static void free_guest_ctrls(struct v3_guest * guest) { struct rb_node * node = rb_first(&(guest->vm_ctrls)); struct vm_ctrl * ctrl = NULL; - struct rb_node * tmp_node = NULL; while (node) { ctrl = rb_entry(node, struct vm_ctrl, tree_node); - tmp_node = node; + node = rb_next(node); WARNING("Cleaning up guest ctrl that was not removed explicitly (%d)\n", ctrl->cmd); - kfree(ctrl); + palacios_free(ctrl); } } @@ -158,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: { @@ -213,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; } @@ -231,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; } @@ -257,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; } @@ -279,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; } @@ -319,13 +317,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; } @@ -387,7 +408,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"); @@ -444,8 +465,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;