X-Git-Url: http://v3vee.org/palacios/gitweb/gitweb.cgi?a=blobdiff_plain;f=palacios%2Fsrc%2Fpalacios%2Fvmm_config.c;h=38cfb70a787049a921e793599977a5bc832df381;hb=60ad6a41c6d0ee08ed689e8505eb0c3df0c2a289;hp=de646bf8b732c8d85d7338c00127c8526cd000c9;hpb=8070d5e87ee3b92cc95bdcb65b2906b0a55d2ea9;p=palacios.git diff --git a/palacios/src/palacios/vmm_config.c b/palacios/src/palacios/vmm_config.c index de646bf..38cfb70 100644 --- a/palacios/src/palacios/vmm_config.c +++ b/palacios/src/palacios/vmm_config.c @@ -33,8 +33,13 @@ #include +#ifdef V3_CONFIG_SWAPPING +#include +#endif - +#ifdef V3_CONFIG_HVM +#include +#endif #include #include @@ -52,9 +57,6 @@ #define COOKIE_V0 "v3vee\0\0\0" #define COOKIE_V1 "v3vee\0\0\1" - - - // This is used to access the configuration file index table struct file_hdr_v0 { uint32_t index; @@ -294,13 +296,14 @@ static inline uint32_t get_alignment(char * align_str) { } + static int pre_config_vm(struct v3_vm_info * vm, v3_cfg_tree_t * vm_cfg) { char * memory_str = v3_cfg_val(vm_cfg, "memory"); char * schedule_hz_str = v3_cfg_val(vm_cfg, "schedule_hz"); char * vm_class = v3_cfg_val(vm_cfg, "class"); char * align_str = v3_cfg_val(v3_cfg_subtree(vm_cfg, "memory"), "alignment"); uint32_t sched_hz = 100; // set the schedule frequency to 100 HZ - + if (!memory_str) { PrintError(VM_NONE, VCORE_NONE, "Memory is a required configuration parameter\n"); @@ -317,8 +320,19 @@ static int pre_config_vm(struct v3_vm_info * vm, v3_cfg_tree_t * vm_cfg) { // Amount of ram the Guest will have, always in MB vm->mem_size = (addr_t)atoi(memory_str) * 1024 * 1024; vm->mem_align = get_alignment(align_str); - - + +#ifdef V3_CONFIG_SWAPPING + if (v3_init_swapping_vm(vm,vm_cfg)) { + PrintError(vm,VCORE_NONE,"Unable to initialize swapping correctly\n"); + return -1; + } + if (vm->swap_state.enable_swapping) { + PrintDebug(vm,VCORE_NONE,"Swapping enabled\n"); + } else { + PrintDebug(vm,VCORE_NONE,"Swapping disabled\n"); + } +#endif + PrintDebug(VM_NONE, VCORE_NONE, "Alignment for %lu bytes of memory computed as 0x%x\n", vm->mem_size, vm->mem_align); if (strcasecmp(vm_class, "PC") == 0) { @@ -346,7 +360,12 @@ static int pre_config_vm(struct v3_vm_info * vm, v3_cfg_tree_t * vm_cfg) { return -1; } - +#ifdef V3_CONFIG_HVM + if (v3_init_hvm_vm(vm,vm_cfg)) { + PrintError(vm,VCORE_NONE,"Cannot initialize HVM for VM\n"); + return -1; + } +#endif if (schedule_hz_str) { sched_hz = atoi(schedule_hz_str); @@ -415,6 +434,13 @@ static int pre_config_core(struct guest_info * info, v3_cfg_tree_t * core_cfg) { return -1; } +#ifdef V3_CONFIG_HVM + if (v3_init_hvm_core(info)) { + PrintError(info->vm_info, info, "Error Initializing HVM Core\n"); + return -1; + } +#endif + if (info->vm_info->vm_class == V3_PC_VM) { if (pre_config_pc_core(info, core_cfg) == -1) { PrintError(info->vm_info, info, "PC Post configuration failure\n"); @@ -595,7 +621,9 @@ struct v3_vm_info * v3_config_guest(void * cfg_blob, void * priv_data) { V3_Print(vm, VCORE_NONE, "Preconfiguration\n"); if (pre_config_vm(vm, vm->cfg_data->cfg) == -1) { - PrintError(vm, VCORE_NONE, "Error in preconfiguration\n"); + PrintError(vm, VCORE_NONE, "Error in preconfiguration, attempting to free\n"); + vm->run_state=VM_ERROR; + v3_free_vm(vm); return NULL; } @@ -611,7 +639,9 @@ struct v3_vm_info * v3_config_guest(void * cfg_blob, void * priv_data) { info->core_cfg_data = per_core_cfg; if (pre_config_core(info, per_core_cfg) == -1) { - PrintError(vm, VCORE_NONE, "Error in core %d preconfiguration\n", i); + PrintError(vm, VCORE_NONE, "Error in core %d preconfiguration, attempting to free guest\n", i); + vm->run_state=VM_ERROR; + v3_free_vm(vm); return NULL; } @@ -623,7 +653,9 @@ struct v3_vm_info * v3_config_guest(void * cfg_blob, void * priv_data) { V3_Print(vm, VCORE_NONE, "Post Configuration\n"); if (post_config_vm(vm, vm->cfg_data->cfg) == -1) { - PrintError(vm, VCORE_NONE, "Error in postconfiguration\n"); + PrintError(vm, VCORE_NONE, "Error in postconfiguration, attempting to free guest\n"); + vm->run_state=VM_ERROR; + v3_free_vm(vm); return NULL; }