(
&mut self,
guest_memory: &GuestMemoryAtomic<GuestMemoryMmap<AtomicBitmap>>,
command: PvmemcontrolTransportCommand,
)
| 344 | } |
| 345 | |
| 346 | fn run_command( |
| 347 | &mut self, |
| 348 | guest_memory: &GuestMemoryAtomic<GuestMemoryMmap<AtomicBitmap>>, |
| 349 | command: PvmemcontrolTransportCommand, |
| 350 | ) { |
| 351 | let state = std::mem::replace(&mut self.state, PvmemcontrolState::Broken); |
| 352 | |
| 353 | *self = match command { |
| 354 | PvmemcontrolTransportCommand::Reset => Self::reset(), |
| 355 | PvmemcontrolTransportCommand::Register => { |
| 356 | if let PvmemcontrolState::PercpuInit(state) = state { |
| 357 | // SAFETY: By device protocol. If driver is wrong the device |
| 358 | // can enter a Broken state, but the behavior is still sound. |
| 359 | Self::register_percpu_buf(guest_memory, state, unsafe { |
| 360 | self.transport.as_register() |
| 361 | }) |
| 362 | } else { |
| 363 | debug!("received register without reset"); |
| 364 | Self::error() |
| 365 | } |
| 366 | } |
| 367 | PvmemcontrolTransportCommand::Ready => { |
| 368 | if let PvmemcontrolState::PercpuInit(state) = state { |
| 369 | Self::ready(state) |
| 370 | } else { |
| 371 | debug!("received ready without reset"); |
| 372 | Self::error() |
| 373 | } |
| 374 | } |
| 375 | PvmemcontrolTransportCommand::Disconnect => Self::error(), |
| 376 | PvmemcontrolTransportCommand::Ack => { |
| 377 | debug!("received ack as command"); |
| 378 | Self::error() |
| 379 | } |
| 380 | PvmemcontrolTransportCommand::Error => { |
| 381 | debug!("received error as command"); |
| 382 | Self::error() |
| 383 | } |
| 384 | } |
| 385 | } |
| 386 | |
| 387 | /// read from the transport |
| 388 | fn read_transport(&self, offset: u64, data: &mut [u8]) { |
no test coverage detected