Master: add get_config()/set_config() support#3
Open
yangzhon wants to merge 1 commit intojiangliu:v1from
Open
Conversation
jiangliu
reviewed
Sep 4, 2019
src/vhost_user/master.rs
Outdated
| // 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); |
Owner
There was a problem hiding this comment.
this may be simplified as
let buf = vec![0u8; body.size as usize];
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
@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