X-Git-Url: http://v3vee.org/palacios/gitweb/gitweb.cgi?a=blobdiff_plain;f=palacios%2Fsrc%2Fpalacios%2Fvmm_config.c;h=781754ad15cbb1c93886f7fc973a3d6bf9d2051f;hb=5ef0e92d52b2698fd2706cd7cfc2b01526a6e319;hp=d8f1961ec6dddcb725d7f71606d03ee23c51971d;hpb=acaadd79c597c8d5180fbfbec79c01fef3dff003;p=palacios.git diff --git a/palacios/src/palacios/vmm_config.c b/palacios/src/palacios/vmm_config.c index d8f1961..781754a 100644 --- a/palacios/src/palacios/vmm_config.c +++ b/palacios/src/palacios/vmm_config.c @@ -33,8 +33,9 @@ #include - - +#ifdef V3_CONFIG_SWAPPING +#include +#endif #include #include @@ -52,9 +53,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 +292,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 +316,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) { @@ -452,6 +462,13 @@ static int post_config_vm(struct v3_vm_info * vm, v3_cfg_tree_t * cfg) { } + + // Initialize fw_cfg state for VMM<->VM SEABIOS communication + if (v3_fw_cfg_init(vm) == -1) { + PrintError(vm, VCORE_NONE, "Error initializing Firmware Config (fw_cfg) state\n"); + return -1; + } + /* * Initialize configured devices */ @@ -588,7 +605,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; } @@ -604,7 +623,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; } @@ -616,7 +637,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; }