mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2024-12-22 13:45:20 +00:00
virtio-mem: mem: Simplify 'process_queue'
No functional change. Signed-off-by: Bo Chen <chen.bo@intel.com>
This commit is contained in:
parent
756aebafda
commit
fd9fa2a681
@ -596,28 +596,22 @@ impl MemEpollHandler {
|
|||||||
|
|
||||||
while let Some(mut desc_chain) = self.queue.pop_descriptor_chain(self.mem.memory()) {
|
while let Some(mut desc_chain) = self.queue.pop_descriptor_chain(self.mem.memory()) {
|
||||||
let r = Request::parse(&mut desc_chain)?;
|
let r = Request::parse(&mut desc_chain)?;
|
||||||
let len = match r.req.req_type {
|
let (resp_type, resp_state) = match r.req.req_type {
|
||||||
VIRTIO_MEM_REQ_PLUG => {
|
VIRTIO_MEM_REQ_PLUG => (
|
||||||
let resp_type = self.state_change_request(r.req.addr, r.req.nb_blocks, true);
|
self.state_change_request(r.req.addr, r.req.nb_blocks, true),
|
||||||
r.send_response(desc_chain.memory(), resp_type, 0u16)?
|
0u16,
|
||||||
}
|
),
|
||||||
VIRTIO_MEM_REQ_UNPLUG => {
|
VIRTIO_MEM_REQ_UNPLUG => (
|
||||||
let resp_type = self.state_change_request(r.req.addr, r.req.nb_blocks, false);
|
self.state_change_request(r.req.addr, r.req.nb_blocks, false),
|
||||||
r.send_response(desc_chain.memory(), resp_type, 0u16)?
|
0u16,
|
||||||
}
|
),
|
||||||
VIRTIO_MEM_REQ_UNPLUG_ALL => {
|
VIRTIO_MEM_REQ_UNPLUG_ALL => (self.unplug_all(), 0u16),
|
||||||
let resp_type = self.unplug_all();
|
VIRTIO_MEM_REQ_STATE => self.state_request(r.req.addr, r.req.nb_blocks),
|
||||||
r.send_response(desc_chain.memory(), resp_type, 0u16)?
|
|
||||||
}
|
|
||||||
VIRTIO_MEM_REQ_STATE => {
|
|
||||||
let (resp_type, resp_state) = self.state_request(r.req.addr, r.req.nb_blocks);
|
|
||||||
r.send_response(desc_chain.memory(), resp_type, resp_state)?
|
|
||||||
}
|
|
||||||
_ => {
|
_ => {
|
||||||
return Err(Error::UnkownRequestType(r.req.req_type));
|
return Err(Error::UnkownRequestType(r.req.req_type));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
let len = r.send_response(desc_chain.memory(), resp_type, resp_state)?;
|
||||||
self.queue
|
self.queue
|
||||||
.add_used(desc_chain.memory(), desc_chain.head_index(), len)
|
.add_used(desc_chain.memory(), desc_chain.head_index(), len)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
Loading…
Reference in New Issue
Block a user