mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2024-08-21 07:21:15 +00:00
vhost-user-blk: make read_config work
Since config space in vhost-user-blk are mostly from backend device, this change will get config space info from backend by vhost-user protocol. Signed-off-by: Yang Zhong <yang.zhong@intel.com>
This commit is contained in:
parent
a949ab21f7
commit
39083d705b
@ -94,11 +94,22 @@ impl<'a> Blk {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let config_len = mem::size_of::<virtio_blk_config>();
|
let config_len = mem::size_of::<virtio_blk_config>();
|
||||||
let mut config_space: Vec<u8> = vec![0u8; config_len as usize];
|
let config_space: Vec<u8> = vec![0u8; config_len as usize];
|
||||||
|
|
||||||
|
let (_, mut config_space) = vhost_user_blk
|
||||||
|
.get_config(
|
||||||
|
0,
|
||||||
|
config_len as u32,
|
||||||
|
VhostUserConfigFlags::WRITABLE,
|
||||||
|
config_space.as_slice(),
|
||||||
|
)
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
let queue_num_offset = offset_of!(virtio_blk_config, num_queues);
|
let queue_num_offset = offset_of!(virtio_blk_config, num_queues);
|
||||||
// only setnum_queues value.
|
// Only set num_queues value(u16).
|
||||||
config_space[queue_num_offset] = vu_cfg.num_queues as u8;
|
let num_queues_slice = (vu_cfg.num_queues as u16).to_le_bytes();
|
||||||
|
config_space[queue_num_offset..queue_num_offset + mem::size_of::<u16>()]
|
||||||
|
.copy_from_slice(&num_queues_slice);
|
||||||
|
|
||||||
Ok(Blk {
|
Ok(Blk {
|
||||||
vhost_user_blk,
|
vhost_user_blk,
|
||||||
|
Loading…
Reference in New Issue
Block a user