X-Git-Url: http://v3vee.org/palacios/gitweb/gitweb.cgi?a=blobdiff_plain;f=palacios%2Fsrc%2Fpalacios%2Fvmm_queue.c;h=a4b5144cddd800c3f67a74919449ec8b71e33d36;hb=774bac9fbb03ef8bf7c2ca2c79a8b87c9bc4c526;hp=20fa255ac22bb5f2aa0c78e954c3449a9279830f;hpb=7451192e943534bd52f3f61dae1d7e9ec4317b30;p=palacios.git diff --git a/palacios/src/palacios/vmm_queue.c b/palacios/src/palacios/vmm_queue.c index 20fa255..a4b5144 100644 --- a/palacios/src/palacios/vmm_queue.c +++ b/palacios/src/palacios/vmm_queue.c @@ -19,6 +19,9 @@ #include + + + void v3_init_queue(struct v3_queue * queue) { queue->num_entries = 0; INIT_LIST_HEAD(&(queue->entries)); @@ -27,14 +30,36 @@ void v3_init_queue(struct v3_queue * queue) { struct v3_queue * v3_create_queue() { struct v3_queue * tmp_queue = V3_Malloc(sizeof(struct v3_queue)); + + if (!tmp_queue) { + PrintError(VM_NONE, VCORE_NONE,"Cannot allocate a queue\n"); + return NULL; + } + v3_init_queue(tmp_queue); return tmp_queue; } +void v3_deinit_queue(struct v3_queue * queue) { + while (v3_dequeue(queue)) { + PrintError(VM_NONE, VCORE_NONE,"ERROR: Freeing non-empty queue. PROBABLE MEMORY LEAK DETECTED\n"); + } + + v3_lock_deinit(&(queue->lock)); +} + + + + void v3_enqueue(struct v3_queue * queue, addr_t entry) { struct v3_queue_entry * q_entry = V3_Malloc(sizeof(struct v3_queue_entry)); unsigned int flags = 0; + if (!q_entry) { + PrintError(VM_NONE, VCORE_NONE,"Cannot allocate a queue entry for enqueue\n"); + return ; + } + flags = v3_lock_irqsave(queue->lock); q_entry->entry = entry; list_add_tail(&(q_entry->entry_list), &(queue->entries));