X-Git-Url: http://v3vee.org/palacios/gitweb/gitweb.cgi?a=blobdiff_plain;f=palacios%2Fsrc%2Fpalacios%2Fvmm_checkpoint.c;h=5ba96ac891d6303aabf60f4bcb057efdc2790d4b;hb=b114cb5ecaeb5e330511684a1c8d56e23fb2f136;hp=f33f64ed49cd4503781046b8d6374bc5f241e21e;hpb=e00538192a2762cacb12b359b40f076cb4f3ba83;p=palacios.git diff --git a/palacios/src/palacios/vmm_checkpoint.c b/palacios/src/palacios/vmm_checkpoint.c index f33f64e..5ba96ac 100644 --- a/palacios/src/palacios/vmm_checkpoint.c +++ b/palacios/src/palacios/vmm_checkpoint.c @@ -26,6 +26,7 @@ #include #include #include +#include #include @@ -236,12 +237,12 @@ static int save_memory(struct v3_vm_info * vm, struct v3_chkpt * chkpt) { } int save_header(struct v3_vm_info * vm, struct v3_chkpt * chkpt) { - v3_cpu_arch_t cpu_type = v3_get_cpu_type(V3_Get_CPU()); + extern v3_cpu_arch_t v3_mach_type; void * ctx = NULL; ctx = v3_chkpt_open_ctx(chkpt, NULL, "header"); - switch (cpu_type) { + switch (v3_mach_type) { case V3_SVM_CPU: case V3_SVM_REV3_CPU: { v3_chkpt_save(ctx, "header", strlen(svm_chkpt_header), svm_chkpt_header); @@ -265,12 +266,12 @@ int save_header(struct v3_vm_info * vm, struct v3_chkpt * chkpt) { } static int load_header(struct v3_vm_info * vm, struct v3_chkpt * chkpt) { - v3_cpu_arch_t cpu_type = v3_get_cpu_type(V3_Get_CPU()); + extern v3_cpu_arch_t v3_mach_type; void * ctx = NULL; ctx = v3_chkpt_open_ctx(chkpt, NULL, "header"); - switch (cpu_type) { + switch (v3_mach_type) { case V3_SVM_CPU: case V3_SVM_REV3_CPU: { char header[strlen(svm_chkpt_header) + 1]; @@ -301,7 +302,7 @@ static int load_header(struct v3_vm_info * vm, struct v3_chkpt * chkpt) { static int load_core(struct guest_info * info, struct v3_chkpt * chkpt) { - v3_cpu_arch_t cpu_type = v3_get_cpu_type(V3_Get_CPU()); + extern v3_cpu_arch_t v3_mach_type; void * ctx = NULL; char key_name[16]; memset(key_name, 0, 16); @@ -310,6 +311,8 @@ static int load_core(struct guest_info * info, struct v3_chkpt * chkpt) { ctx = v3_chkpt_open_ctx(chkpt, NULL, key_name); + v3_chkpt_load_64(ctx, "RIP", &(info->rip)); + V3_CHKPT_STD_LOAD(ctx, info->vm_regs); V3_CHKPT_STD_LOAD(ctx, info->ctrl_regs.cr0); @@ -331,8 +334,22 @@ static int load_core(struct guest_info * info, struct v3_chkpt * chkpt) { info->cpu_mode = v3_get_vm_cpu_mode(info); info->mem_mode = v3_get_vm_mem_mode(info); + if (info->shdw_pg_mode == SHADOW_PAGING) { + if (v3_get_vm_mem_mode(info) == VIRTUAL_MEM) { + if (v3_activate_shadow_pt(info) == -1) { + PrintError("Failed to activate shadow page tables\n"); + return -1; + } + } else { + if (v3_activate_passthrough_pt(info) == -1) { + PrintError("Failed to activate passthrough page tables\n"); + return -1; + } + } + } + - switch (cpu_type) { + switch (v3_mach_type) { case V3_SVM_CPU: case V3_SVM_REV3_CPU: { char key_name[16]; @@ -367,26 +384,32 @@ static int load_core(struct guest_info * info, struct v3_chkpt * chkpt) { break; } default: - PrintError("Invalid CPU Type (%d)\n", cpu_type); + PrintError("Invalid CPU Type (%d)\n", v3_mach_type); return -1; } + v3_print_guest_state(info); + return 0; } static int save_core(struct guest_info * info, struct v3_chkpt * chkpt) { - v3_cpu_arch_t cpu_type = v3_get_cpu_type(V3_Get_CPU()); + extern v3_cpu_arch_t v3_mach_type; void * ctx = NULL; char key_name[16]; memset(key_name, 0, 16); + v3_print_guest_state(info); + snprintf(key_name, 16, "guest_info%d", info->vcpu_id); ctx = v3_chkpt_open_ctx(chkpt, NULL, key_name); + v3_chkpt_save_64(ctx, "RIP", &(info->rip)); + V3_CHKPT_STD_SAVE(ctx, info->vm_regs); V3_CHKPT_STD_SAVE(ctx, info->ctrl_regs.cr0); @@ -405,7 +428,7 @@ static int save_core(struct guest_info * info, struct v3_chkpt * chkpt) { v3_chkpt_close_ctx(ctx); //Architechture specific code - switch (cpu_type) { + switch (v3_mach_type) { case V3_SVM_CPU: case V3_SVM_REV3_CPU: { char key_name[16]; @@ -445,7 +468,7 @@ static int save_core(struct guest_info * info, struct v3_chkpt * chkpt) { break; } default: - PrintError("Invalid CPU Type (%d)\n", cpu_type); + PrintError("Invalid CPU Type (%d)\n", v3_mach_type); return -1; }