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 <slp@redhat.com>
This commit is contained in:
Sergio Lopez 2020-01-16 13:13:32 +01:00 committed by Rob Bradford
parent c7e9056c1e
commit e0a8da2f46

View File

@ -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();