From 5aeb9f55d190abd9a1d220b12d799a020b9800f1 Mon Sep 17 00:00:00 2001 From: Sebastian Eydam Date: Fri, 20 Mar 2026 16:21:02 +0100 Subject: [PATCH] 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 --- virtio-devices/src/block.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/virtio-devices/src/block.rs b/virtio-devices/src/block.rs index 97d7c58c1..47309dd87 100644 --- a/virtio-devices/src/block.rs +++ b/virtio-devices/src/block.rs @@ -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();