From c62227803047d0bf81279cb4aadcf131a194426d Mon Sep 17 00:00:00 2001 From: Rob Bradford Date: Tue, 17 Nov 2020 17:11:53 +0000 Subject: [PATCH] config, device_manager: Add support for disabling io_uring for testing Add config parameter to --disk called "_disable_io_uring" (the underscore prefix indicating it is not for public consumpion.) Use this option to disable io_uring if it would otherwise be used. Signed-off-by: Rob Bradford --- vmm/src/config.rs | 13 ++++++++++++- vmm/src/device_manager.rs | 2 +- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/vmm/src/config.rs b/vmm/src/config.rs index a6c81e32d..22fbcf2cd 100644 --- a/vmm/src/config.rs +++ b/vmm/src/config.rs @@ -622,6 +622,9 @@ pub struct DiskConfig { pub poll_queue: bool, #[serde(default)] pub id: Option, + // For testing use only. Not exposed in API. + #[serde(default)] + pub disable_io_uring: bool, } fn default_diskconfig_num_queues() -> usize { @@ -649,6 +652,7 @@ impl Default for DiskConfig { vhost_socket: None, poll_queue: default_diskconfig_poll_queue(), id: None, + disable_io_uring: false, } } } @@ -671,7 +675,8 @@ impl DiskConfig { .add("vhost_user") .add("socket") .add("poll_queue") - .add("id"); + .add("id") + .add("_disable_io_uring"); parser.parse(disk).map_err(Error::ParseDisk)?; let path = parser.get("path").map(PathBuf::from); @@ -710,6 +715,11 @@ impl DiskConfig { .unwrap_or_else(|| Toggle(default_diskconfig_poll_queue())) .0; let id = parser.get("id"); + let disable_io_uring = parser + .convert::("_disable_io_uring") + .map_err(Error::ParseDisk)? + .unwrap_or(Toggle(false)) + .0; if parser.is_set("poll_queue") && !vhost_user { warn!("poll_queue parameter currently only has effect when used vhost_user=true"); @@ -726,6 +736,7 @@ impl DiskConfig { vhost_user, poll_queue, id, + disable_io_uring, }) } } diff --git a/vmm/src/device_manager.rs b/vmm/src/device_manager.rs index 9bc366d5b..c18b83a6e 100644 --- a/vmm/src/device_manager.rs +++ b/vmm/src/device_manager.rs @@ -1642,7 +1642,7 @@ impl DeviceManager { ImageType::Raw => { // Use asynchronous backend relying on io_uring if the // syscalls are supported. - if block_io_uring_is_supported() { + if block_io_uring_is_supported() && !disk_cfg.disable_io_uring { let dev = Arc::new(Mutex::new( virtio_devices::BlockIoUring::new( id.clone(),