X-Git-Url: http://v3vee.org/palacios/gitweb/gitweb.cgi?a=blobdiff_plain;f=palacios%2Fsrc%2Fpalacios%2Fvmm_host_events.c;h=ec54c65ac7a517b96e70e10fc541af76d16b6584;hb=2fb33705f951901f43a9fed966e96074fc693609;hp=58ac6eae7eae1ae1c6f39c82ce07e2421e2d9ab8;hpb=266af4b5b19da7bee8e7445288c7c1cb3ee194c7;p=palacios.releases.git diff --git a/palacios/src/palacios/vmm_host_events.c b/palacios/src/palacios/vmm_host_events.c index 58ac6ea..ec54c65 100644 --- a/palacios/src/palacios/vmm_host_events.c +++ b/palacios/src/palacios/vmm_host_events.c @@ -19,10 +19,11 @@ #include #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 +33,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)); @@ -59,19 +60,32 @@ int v3_hook_host_event(struct guest_info * info, case HOST_TIMER_EVT: list_add(&(hook->link), &(host_evts->timer_events)); break; + case HOST_CONSLE_EVT: + list_add(&(hook->link), &(host_evts->console_events)); + break; } return 0; } -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 = 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; + } + 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 +94,23 @@ 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 = 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; + } + 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,16 +119,51 @@ 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 = 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; + } + 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; + } + } + + return 0; +} + +int v3_deliver_console_event(struct v3_vm_info * vm, + struct v3_console_event * evt) { + 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; + } + + list_for_each_entry(hook, &(host_evts->console_events), link) { + if (hook->cb.console_handler(vm, evt, hook->private_data) == -1) { return -1; } } return 0; } +