mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2026-08-05 02:19:16 +00:00
vm-virtio: Simplify virtio feature handling
Remove duplicated code across the different devices by handling the virtio feature pages in VirtioDevice itself rather than in the backends. This works as no virtio devices use feature bits beyond 64-bits. Signed-off-by: Cathy Zhang <cathy.zhang@intel.com>
This commit is contained in:
committed by
Rob Bradford
parent
411e2b43ba
commit
14eddf72b4
@@ -189,8 +189,12 @@ impl BusDevice for MmioDevice {
|
||||
0x08 => self.device.lock().unwrap().device_type(),
|
||||
0x0c => VENDOR_ID, // vendor id
|
||||
0x10 => {
|
||||
self.device.lock().unwrap().features(self.features_select)
|
||||
| if self.features_select == 1 { 0x1 } else { 0x0 }
|
||||
if self.features_select < 2 {
|
||||
(self.device.lock().unwrap().features() >> (self.features_select * 32))
|
||||
as u32
|
||||
} else {
|
||||
0
|
||||
}
|
||||
}
|
||||
0x34 => self.with_queue(0, |q| u32::from(q.get_max_size())),
|
||||
0x44 => self.with_queue(0, |q| q.ready as u32),
|
||||
@@ -234,11 +238,19 @@ impl BusDevice for MmioDevice {
|
||||
let v = LittleEndian::read_u32(data);
|
||||
match offset {
|
||||
0x14 => self.features_select = v,
|
||||
0x20 => self
|
||||
.device
|
||||
.lock()
|
||||
.unwrap()
|
||||
.ack_features(self.acked_features_select, v),
|
||||
0x20 => {
|
||||
if self.acked_features_select < 2 {
|
||||
self.device
|
||||
.lock()
|
||||
.unwrap()
|
||||
.ack_features(u64::from(v) << (self.acked_features_select * 32));
|
||||
} else {
|
||||
warn!(
|
||||
"invalid ack_features (page {}, value 0x{:x})",
|
||||
self.acked_features_select, v
|
||||
);
|
||||
}
|
||||
}
|
||||
0x24 => self.acked_features_select = v,
|
||||
0x30 => self.queue_select = v,
|
||||
0x38 => mut_q = self.with_queue_mut(|q| q.size = v as u16),
|
||||
|
||||
Reference in New Issue
Block a user