From 85556951a6964fb416f0d5aa4df4d1cb8eac1e89 Mon Sep 17 00:00:00 2001 From: Wei Liu Date: Sat, 29 Nov 2025 20:07:24 +0000 Subject: [PATCH] block: qcow2: Flush the buffer explicitly when writing pointer table Previously the code relies on the implicit flush when BufWriter is dropped. That's not safe. Per BufWriter's document: ``` It is critical to call flush before BufWriter is dropped. Though dropping will attempt to flush the contents of the buffer, any errors that happen in the process of dropping will be ignored. Calling flush ensures that the buffer is empty and thus dropping will not even attempt file operations. ``` Signed-off-by: Wei Liu --- block/src/qcow/qcow_raw_file.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/block/src/qcow/qcow_raw_file.rs b/block/src/qcow/qcow_raw_file.rs index ceebfd1a9..d3a9ad7ab 100644 --- a/block/src/qcow/qcow_raw_file.rs +++ b/block/src/qcow/qcow_raw_file.rs @@ -80,6 +80,7 @@ impl QcowRawFile { }; buffer.write_u64::(val)?; } + buffer.flush()?; Ok(()) }