mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2024-10-05 21:15:45 +00:00
vfio: Propagate the KVM routes setting error
This will trigger a logged error once we have an actual logger. Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
This commit is contained in:
parent
421b896ab7
commit
792cc27435
@ -478,7 +478,7 @@ impl VfioPciDevice {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn update_msi_interrupt_routes(&mut self, msi: &VfioMsi) {
|
fn update_msi_interrupt_routes(&mut self, msi: &VfioMsi) -> Result<()> {
|
||||||
let num_vectors = msi.cap.num_enabled_vectors();
|
let num_vectors = msi.cap.num_enabled_vectors();
|
||||||
for (idx, route) in self.interrupt_routes.iter_mut().enumerate() {
|
for (idx, route) in self.interrupt_routes.iter_mut().enumerate() {
|
||||||
// Mask the MSI vector if the amount of vectors supported by the
|
// Mask the MSI vector if the amount of vectors supported by the
|
||||||
@ -499,17 +499,17 @@ impl VfioPciDevice {
|
|||||||
// Check if we need to update KVM GSI mapping, based on the status of
|
// Check if we need to update KVM GSI mapping, based on the status of
|
||||||
// the "MSI Enable" bit.
|
// the "MSI Enable" bit.
|
||||||
if msi.cap.enabled() {
|
if msi.cap.enabled() {
|
||||||
if let Err(e) = self.set_kvm_routes() {
|
return self.set_kvm_routes();
|
||||||
warn!("Could not Set KVM routes: {}", e);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn read_msix_table(&mut self, offset: u64, data: &mut [u8]) {
|
fn read_msix_table(&mut self, offset: u64, data: &mut [u8]) {
|
||||||
self.interrupt.msix_read_table(offset, data);
|
self.interrupt.msix_read_table(offset, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn update_msix_table(&mut self, offset: u64, data: &[u8]) {
|
fn update_msix_table(&mut self, offset: u64, data: &[u8]) -> Result<()> {
|
||||||
self.interrupt.msix_write_table(offset, data);
|
self.interrupt.msix_write_table(offset, data);
|
||||||
|
|
||||||
if self.interrupt.msix_enabled() && !self.interrupt.msix_function_masked() {
|
if self.interrupt.msix_enabled() && !self.interrupt.msix_function_masked() {
|
||||||
@ -523,13 +523,13 @@ impl VfioPciDevice {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Err(e) = self.set_kvm_routes() {
|
return self.set_kvm_routes();
|
||||||
warn!("Could not Set KVM routes: {}", e);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn update_msi_capabilities(&mut self, offset: u64, data: &[u8]) {
|
fn update_msi_capabilities(&mut self, offset: u64, data: &[u8]) -> Result<()> {
|
||||||
match self.interrupt.update_msi(offset, data) {
|
match self.interrupt.update_msi(offset, data) {
|
||||||
Some(InterruptUpdateAction::EnableMsi) => match self.irq_fds() {
|
Some(InterruptUpdateAction::EnableMsi) => match self.irq_fds() {
|
||||||
Ok(fds) => {
|
Ok(fds) => {
|
||||||
@ -552,8 +552,10 @@ impl VfioPciDevice {
|
|||||||
// changes to the cache, and based on the state of masking flags, the
|
// changes to the cache, and based on the state of masking flags, the
|
||||||
// KVM GSI routes should be configured.
|
// KVM GSI routes should be configured.
|
||||||
if let Some(msi) = self.interrupt.msi {
|
if let Some(msi) = self.interrupt.msi {
|
||||||
self.update_msi_interrupt_routes(&msi);
|
return self.update_msi_interrupt_routes(&msi);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn update_msix_capabilities(&mut self, offset: u64, data: &[u8]) {
|
fn update_msix_capabilities(&mut self, offset: u64, data: &[u8]) {
|
||||||
@ -881,7 +883,9 @@ impl PciDevice for VfioPciDevice {
|
|||||||
let cap_offset: u64 = reg - cap_base + offset;
|
let cap_offset: u64 = reg - cap_base + offset;
|
||||||
match cap_id {
|
match cap_id {
|
||||||
PciCapabilityID::MessageSignalledInterrupts => {
|
PciCapabilityID::MessageSignalledInterrupts => {
|
||||||
self.update_msi_capabilities(cap_offset, data);
|
if let Err(e) = self.update_msi_capabilities(cap_offset, data) {
|
||||||
|
error!("Could not update MSI capabilities: {}", e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
PciCapabilityID::MSIX => {
|
PciCapabilityID::MSIX => {
|
||||||
self.update_msix_capabilities(cap_offset, data);
|
self.update_msix_capabilities(cap_offset, data);
|
||||||
@ -943,7 +947,9 @@ impl PciDevice for VfioPciDevice {
|
|||||||
|
|
||||||
// If the MSI-X table is written to, we need to update our cache.
|
// If the MSI-X table is written to, we need to update our cache.
|
||||||
if self.interrupt.msix_table_accessed(region.index, offset) {
|
if self.interrupt.msix_table_accessed(region.index, offset) {
|
||||||
self.update_msix_table(offset, data);
|
if let Err(e) = self.update_msix_table(offset, data) {
|
||||||
|
error!("Could not update MSI-X table: {}", e);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
self.device.region_write(region.index, data, offset);
|
self.device.region_write(region.index, data, offset);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user