mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2024-08-22 07:51:16 +00:00
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:
parent
a105089702
commit
c90f77e399
@ -332,6 +332,7 @@ impl Balloon {
|
|||||||
avail_features,
|
avail_features,
|
||||||
paused_sync: Some(Arc::new(Barrier::new(2))),
|
paused_sync: Some(Arc::new(Barrier::new(2))),
|
||||||
queue_sizes: QUEUE_SIZES.to_vec(),
|
queue_sizes: QUEUE_SIZES.to_vec(),
|
||||||
|
min_queues: NUM_QUEUES as u16,
|
||||||
..Default::default()
|
..Default::default()
|
||||||
},
|
},
|
||||||
id,
|
id,
|
||||||
|
@ -337,6 +337,7 @@ impl<T: DiskFile> Block<T> {
|
|||||||
avail_features,
|
avail_features,
|
||||||
paused_sync: Some(Arc::new(Barrier::new(num_queues + 1))),
|
paused_sync: Some(Arc::new(Barrier::new(num_queues + 1))),
|
||||||
queue_sizes: vec![queue_size; num_queues],
|
queue_sizes: vec![queue_size; num_queues],
|
||||||
|
min_queues: 1,
|
||||||
..Default::default()
|
..Default::default()
|
||||||
},
|
},
|
||||||
id,
|
id,
|
||||||
|
@ -378,6 +378,7 @@ impl BlockIoUring {
|
|||||||
avail_features,
|
avail_features,
|
||||||
paused_sync: Some(Arc::new(Barrier::new(num_queues + 1))),
|
paused_sync: Some(Arc::new(Barrier::new(num_queues + 1))),
|
||||||
queue_sizes: vec![queue_size; num_queues],
|
queue_sizes: vec![queue_size; num_queues],
|
||||||
|
min_queues: 1,
|
||||||
..Default::default()
|
..Default::default()
|
||||||
},
|
},
|
||||||
id,
|
id,
|
||||||
|
@ -348,6 +348,7 @@ impl Console {
|
|||||||
queue_sizes: QUEUE_SIZES.to_vec(),
|
queue_sizes: QUEUE_SIZES.to_vec(),
|
||||||
avail_features,
|
avail_features,
|
||||||
paused_sync: Some(Arc::new(Barrier::new(2))),
|
paused_sync: Some(Arc::new(Barrier::new(2))),
|
||||||
|
min_queues: NUM_QUEUES as u16,
|
||||||
..Default::default()
|
..Default::default()
|
||||||
},
|
},
|
||||||
id,
|
id,
|
||||||
|
@ -224,6 +224,7 @@ pub struct VirtioCommon {
|
|||||||
pub epoll_threads: Option<Vec<thread::JoinHandle<()>>>,
|
pub epoll_threads: Option<Vec<thread::JoinHandle<()>>>,
|
||||||
pub queue_sizes: Vec<u16>,
|
pub queue_sizes: Vec<u16>,
|
||||||
pub device_type: u32,
|
pub device_type: u32,
|
||||||
|
pub min_queues: u16,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl VirtioCommon {
|
impl VirtioCommon {
|
||||||
@ -259,6 +260,15 @@ impl VirtioCommon {
|
|||||||
return Err(ActivateError::BadActivate);
|
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| {
|
let kill_evt = EventFd::new(EFD_NONBLOCK).map_err(|e| {
|
||||||
error!("failed creating kill EventFd: {}", e);
|
error!("failed creating kill EventFd: {}", e);
|
||||||
ActivateError::BadActivate
|
ActivateError::BadActivate
|
||||||
|
@ -764,6 +764,7 @@ impl Mem {
|
|||||||
avail_features,
|
avail_features,
|
||||||
paused_sync: Some(Arc::new(Barrier::new(2))),
|
paused_sync: Some(Arc::new(Barrier::new(2))),
|
||||||
queue_sizes: QUEUE_SIZES.to_vec(),
|
queue_sizes: QUEUE_SIZES.to_vec(),
|
||||||
|
min_queues: 1,
|
||||||
..Default::default()
|
..Default::default()
|
||||||
},
|
},
|
||||||
id,
|
id,
|
||||||
|
@ -256,6 +256,7 @@ impl Net {
|
|||||||
avail_features,
|
avail_features,
|
||||||
queue_sizes: vec![queue_size; queue_num],
|
queue_sizes: vec![queue_size; queue_num],
|
||||||
paused_sync: Some(Arc::new(Barrier::new((num_queues / 2) + 1))),
|
paused_sync: Some(Arc::new(Barrier::new((num_queues / 2) + 1))),
|
||||||
|
min_queues: 2,
|
||||||
..Default::default()
|
..Default::default()
|
||||||
},
|
},
|
||||||
id,
|
id,
|
||||||
|
@ -304,6 +304,7 @@ impl Pmem {
|
|||||||
queue_sizes: QUEUE_SIZES.to_vec(),
|
queue_sizes: QUEUE_SIZES.to_vec(),
|
||||||
paused_sync: Some(Arc::new(Barrier::new(2))),
|
paused_sync: Some(Arc::new(Barrier::new(2))),
|
||||||
avail_features,
|
avail_features,
|
||||||
|
min_queues: 1,
|
||||||
..Default::default()
|
..Default::default()
|
||||||
},
|
},
|
||||||
id,
|
id,
|
||||||
|
@ -158,6 +158,7 @@ impl Rng {
|
|||||||
queue_sizes: QUEUE_SIZES.to_vec(),
|
queue_sizes: QUEUE_SIZES.to_vec(),
|
||||||
paused_sync: Some(Arc::new(Barrier::new(2))),
|
paused_sync: Some(Arc::new(Barrier::new(2))),
|
||||||
avail_features,
|
avail_features,
|
||||||
|
min_queues: 1,
|
||||||
..Default::default()
|
..Default::default()
|
||||||
},
|
},
|
||||||
id,
|
id,
|
||||||
|
@ -135,6 +135,7 @@ impl Blk {
|
|||||||
avail_features,
|
avail_features,
|
||||||
acked_features,
|
acked_features,
|
||||||
paused_sync: Some(Arc::new(Barrier::new(vu_cfg.num_queues + 1))),
|
paused_sync: Some(Arc::new(Barrier::new(vu_cfg.num_queues + 1))),
|
||||||
|
min_queues: 1,
|
||||||
..Default::default()
|
..Default::default()
|
||||||
},
|
},
|
||||||
id,
|
id,
|
||||||
|
@ -352,6 +352,7 @@ impl Fs {
|
|||||||
acked_features,
|
acked_features,
|
||||||
queue_sizes: vec![queue_size; num_queues],
|
queue_sizes: vec![queue_size; num_queues],
|
||||||
paused_sync: Some(Arc::new(Barrier::new(2))),
|
paused_sync: Some(Arc::new(Barrier::new(2))),
|
||||||
|
min_queues: NUM_QUEUE_OFFSET as u16,
|
||||||
..Default::default()
|
..Default::default()
|
||||||
},
|
},
|
||||||
id,
|
id,
|
||||||
|
@ -144,6 +144,7 @@ impl Net {
|
|||||||
avail_features,
|
avail_features,
|
||||||
acked_features,
|
acked_features,
|
||||||
paused_sync: Some(Arc::new(Barrier::new((vu_cfg.num_queues / 2) + 1))),
|
paused_sync: Some(Arc::new(Barrier::new((vu_cfg.num_queues / 2) + 1))),
|
||||||
|
min_queues: 2,
|
||||||
..Default::default()
|
..Default::default()
|
||||||
},
|
},
|
||||||
vhost_user_net,
|
vhost_user_net,
|
||||||
|
@ -337,6 +337,7 @@ where
|
|||||||
avail_features,
|
avail_features,
|
||||||
paused_sync: Some(Arc::new(Barrier::new(2))),
|
paused_sync: Some(Arc::new(Barrier::new(2))),
|
||||||
queue_sizes: QUEUE_SIZES.to_vec(),
|
queue_sizes: QUEUE_SIZES.to_vec(),
|
||||||
|
min_queues: NUM_QUEUES as u16,
|
||||||
..Default::default()
|
..Default::default()
|
||||||
},
|
},
|
||||||
id,
|
id,
|
||||||
|
@ -193,6 +193,7 @@ impl Watchdog {
|
|||||||
queue_sizes: QUEUE_SIZES.to_vec(),
|
queue_sizes: QUEUE_SIZES.to_vec(),
|
||||||
paused_sync: Some(Arc::new(Barrier::new(2))),
|
paused_sync: Some(Arc::new(Barrier::new(2))),
|
||||||
avail_features,
|
avail_features,
|
||||||
|
min_queues: 1,
|
||||||
..Default::default()
|
..Default::default()
|
||||||
},
|
},
|
||||||
id,
|
id,
|
||||||
|
Loading…
Reference in New Issue
Block a user