virtio-devices: Use asynchronous traits for virtio-blk io_uring

Based on the new DiskFile and AsyncIo traits, the implementation of
asynchronous block support does not have to be tied to io_uring anymore.
Instead, the only thing the virtio-blk implementation knows is that it
is using an asynchronous implementation of the underlying disk file.

Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
This commit is contained in:
Sebastien Boeuf
2021-01-20 10:58:30 +01:00
committed by Rob Bradford
parent 23e3b022eb
commit da8ce25abf
3 changed files with 57 additions and 100 deletions

View File

@@ -38,7 +38,7 @@ use arch::layout;
use arch::layout::{APIC_START, IOAPIC_SIZE, IOAPIC_START};
#[cfg(target_arch = "aarch64")]
use arch::DeviceType;
use block_util::block_io_uring_is_supported;
use block_util::{async_io::DiskFile, block_io_uring_is_supported, raw_async::RawFileDisk};
#[cfg(target_arch = "aarch64")]
use devices::gic;
#[cfg(target_arch = "x86_64")]
@@ -1655,6 +1655,7 @@ impl DeviceManager {
// Use asynchronous backend relying on io_uring if the
// syscalls are supported.
if block_io_uring_is_supported() && !disk_cfg.disable_io_uring {
let image = Box::new(RawFileDisk::new(image)) as Box<dyn DiskFile>;
let dev = Arc::new(Mutex::new(
virtio_devices::BlockIoUring::new(
id.clone(),