virtio-devices: Enforce a minimum number of queues

Even though the driver can provide fewer queues than those advertised
for some device types their is a minimum number that is required for
operation.

Signed-off-by: Rob Bradford <robert.bradford@intel.com>
This commit is contained in:
Rob Bradford
2021-01-19 06:11:07 +00:00
committed by Sebastien Boeuf
parent a105089702
commit c90f77e399
14 changed files with 23 additions and 0 deletions
+10
View File
@@ -224,6 +224,7 @@ pub struct VirtioCommon {
pub epoll_threads: Option<Vec<thread::JoinHandle<()>>>,
pub queue_sizes: Vec<u16>,
pub device_type: u32,
pub min_queues: u16,
}
impl VirtioCommon {
@@ -259,6 +260,15 @@ impl VirtioCommon {
return Err(ActivateError::BadActivate);
}
if queues.len() < self.min_queues.into() {
error!(
"Number of enabled queues lower tham min: {} vs {}",
queues.len(),
self.min_queues
);
return Err(ActivateError::BadActivate);
}
let kill_evt = EventFd::new(EFD_NONBLOCK).map_err(|e| {
error!("failed creating kill EventFd: {}", e);
ActivateError::BadActivate