virtio-devices: Support driver programming fewer queues

It is permissable for the driver to program fewer queues than offered by
the device. Filter the queues so that only the ready ones are included
and check that they have valid addresses configured.

Fixes: #2136

Signed-off-by: Rob Bradford <robert.bradford@intel.com>
This commit is contained in:
Rob Bradford
2021-01-18 17:52:45 +00:00
committed by Sebastien Boeuf
parent c366efc19e
commit a105089702
2 changed files with 34 additions and 56 deletions
+3 -3
View File
@@ -250,10 +250,10 @@ impl VirtioCommon {
queue_evts: &[EventFd],
interrupt_cb: &Arc<dyn VirtioInterrupt>,
) -> ActivateResult {
if queues.len() != self.queue_sizes.len() || queue_evts.len() != self.queue_sizes.len() {
if queues.len() != queue_evts.len() {
error!(
"Cannot perform activate. Expected {} queue(s), got {}",
self.queue_sizes.len(),
"Cannot activate: length mismatch: queue_evts={} queues={}",
queue_evts.len(),
queues.len()
);
return Err(ActivateError::BadActivate);