From e0a8da2f46c35bb28b428ed3b4054fdadb482f02 Mon Sep 17 00:00:00 2001 From: Sergio Lopez Date: Thu, 16 Jan 2020 13:13:32 +0100 Subject: [PATCH] vhost_user_blk: Add missing WCE property support Add missing WCE (write-cache enable) property support. This not only an enhancement, but also a fix for a bug. Right now, when vhost_user_blk uses a qcow2 image, it doesn't write the QCOW2 metadata until the guest explicitly requests a flush. In practice, this is equivalent to the write back semantic. Without WCE, the guest assumes write through for the virtio_blk device, and doesn't send those flush requests. Adding support for WCE, and enabling it by default, we ensure the guest does send said requests. Supporting "WCE = false" would require updating our qcow2 implementation to ensure that, when required, it honors the write through semantics by not deferring the updates to QCOW2 metadata. Signed-off-by: Sergio Lopez --- src/bin/vhost_user_blk.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/bin/vhost_user_blk.rs b/src/bin/vhost_user_blk.rs index b5c6481d8..b1e314eae 100644 --- a/src/bin/vhost_user_blk.rs +++ b/src/bin/vhost_user_blk.rs @@ -107,6 +107,7 @@ impl VhostUserBlkBackend { config.min_io_size = 1; config.opt_io_size = 1; config.num_queues = 1; + config.wce = 1; Ok(VhostUserBlkBackend { mem: None, @@ -173,6 +174,7 @@ impl VhostUserBackend for VhostUserBlkBackend { fn features(&self) -> u64 { let mut avail_features = 1 << VIRTIO_BLK_F_MQ + | 1 << VIRTIO_BLK_F_CONFIG_WCE | 1 << VIRTIO_F_VERSION_1 | VhostUserVirtioFeatures::PROTOCOL_FEATURES.bits();