X-Git-Url: http://v3vee.org/palacios/gitweb/gitweb.cgi?a=blobdiff_plain;f=palacios%2Fsrc%2Fpalacios%2Fvmm_host_events.c;h=f872149fbce7709072dc0ae0e18a095ee8b3423b;hb=c3cc58c287fd4a912919c4546f41026c571b13ec;hp=5e6baf2d028a8552e9988be56c61b961e58efecc;hpb=43347a912eba44cae132d01668d45743702f3148;p=palacios.git diff --git a/palacios/src/palacios/vmm_host_events.c b/palacios/src/palacios/vmm_host_events.c index 5e6baf2..f872149 100644 --- a/palacios/src/palacios/vmm_host_events.c +++ b/palacios/src/palacios/vmm_host_events.c @@ -20,6 +20,7 @@ #include #include #include +#include int v3_init_host_events(struct v3_vm_info * vm) { struct v3_host_events * host_evts = &(vm->host_event_hooks); @@ -67,9 +68,15 @@ int v3_hook_host_event(struct v3_vm_info * vm, int v3_deliver_keyboard_event(struct v3_vm_info * vm, struct v3_keyboard_event * evt) { - struct v3_host_events * host_evts = &(vm->host_event_hooks); + struct v3_host_events * host_evts = NULL; struct v3_host_event_hook * hook = NULL; + if (vm == NULL) { + vm = v3_get_foreground_vm(); + } + + host_evts = &(vm->host_event_hooks); + if (vm->run_state != VM_RUNNING) { return -1; } @@ -86,9 +93,15 @@ int v3_deliver_keyboard_event(struct v3_vm_info * vm, int v3_deliver_mouse_event(struct v3_vm_info * vm, struct v3_mouse_event * evt) { - struct v3_host_events * host_evts = &(vm->host_event_hooks); + struct v3_host_events * host_evts = NULL; struct v3_host_event_hook * hook = NULL; + if (vm == NULL) { + vm = v3_get_foreground_vm(); + } + + host_evts = &(vm->host_event_hooks); + if (vm->run_state != VM_RUNNING) { return -1; } @@ -105,9 +118,15 @@ int v3_deliver_mouse_event(struct v3_vm_info * vm, int v3_deliver_timer_event(struct v3_vm_info * vm, struct v3_timer_event * evt) { - struct v3_host_events * host_evts = &(vm->host_event_hooks); + struct v3_host_events * host_evts = NULL; struct v3_host_event_hook * hook = NULL; + if (vm == NULL) { + vm = v3_get_foreground_vm(); + } + + host_evts = &(vm->host_event_hooks); + if (vm->run_state != VM_RUNNING) { return -1; }