mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2024-07-15 13:47:14 +00:00
vhost-user-blk: enable write_config for WCE
In vhost-user-blk, only WCE value can be set back to device in guest kernel like echo "write through" > /sys/block/vda/cache_type So write_config() will only set WCE value from guest kernel to vhost user side. Signed-off-by: Yang Zhong <yang.zhong@intel.com>
This commit is contained in:
parent
39083d705b
commit
360980d93c
@ -61,6 +61,10 @@ impl<'a> Blk {
|
|||||||
| 1 << VIRTIO_F_VERSION_1
|
| 1 << VIRTIO_F_VERSION_1
|
||||||
| VhostUserVirtioFeatures::PROTOCOL_FEATURES.bits();
|
| VhostUserVirtioFeatures::PROTOCOL_FEATURES.bits();
|
||||||
|
|
||||||
|
if wce {
|
||||||
|
avail_features |= 1 << VIRTIO_BLK_F_CONFIG_WCE;
|
||||||
|
}
|
||||||
|
|
||||||
// Set vhost-user owner.
|
// Set vhost-user owner.
|
||||||
vhost_user_blk
|
vhost_user_blk
|
||||||
.set_owner()
|
.set_owner()
|
||||||
@ -190,8 +194,15 @@ impl VirtioDevice for Blk {
|
|||||||
error!("Failed to write config space");
|
error!("Failed to write config space");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
let (_, right) = self.config_space.split_at_mut(offset as usize);
|
// In fact, write_config() only handle wce value in vhost-user-blk.
|
||||||
right.copy_from_slice(&data[..]);
|
// so, we can only set wce value here.
|
||||||
|
if self.config_space[offset as usize] == data[0] {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
self.vhost_user_blk
|
||||||
|
.set_config(offset as u32, VhostUserConfigFlags::WRITABLE, data)
|
||||||
|
.expect("Failed to set config");
|
||||||
|
self.config_space[offset as usize] = data[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
fn activate(
|
fn activate(
|
||||||
|
Loading…
Reference in New Issue
Block a user