Skip to content

Conversation

@yangzhon
Copy link

@yangzhon yangzhon commented Sep 3, 2019

@jiangliu

Please help review this PR, and i copied this whole src into our cloud-hypervisor to verify it.

From the guest kernel log, we can get right virtio-blk config info from SPDK backend.

[ 0.171460] -----------blk config value as below:--------------
[ 0.172211] capacity=131072
[ 0.172573] size_max=0
[ 0.172886] seg_max=0
[ 0.173183] blk_size=512
[ 0.173519] physical_block_exp=0
[ 0.173940] alignment_offset=0
[ 0.174347] min_io_size=1
[ 0.174692] opt_io_size=0
[ 0.175045] wce=1
[ 0.175301] num_queues=1
[ 0.175616] max_discard_sectors=32768
[ 0.176092] max_discard_seg=1
[ 0.176473] discard_sector_alignment=1
[ 0.176954] max_write_zeroes_sectors=1
[ 0.177436] max_write_zeroes_seg=1
[ 0.177881] write_zeroes_may_unmap=0
[ 0.179780] virtio_blk virtio2: [vdb] 131072 512-byte logical blocks (67.1 MB/64.0 MiB)

This also can show right vdb info from guest
root@unicorn ~ # lsblk --output "NAME,KNAME,MODEL,HCTL,SIZE,VENDOR,SUBSYSTEMS"
NAME KNAME MODEL HCTL SIZE VENDOR SUBSYSTEMS
sda sda scsi_debug 0:0:0:0 8M Linux block:scsi:pseudo
nullb0 nullb0 250G block
vda vda 8.5G 0x1af4 block:virtio:pci
├─vda1 vda1 511M block:virtio:pci
├─vda2 vda2 32M block:virtio:pci
└─vda3 vda3 8G block:virtio:pci
vdb vdb 64M 0x1af4 block:virtio:pci

// So current implementation doesn't conform to the spec.
let hdr = node.send_request_with_body(MasterReq::GET_CONFIG, &body, None)?;
let mut buf: Vec<u8> = Vec::with_capacity(body.size as usize);
buf.resize(body.size as usize, 0);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this may be simplified as
let buf = vec![0u8; body.size as usize];

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done, thanks

This patch replace send_request_with_payload() with
send_request_with_body() to make get_config work.

From vhost-user Spec:
A vhost-user message consists of 3 header fields and a payload.

+---------+-------+------+---------+
| request | flags | size | payload |
+---------+-------+------+---------+

but for config space, the payload include:

Virtio device config space
^^^^^^^^^^^^^^^^^^^^^^^^^^
+--------+------+-------+---------+
| offset | size | flags | payload |
+--------+------+-------+---------+

Signed-off-by: Yang Zhong <yang.zhong@intel.com>
Signed-off-by: Liu Jiang <gerry@linux.alibaba.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants