qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] thread synchronization in qcow2.c and qcow2-cluster.c


From: Chunqiang (CQ) Tang
Subject: [Qemu-devel] thread synchronization in qcow2.c and qcow2-cluster.c
Date: Tue, 27 Apr 2010 12:06:17 -0400

Hi there,

I just started to read the code of qemu-kvm-0.12.3 recently, and was
puzzled by the thread synchronization issue in qcow2.c and
qcow2-cluster.c. Could someone please enlighten me? Thanks!

Specifically, I found that BDRVQcowState.cluster_allocs, which is a
QLIST_HEAD, may be accessed concurrently by two threads, but I could
not figure out how the two thread synchronize with each other to avoid
race conditions (e.g., through a lock?).

Stack trace of thread 1:
main -> main_loop -> kvm_main_loop -> main_loop_wait -> posix_aio_read
-> posix_aio_process_queue -> qcow_aio_write_cb ->
qcow2_alloc_cluster_offset (which may modify
BDRVQcowState.cluster_allocs)

Stack trace of thread 2:
ap_main_loop -> ... -> kvm_handle_io -> ... -> qcow_aio_writev ->
qcow_aio_write_cb -> qcow2_alloc_cluster_offset (which may modify
BDRVQcowState.cluster_allocs)

-- 
Best regards,
CQ Tang




reply via email to

[Prev in Thread] Current Thread [Next in Thread]