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