MCPcopy Create free account
hub / github.com/cloud-hypervisor/cloud-hypervisor / read

Method read

vmm/src/cpu.rs:3205–3236  ·  view source on GitHub ↗
(&mut self, _base: u64, offset: u64, data: &mut [u8])

Source from the content-addressed store, hash-verified

3203
3204impl BusDevice for AcpiCpuHotplugController {
3205 fn read(&mut self, _base: u64, offset: u64, data: &mut [u8]) {
3206 // The Linux kernel, quite reasonably, doesn't zero the memory it gives us.
3207 data.fill(0);
3208 let vcpu_states = self.vcpu_states.lock().unwrap();
3209
3210 match offset {
3211 Self::CPU_SELECTION_OFFSET => {
3212 assert!(data.len() >= core::mem::size_of::<u32>());
3213 data[0..core::mem::size_of::<u32>()]
3214 .copy_from_slice(&self.selected_cpu.to_le_bytes());
3215 }
3216 Self::CPU_STATUS_OFFSET => {
3217 if self.selected_cpu < self.max_vcpus {
3218 let state = &vcpu_states[usize::try_from(self.selected_cpu).unwrap()];
3219 if state.active() {
3220 data[0] |= 1 << Self::CPU_ENABLE_FLAG;
3221 }
3222 if state.inserting {
3223 data[0] |= 1 << Self::CPU_INSERTING_FLAG;
3224 }
3225 if state.removing {
3226 data[0] |= 1 << Self::CPU_REMOVING_FLAG;
3227 }
3228 } else {
3229 warn!("Out of range vCPU id: {}", self.selected_cpu);
3230 }
3231 }
3232 _ => {
3233 warn!("Unexpected offset for accessing CPU manager device: {offset:#}");
3234 }
3235 }
3236 }
3237
3238 fn write(&mut self, _base: u64, offset: u64, data: &[u8]) -> Option<Arc<Barrier>> {
3239 match offset {

Callers 15

control_loopMethod · 0.45
vm_rebootMethod · 0.45
wait_for_stop_reasonMethod · 0.45
try_dev_userfaultfdFunction · 0.45
translate_gvaMethod · 0.45
read_memMethod · 0.45
create_ptyFunction · 0.45
guest_mem_readMethod · 0.45
mmio_readMethod · 0.45
pio_readMethod · 0.45
get_dump_stateMethod · 0.45
sendMethod · 0.45

Calls 1

activeMethod · 0.80

Tested by

no test coverage detected