From: Jack Lange Date: Fri, 27 Jul 2012 19:04:38 +0000 (-0400) Subject: added state checks for VM control commands X-Git-Url: http://v3vee.org/palacios/gitweb/gitweb.cgi?a=commitdiff_plain;h=e3b62e7befa086a4fb320890952f54667ee46329;p=palacios.git added state checks for VM control commands --- diff --git a/palacios/src/palacios/vmm.c b/palacios/src/palacios/vmm.c index 18871b0..1d8cd07 100644 --- a/palacios/src/palacios/vmm.c +++ b/palacios/src/palacios/vmm.c @@ -457,6 +457,12 @@ int v3_move_vm_core(struct v3_vm_info * vm, int vcore_id, int target_cpu) { int v3_stop_vm(struct v3_vm_info * vm) { + if ((vm->run_state |= VM_RUNNING) && + (vm->run_state != VM_SIMULATING)) { + PrintError("Tried to stop VM in invalid runstate (%d)\n", vm->run_state); + return -1; + } + vm->run_state = VM_STOPPED; // Sanity check to catch any weird execution states @@ -649,6 +655,12 @@ int v3_free_vm(struct v3_vm_info * vm) { int i = 0; // deinitialize guest (free memory, etc...) + if ((vm->run_state != VM_STOPPED) && + (vm->run_state != VM_ERROR)) { + PrintError("Tried to Free VM in invalid runstate (%d)\n", vm->run_state); + return -1; + } + v3_free_vm_devices(vm); // free cores