mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2026-08-05 02:19:16 +00:00
block: Move request code to its own module
There is no reason for most of the Request struct to be writable from anywhere in the codebase. Encapsulate it. Use getter functions for access outside the request module. Replace the trivial setter for the writeback field with direct assignment. No functional change intended. Signed-off-by: Demi Marie Obenour <demiobenour@gmail.com>
This commit is contained in:
committed by
Bo Chen
parent
8f972567d0
commit
7c44f49293
@@ -131,14 +131,14 @@ impl VhostUserBlkThread {
|
||||
let len = match Request::parse(&mut desc_chain, None) {
|
||||
Ok(mut request) => {
|
||||
debug!("element is a valid request");
|
||||
request.set_writeback(self.writeback.load(Ordering::Acquire));
|
||||
request.writeback = self.writeback.load(Ordering::Acquire);
|
||||
let (status, len) = match request.execute(
|
||||
&mut self.disk_image.lock().unwrap().deref_mut(),
|
||||
self.disk_nsectors,
|
||||
desc_chain.memory(),
|
||||
&self.serial,
|
||||
) {
|
||||
Ok(_) if request.request_type == RequestType::GetDeviceId => {
|
||||
Ok(_) if request.request_type() == RequestType::GetDeviceId => {
|
||||
(VIRTIO_BLK_S_OK as u8, self.serial.len() as u32 + 1)
|
||||
}
|
||||
Ok(l) => (VIRTIO_BLK_S_OK as u8, l + 1),
|
||||
@@ -146,7 +146,7 @@ impl VhostUserBlkThread {
|
||||
};
|
||||
desc_chain
|
||||
.memory()
|
||||
.write_obj(status, request.status_addr)
|
||||
.write_obj(status, request.status_addr())
|
||||
.unwrap();
|
||||
len
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user