X-Git-Url: http://v3vee.org/palacios/gitweb/gitweb.cgi?a=blobdiff_plain;f=palacios%2Fsrc%2Fpalacios%2Fvmm.c;h=580a514b2568106d902e0aa0c1270f8d3da0c0e9;hb=4a13fd6e61111133266b79ec8ff1f84258f953f4;hp=e10c9a344d6513f33004c7d645a509b7fe4ff472;hpb=0acab7cc621777394096377d6412e7f796e41769;p=palacios.git diff --git a/palacios/src/palacios/vmm.c b/palacios/src/palacios/vmm.c index e10c9a3..580a514 100644 --- a/palacios/src/palacios/vmm.c +++ b/palacios/src/palacios/vmm.c @@ -82,7 +82,7 @@ void Init_V3(struct v3_os_hooks * hooks, int num_cpus) { } // Register all the possible device types - v3_init_devices(); + V3_init_devices(); // Register all shadow paging handlers V3_init_shdw_paging(); @@ -208,7 +208,7 @@ int v3_start_vm(struct v3_vm_info * vm, unsigned int cpu_mask) { } if (vm->num_cores > avail_cores) { - PrintError("Attempted to start a VM with too many cores (MAX=%d)\n", MAX_CORES); + PrintError("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; } @@ -269,13 +269,50 @@ int v3_stop_vm(struct v3_vm_info * vm) { vm->run_state = VM_STOPPED; - // force exit all cores via a cross call/IPI - // Wait for all cores to enter CORE_STOPPED state + while (1) { + int i = 0; + int still_running = 0; + + for (i = 0; i < vm->num_cores; i++) { + if (vm->cores[i].core_run_state != CORE_STOPPED) { + still_running = 1; + } + } + + if (still_running == 0) { + break; + } + + V3_Print("Yielding\n"); + + v3_yield(NULL); + } + + V3_Print("VM stopped. Returning\n"); + + return 0; +} + +int v3_free_vm(struct v3_vm_info * vm) { + int i = 0; // deinitialize guest (free memory, etc...) + v3_free_vm_devices(vm); + + for (i = 0; i < vm->num_cores; i++) { + // free cores + + v3_free_core(&(vm->cores[i])); + + } + + v3_free_vm_internal(vm); + + // free vm + return 0; }