Skip to content

Commit

Permalink
virtio-device: move driver feat hook-up into set dev status
Browse files Browse the repository at this point in the history
Signed-off-by: João Peixoto <joaopeixotooficial@gmail.com>
  • Loading branch information
joaopeixoto13 committed Oct 10, 2024
1 parent 1140db0 commit a722cf2
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions virtio-device/src/virtio_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ use std::sync::Arc;

use log::error;

use crate::status::{ACKNOWLEDGE, DRIVER, FEATURES_OK};
use crate::{VirtioDevice, WithDriverSelect};
use virtio_queue::{Queue, QueueT};

Expand Down Expand Up @@ -183,10 +184,6 @@ where
// Accessing an unknown page has no effect.
_ => features,
};

if page == 0 {
<Self as VirtioDeviceActions>::negotiate_driver_features(self);
}
}

fn device_status(&self) -> u8 {
Expand All @@ -195,6 +192,9 @@ where

fn set_device_status(&mut self, status: u8) {
self.borrow_mut().device_status = status;
if self.borrow_mut().device_status == (ACKNOWLEDGE | DRIVER | FEATURES_OK) {
<Self as VirtioDeviceActions>::negotiate_driver_features(self);
}
}

fn activate(&mut self) -> Result<(), Self::E> {
Expand Down

0 comments on commit a722cf2

Please sign in to comment.