diff --git a/src/virtio/src/block/virtio/device.rs b/src/virtio/src/block/virtio/device.rs index ea4c746..025d23e 100644 --- a/src/virtio/src/block/virtio/device.rs +++ b/src/virtio/src/block/virtio/device.rs @@ -15,6 +15,7 @@ use event_manager::{ use std::borrow::{Borrow, BorrowMut}; use std::sync::{Arc, Mutex}; use virtio_bindings::virtio_blk::{VIRTIO_BLK_F_FLUSH, VIRTIO_BLK_F_RO}; +use virtio_bindings::virtio_config::VIRTIO_F_IN_ORDER; use virtio_blk::stdio_executor::StdIoBackend; use virtio_device::{VirtioConfig, VirtioDeviceActions, VirtioDeviceType, VirtioMmioDevice}; use virtio_queue::Queue; @@ -94,7 +95,7 @@ impl VirtioDeviceT for VirtioBlock { } fn device_features(config: &DeviceConfig) -> Result { - let mut features = 0; + let mut features = 1 << VIRTIO_F_IN_ORDER; // Set the read-only feature. if config.read_only.unwrap() { diff --git a/src/virtio/src/console/virtio/device.rs b/src/virtio/src/console/virtio/device.rs index a372921..c05804a 100644 --- a/src/virtio/src/console/virtio/device.rs +++ b/src/virtio/src/console/virtio/device.rs @@ -10,6 +10,7 @@ use event_manager::{ }; use std::borrow::{Borrow, BorrowMut}; use std::sync::{Arc, Mutex}; +use virtio_bindings::virtio_config::VIRTIO_F_IN_ORDER; use virtio_console::console::Console; use virtio_device::{VirtioConfig, VirtioDeviceActions, VirtioDeviceType, VirtioMmioDevice}; use virtio_queue::Queue; @@ -74,7 +75,7 @@ impl VirtioDeviceT for VirtioConsole { } fn device_features(_config: &DeviceConfig) -> Result { - Ok(0) + Ok(1 << VIRTIO_F_IN_ORDER) } fn config_space(_config: &DeviceConfig) -> Result> { diff --git a/src/virtio/src/device.rs b/src/virtio/src/device.rs index ddaf21a..1c2e250 100644 --- a/src/virtio/src/device.rs +++ b/src/virtio/src/device.rs @@ -27,12 +27,7 @@ use vm_device::device_manager::IoManager; use vm_memory::{guest_memory::FileOffset, GuestAddress, MmapRegion}; use vmm_sys_util::eventfd::{EventFd, EFD_NONBLOCK}; -use virtio_bindings::virtio_config::{ - VIRTIO_F_IN_ORDER, VIRTIO_F_IOMMU_PLATFORM, VIRTIO_F_VERSION_1, -}; - -/// This feature enables the used_event and the avail_event (Notification Suppression). -pub const VIRTIO_F_RING_EVENT_IDX: u32 = 29; +use virtio_bindings::virtio_config::{VIRTIO_F_IOMMU_PLATFORM, VIRTIO_F_VERSION_1}; /// Type alias for the subscriber. pub type Subscriber = Arc>; @@ -269,7 +264,7 @@ pub trait VirtioDeviceT { .unwrap(); // Define the generic device features. - let device_features = 1 << VIRTIO_F_VERSION_1 | 1 << VIRTIO_F_IOMMU_PLATFORM | 1 << VIRTIO_F_IN_ORDER /*| 1 << VIRTIO_F_RING_EVENT_IDX*/; + let device_features = 1 << VIRTIO_F_VERSION_1 | 1 << VIRTIO_F_IOMMU_PLATFORM; Ok((device_features, queues_converted)) } diff --git a/src/virtio/src/net/vhost/device.rs b/src/virtio/src/net/vhost/device.rs index c6c7930..d95ef9b 100644 --- a/src/virtio/src/net/vhost/device.rs +++ b/src/virtio/src/net/vhost/device.rs @@ -176,11 +176,13 @@ impl VirtioDeviceActions for VhostNet { // Set the current process as the owner of the file descriptor. self.net.set_owner().unwrap(); + // Get the device features. + let supported_backend_features = self.net.get_features().unwrap(); + // Set the device features. - let features = self.net.get_features().unwrap(); - println!("Get Features: {:x}", features); - println!("Set Features: {:x}", self.vhost.features()); - self.net.set_features(self.vhost.features()).unwrap(); + self.net + .set_features(self.vhost.features() & supported_backend_features) + .unwrap(); // Update the memory table. self.net diff --git a/src/virtio/src/vsock/vhost/device.rs b/src/virtio/src/vsock/vhost/device.rs index f35c436..8697a0d 100644 --- a/src/virtio/src/vsock/vhost/device.rs +++ b/src/virtio/src/vsock/vhost/device.rs @@ -140,8 +140,13 @@ impl VirtioDeviceActions for VhostVsockDevice { // Set the current process as the owner of the file descriptor. self.vsock.set_owner().unwrap(); + // Get the device features. + let supported_backend_features = self.vsock.get_features().unwrap(); + // Set the device features. - self.vsock.set_features(self.vhost.features()).unwrap(); + self.vsock + .set_features(self.vhost.features() & supported_backend_features) + .unwrap(); // Update the memory table. self.vsock