X-Git-Url: http://v3vee.org/palacios/gitweb/gitweb.cgi?a=blobdiff_plain;f=palacios%2Fsrc%2Fpalacios%2Fvmm.c;h=6e32e88a8d982583cfdc1e69665a28288297d8ec;hb=c53e6ed4d6903df3c8351b8334848c466076d5b0;hp=148b86e65c60df88d9b7158b371c8c1b0f30fc1d;hpb=acaadd79c597c8d5180fbfbec79c01fef3dff003;p=palacios.git diff --git a/palacios/src/palacios/vmm.c b/palacios/src/palacios/vmm.c index 148b86e..6e32e88 100644 --- a/palacios/src/palacios/vmm.c +++ b/palacios/src/palacios/vmm.c @@ -26,7 +26,7 @@ #include #include #include - +#include #ifdef V3_CONFIG_SVM #include @@ -99,8 +99,7 @@ static void deinit_cpu(void * arg) { } } - -void Init_V3(struct v3_os_hooks * hooks, char * cpu_mask, int num_cpus) { +void Init_V3(struct v3_os_hooks * hooks, char * cpu_mask, int num_cpus, char *options) { int i = 0; int minor = 0; int major = 0; @@ -117,15 +116,24 @@ void Init_V3(struct v3_os_hooks * hooks, char * cpu_mask, int num_cpus) { v3_cpu_types[i] = V3_INVALID_CPU; } + // Parse host-os defined options into an easily-accessed format. + v3_parse_options(options); + // Register all the possible device types V3_init_devices(); // Register all shadow paging handlers V3_init_shdw_paging(); + // Initialize the scheduler framework (must be before extensions) + V3_init_scheduling(); + // Register all extensions V3_init_extensions(); + // Enabling scheduler + V3_enable_scheduler(); + #ifdef V3_CONFIG_SYMMOD V3_init_symmod(); @@ -208,6 +216,15 @@ struct v3_vm_info * v3_create_vm(void * cfg, void * priv_data, char * name) { memset(vm->name, 0, 128); strncpy(vm->name, name, 127); + /* + * Register this VM with the palacios scheduler. It will ask for admission + * prior to launch. + */ + if(v3_scheduler_register_vm(vm) == -1) { + + PrintError(vm, VCORE_NONE,"Error registering VM with scheduler\n"); + } + return vm; } @@ -218,6 +235,9 @@ static int start_core(void * p) { struct guest_info * core = (struct guest_info *)p; + if (v3_scheduler_register_core(core) == -1){ + PrintError(core->vm_info, core,"Error initializing scheduling in core %d\n", core->vcpu_id); + } PrintDebug(core->vm_info,core,"virtual core %u (on logical core %u): in start_core (RIP=%p)\n", core->vcpu_id, core->pcpu_id, (void *)(addr_t)core->rip); @@ -298,10 +318,10 @@ int v3_start_vm(struct v3_vm_info * vm, unsigned int cpu_mask) { } - if (vm->num_cores > avail_cores) { - PrintError(vm, VCORE_NONE, "Attempted to start a VM with too many cores (vm->num_cores = %d, avail_cores = %d, MAX=%d)\n", - vm->num_cores, avail_cores, MAX_CORES); - return -1; + vm->avail_cores = avail_cores; + + if (v3_scheduler_admit_vm(vm) != 0){ + PrintError(vm, VCORE_NONE,"Error admitting VM %s for scheduling", vm->name); } vm->run_state = VM_RUNNING; @@ -780,53 +800,6 @@ v3_cpu_mode_t v3_get_host_cpu_mode() { #endif - - - - -void v3_yield_cond(struct guest_info * info, int usec) { - uint64_t cur_cycle; - cur_cycle = v3_get_host_time(&info->time_state); - - if (cur_cycle > (info->yield_start_cycle + info->vm_info->yield_cycle_period)) { - //PrintDebug(info->vm_info, info, "Conditional Yield (cur_cyle=%p, start_cycle=%p, period=%p)\n", - // (void *)cur_cycle, (void *)info->yield_start_cycle, - // (void *)info->yield_cycle_period); - - if (usec < 0) { - V3_Yield(); - } else { - V3_Sleep(usec); - } - - info->yield_start_cycle += info->vm_info->yield_cycle_period; - } -} - - -/* - * unconditional cpu yield - * if the yielding thread is a guest context, the guest quantum is reset on resumption - * Non guest context threads should call this function with a NULL argument - * - * usec <0 => the non-timed yield is used - * usec >=0 => the timed yield is used, which also usually implies interruptible - */ -void v3_yield(struct guest_info * info, int usec) { - if (usec < 0) { - V3_Yield(); - } else { - V3_Sleep(usec); - } - - if (info) { - info->yield_start_cycle += info->vm_info->yield_cycle_period; - } -} - - - - void v3_print_cond(const char * fmt, ...) { if (v3_dbg_enable == 1) { char buf[2048];