X-Git-Url: http://v3vee.org/palacios/gitweb/gitweb.cgi?a=blobdiff_plain;f=palacios%2Fsrc%2Fpalacios%2Fvmm_host_events.c;h=5e6baf2d028a8552e9988be56c61b961e58efecc;hb=58a5fd180f52b2d9e15c3613324c17123672ee19;hp=58ac6eae7eae1ae1c6f39c82ce07e2421e2d9ab8;hpb=266af4b5b19da7bee8e7445288c7c1cb3ee194c7;p=palacios.git diff --git a/palacios/src/palacios/vmm_host_events.c b/palacios/src/palacios/vmm_host_events.c index 58ac6ea..5e6baf2 100644 --- a/palacios/src/palacios/vmm_host_events.c +++ b/palacios/src/palacios/vmm_host_events.c @@ -19,10 +19,10 @@ #include #include +#include - -int v3_init_host_events(struct guest_info * info) { - struct v3_host_events * host_evts = &(info->host_event_hooks); +int v3_init_host_events(struct v3_vm_info * vm) { + struct v3_host_events * host_evts = &(vm->host_event_hooks); INIT_LIST_HEAD(&(host_evts->keyboard_events)); INIT_LIST_HEAD(&(host_evts->mouse_events)); @@ -32,12 +32,12 @@ int v3_init_host_events(struct guest_info * info) { } -int v3_hook_host_event(struct guest_info * info, +int v3_hook_host_event(struct v3_vm_info * vm, v3_host_evt_type_t event_type, union v3_host_event_handler cb, void * private_data) { - struct v3_host_events * host_evts = &(info->host_event_hooks); + struct v3_host_events * host_evts = &(vm->host_event_hooks); struct v3_host_event_hook * hook = NULL; hook = (struct v3_host_event_hook *)V3_Malloc(sizeof(struct v3_host_event_hook)); @@ -65,13 +65,17 @@ int v3_hook_host_event(struct guest_info * info, } -int v3_deliver_keyboard_event(struct guest_info * info, +int v3_deliver_keyboard_event(struct v3_vm_info * vm, struct v3_keyboard_event * evt) { - struct v3_host_events * host_evts = &(info->host_event_hooks); + struct v3_host_events * host_evts = &(vm->host_event_hooks); struct v3_host_event_hook * hook = NULL; + if (vm->run_state != VM_RUNNING) { + return -1; + } + list_for_each_entry(hook, &(host_evts->keyboard_events), link) { - if (hook->cb.keyboard_handler(info, evt, hook->private_data) == -1) { + if (hook->cb.keyboard_handler(vm, evt, hook->private_data) == -1) { return -1; } } @@ -80,13 +84,17 @@ int v3_deliver_keyboard_event(struct guest_info * info, } -int v3_deliver_mouse_event(struct guest_info * info, +int v3_deliver_mouse_event(struct v3_vm_info * vm, struct v3_mouse_event * evt) { - struct v3_host_events * host_evts = &(info->host_event_hooks); + struct v3_host_events * host_evts = &(vm->host_event_hooks); struct v3_host_event_hook * hook = NULL; + if (vm->run_state != VM_RUNNING) { + return -1; + } + list_for_each_entry(hook, &(host_evts->mouse_events), link) { - if (hook->cb.mouse_handler(info, evt, hook->private_data) == -1) { + if (hook->cb.mouse_handler(vm, evt, hook->private_data) == -1) { return -1; } } @@ -95,13 +103,17 @@ int v3_deliver_mouse_event(struct guest_info * info, } -int v3_deliver_timer_event(struct guest_info * info, +int v3_deliver_timer_event(struct v3_vm_info * vm, struct v3_timer_event * evt) { - struct v3_host_events * host_evts = &(info->host_event_hooks); + struct v3_host_events * host_evts = &(vm->host_event_hooks); struct v3_host_event_hook * hook = NULL; + if (vm->run_state != VM_RUNNING) { + return -1; + } + list_for_each_entry(hook, &(host_evts->timer_events), link) { - if (hook->cb.timer_handler(info, evt, hook->private_data) == -1) { + if (hook->cb.timer_handler(vm, evt, hook->private_data) == -1) { return -1; } }