mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2026-08-05 02:19:16 +00:00
Wrap QcowFile in Arc<Mutex<>> to ensure thread safety when multiple virtio queues access the same QCOW2 image concurrently. Previously, each queue received its own QcowSync instance via new_async_io() that shared the underlying QcowFile through Clone. However, cloned QcowFile instances share internal mutable state (L2 cache, reference counts, file seek position) without synchronization, leading to data corruption under concurrent I/O. This change serializes all QCOW2 operations through a mutex, which ensures correctness at the cost of parallelism. A more performant solution would require separating metadata locking from actual I/O operations, tracked in #7560. Related: #7560 Signed-off-by: Anatol Belski <anbelski@linux.microsoft.com>