Skip to content

Commit a722cf2

Browse files
committed
virtio-device: move driver feat hook-up into set dev status
Signed-off-by: João Peixoto <joaopeixotooficial@gmail.com>
1 parent 1140db0 commit a722cf2

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

virtio-device/src/virtio_config.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ use std::sync::Arc;
1010

1111
use log::error;
1212

13+
use crate::status::{ACKNOWLEDGE, DRIVER, FEATURES_OK};
1314
use crate::{VirtioDevice, WithDriverSelect};
1415
use virtio_queue::{Queue, QueueT};
1516

@@ -183,10 +184,6 @@ where
183184
// Accessing an unknown page has no effect.
184185
_ => features,
185186
};
186-
187-
if page == 0 {
188-
<Self as VirtioDeviceActions>::negotiate_driver_features(self);
189-
}
190187
}
191188

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

196193
fn set_device_status(&mut self, status: u8) {
197194
self.borrow_mut().device_status = status;
195+
if self.borrow_mut().device_status == (ACKNOWLEDGE | DRIVER | FEATURES_OK) {
196+
<Self as VirtioDeviceActions>::negotiate_driver_features(self);
197+
}
198198
}
199199

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

0 commit comments

Comments
 (0)