vhost-user: fix SlaveReqHandler::set_config()
Fix a bug in SlaveReqHandler::set_config(), it should remove the message header of the buffer passed to backend. Signed-off-by: Liu Jiang <gerry@linux.alibaba.com>
This commit is contained in:
parent
45f026046b
commit
0d2acd505d
4 changed files with 10 additions and 4 deletions
|
|
@ -1 +1 @@
|
|||
{"coverage_score": 80.2, "exclude_path": "src/vhost_kern/", "crate_features": "vhost-user-master,vhost-user-slave"}
|
||||
{"coverage_score": 80.3, "exclude_path": "src/vhost_kern/", "crate_features": "vhost-user-master,vhost-user-slave"}
|
||||
|
|
|
|||
|
|
@ -218,6 +218,8 @@ impl VhostUserSlaveReqHandlerMut for DummySlaveReqHandler {
|
|||
{
|
||||
return Err(Error::InvalidParam);
|
||||
}
|
||||
assert_eq!(offset, 0x100);
|
||||
assert_eq!(size, 4);
|
||||
Ok(vec![0xa5; size as usize])
|
||||
}
|
||||
|
||||
|
|
@ -231,6 +233,9 @@ impl VhostUserSlaveReqHandlerMut for DummySlaveReqHandler {
|
|||
{
|
||||
return Err(Error::InvalidParam);
|
||||
}
|
||||
assert_eq!(offset, 0x100);
|
||||
assert_eq!(buf.len(), 4);
|
||||
assert_eq!(buf, &[0xa5; 4]);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -419,7 +419,7 @@ mod tests {
|
|||
master.set_mem_table(&mem).unwrap();
|
||||
|
||||
master
|
||||
.set_config(0x100, VhostUserConfigFlags::WRITABLE, &[0xa5u8])
|
||||
.set_config(0x100, VhostUserConfigFlags::WRITABLE, &[0xa5u8; 4])
|
||||
.unwrap();
|
||||
let buf = [0x0u8; 4];
|
||||
let (reply_body, reply_payload) = master
|
||||
|
|
@ -427,7 +427,7 @@ mod tests {
|
|||
.unwrap();
|
||||
let offset = reply_body.offset;
|
||||
assert_eq!(offset, 0x100);
|
||||
assert_eq!(reply_payload[0], 0xa5);
|
||||
assert_eq!(&reply_payload, &[0xa5; 4]);
|
||||
|
||||
master.set_slave_request_fd(&eventfd).unwrap();
|
||||
master.set_vring_enable(0, true).unwrap();
|
||||
|
|
|
|||
|
|
@ -634,7 +634,8 @@ impl<S: VhostUserSlaveReqHandler> SlaveReqHandler<S> {
|
|||
None => return Err(Error::InvalidMessage),
|
||||
}
|
||||
|
||||
self.backend.set_config(msg.offset, buf, flags)
|
||||
self.backend
|
||||
.set_config(msg.offset, &buf[mem::size_of::<VhostUserConfig>()..], flags)
|
||||
}
|
||||
|
||||
fn set_slave_req_fd(&mut self, files: Option<Vec<File>>) -> Result<()> {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue