#include <palacios/vmm_sprintf.h>
-
-
+#ifdef V3_CONFIG_SWAPPING
+#include <palacios/vmm_swapping.h>
+#endif
#include <palacios/vmm_host_events.h>
#include <palacios/vmm_perftune.h>
#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;
}
+
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");
// 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) {
}
+
+ // 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
*/
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;
}
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;
}
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;
}