In cases of deadlocks, knowing who holds a given CoMutex is really
helpful for debugging. Keeping the information around doesn't cost much
and allows us to add another assertion to keep the code correct, so
let's just add it.
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
*/
typedef struct CoMutex {
bool locked;
+ Coroutine *holder;
CoQueue queue;
} CoMutex;
}
mutex->locked = true;
+ mutex->holder = self;
trace_qemu_co_mutex_lock_return(mutex, self);
}
trace_qemu_co_mutex_unlock_entry(mutex, self);
assert(mutex->locked == true);
+ assert(mutex->holder == self);
assert(qemu_in_coroutine());
mutex->locked = false;
+ mutex->holder = NULL;
qemu_co_queue_next(&mutex->queue);
trace_qemu_co_mutex_unlock_return(mutex, self);