mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2025-01-21 20:15:21 +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 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);
|
||||
// only setnum_queues value.
|
||||
config_space[queue_num_offset] = vu_cfg.num_queues as u8;
|
||||
// Only set num_queues value(u16).
|
||||
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 {
|
||||
vhost_user_blk,
|
||||
|
Loading…
x
Reference in New Issue
Block a user