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 <robert.bradford@intel.com>
This commit is contained in:
Rob Bradford 2020-11-17 17:11:53 +00:00 committed by Samuel Ortiz
parent d1d0421103
commit c622278030
2 changed files with 13 additions and 2 deletions

View File

@ -622,6 +622,9 @@ pub struct DiskConfig {
pub poll_queue: bool,
#[serde(default)]
pub id: Option<String>,
// 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::<Toggle>("_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,
})
}
}

View File

@ -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(),