X-Git-Url: http://v3vee.org/palacios/gitweb/gitweb.cgi?a=blobdiff_plain;f=palacios%2Fsrc%2Fpalacios%2Fvmm_events.c;h=c4580eea40276686f1b20240b9793bae755899bb;hb=0246f0904a4800dbe1e8e23332d49b468a58f751;hp=4f705b2d45a37e69cc1ecb5996ba01d13883ba4b;hpb=0c942db0269c98d20875637eab9e97d639f7cda8;p=palacios.git diff --git a/palacios/src/palacios/vmm_events.c b/palacios/src/palacios/vmm_events.c index 4f705b2..c4580ee 100644 --- a/palacios/src/palacios/vmm_events.c +++ b/palacios/src/palacios/vmm_events.c @@ -28,10 +28,10 @@ int v3_init_events(struct v3_vm_info * vm) { struct v3_event_map * map = &(vm->event_map); int i = 0; - map->events = V3_Malloc(sizeof(struct list_head) * V3_EVENT_INVALID); + map->events = V3_Malloc(sizeof(struct list_head) * (V3_EVENT_INVALID+1)); if (map->events == NULL) { - PrintError("Error: could not allocate event map\n"); + PrintError(vm, VCORE_NONE, "Error: could not allocate event map\n"); return -1; } @@ -50,7 +50,7 @@ int v3_deinit_events(struct v3_vm_info * vm) { if (!list_empty(&(map->events[i]))) { struct v3_notifier * tmp_notifier = NULL; struct v3_notifier * safe_notifier = NULL; - PrintError("Found orphan notifier for event %d. Probable memory leak detected.\n", i); + PrintError(vm, VCORE_NONE, "Found orphan notifier for event %d. Probable memory leak detected.\n", i); list_for_each_entry_safe(tmp_notifier, safe_notifier, &(map->events[i]), node) { list_del(&(tmp_notifier->node)); @@ -79,14 +79,14 @@ struct v3_notifier * v3_subscribe_event(struct v3_vm_info * vm, struct v3_notifier * notifier = NULL; if (event_type >= V3_EVENT_INVALID) { - PrintError("Tried to request illegal event (%d)\n", event_type); + PrintError(vm, VCORE_NONE, "Tried to request illegal event (%d)\n", event_type); return NULL; } notifier = V3_Malloc(sizeof(struct v3_notifier)); if (notifier == NULL) { - PrintError("Error: Could not allocate notifier\n"); + PrintError(vm, VCORE_NONE, "Error: Could not allocate notifier\n"); return NULL; } @@ -96,15 +96,9 @@ struct v3_notifier * v3_subscribe_event(struct v3_vm_info * vm, notifier->priv_data = priv_data; notifier->event_type = event_type; - if ((vm->run_state == VM_RUNNING) || - (vm->run_state == VM_SIMULATING)) { - while (v3_raise_barrier(vm, current_core) == -1); - list_add(&(notifier->node), &(map->events[event_type])); - v3_lower_barrier(vm); - } else { - // No need to lock the list - list_add(&(notifier->node), &(map->events[event_type])); - } + while (v3_raise_barrier(vm, current_core) == -1); + list_add(&(notifier->node), &(map->events[event_type])); + v3_lower_barrier(vm); return notifier;; } @@ -117,33 +111,23 @@ int v3_unsubscribe_event(struct v3_vm_info * vm, struct v3_notifier * notifier, struct v3_notifier * safe_notifier = NULL; if (notifier == NULL) { - PrintError("Could not unsubscribe invalid event notifier\n"); + PrintError(vm, VCORE_NONE, "Could not unsubscribe invalid event notifier\n"); return -1; } if (notifier->event_type >= V3_EVENT_INVALID) { - PrintError("Could not unsubscribe from invalid event\n"); + PrintError(vm, VCORE_NONE, "Could not unsubscribe from invalid event\n"); return -1; } - if ((vm->run_state == VM_RUNNING) || - (vm->run_state == VM_SIMULATING)) { - while (v3_raise_barrier(vm, current_core) == -1); - } - - + while (v3_raise_barrier(vm, current_core) == -1); list_for_each_entry_safe(tmp_notifier, safe_notifier, &(map->events[notifier->event_type]), node) { if (tmp_notifier == notifier) { list_del(&(tmp_notifier->node)); V3_Free(tmp_notifier); } } - - - if ((vm->run_state == VM_RUNNING) || - (vm->run_state == VM_SIMULATING)) { - v3_lower_barrier(vm); - } + v3_lower_barrier(vm); return 0; }