virtio-devices: fix barrier handling in virtio-blk

When configuring multiple queues for a virtio device, the guest can
activate between 1 and the configured amount of queues. The firmware,
for example, may activate only one queue, while a Linux guest would
likely activate all available queues.

The constructor of virtio-blk initializes the `paused_sync` barrier
using the configured queue count (plus one for the main thread). This
can be wrong if the guest enable a different number of queues at
activation time, which can make pause hang. Thus, we now recompute the
barrier size from the queues that are actually activated.

On-behalf-of: SAP sebastian.eydam@sap.com
Signed-off-by: Sebastian Eydam <sebastian.eydam@cyberus-technology.de>
This commit is contained in:
Sebastian Eydam
2026-03-20 16:21:02 +01:00
committed by Rob Bradford
parent 882f82f04b
commit 5aeb9f55d1

View File

@@ -1087,6 +1087,9 @@ impl VirtioDevice for Block {
}
self.common.activate(&queues, interrupt_cb.clone())?;
// Recompute the barrier size from the queues that are actually activated.
self.common.paused_sync = Some(Arc::new(Barrier::new(queues.len() + 1)));
self.update_writeback();
let mut epoll_threads = Vec::new();