diff options
author | Jan Kiszka <jan.kiszka@siemens.com> | 2012-08-17 08:59:08 +0200 |
---|---|---|
committer | Marcelo Tosatti <mtosatti@redhat.com> | 2012-08-23 17:02:36 -0300 |
commit | 4144fe9d48c290b390b4e2cdda91fea73036813d (patch) | |
tree | c9a3937a0693fa2ede88051c656f2b0d86859d14 | |
parent | c0ded17f24b52edf74d30d1129e81c760821e9ae (diff) |
pci-assign: Gracefully handle missing in-kernel irqchip support
Inform the user properly when trying to register an IRQ-using device
without in-kernel irqchip enabled.
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
-rw-r--r-- | hw/kvm/pci-assign.c | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/hw/kvm/pci-assign.c b/hw/kvm/pci-assign.c index 4f5daf368..9cce02cbf 100644 --- a/hw/kvm/pci-assign.c +++ b/hw/kvm/pci-assign.c @@ -862,6 +862,16 @@ static int assign_device(AssignedDevice *dev) return r; } +static bool check_irqchip_in_kernel(void) +{ + if (kvm_irqchip_in_kernel()) { + return true; + } + error_report("pci-assign: error: requires KVM with in-kernel irqchip " + "enabled"); + return false; +} + static int assign_intx(AssignedDevice *dev) { AssignedIRQType new_type; @@ -875,6 +885,10 @@ static int assign_intx(AssignedDevice *dev) return 0; } + if (!check_irqchip_in_kernel()) { + return -ENOTSUP; + } + pci_device_set_intx_routing_notifier(&dev->dev, assigned_dev_update_irq_routing); @@ -1236,6 +1250,9 @@ static int assigned_device_pci_cap_init(PCIDevice *pci_dev) * MSI capability is the 1st capability in capability config */ pos = pci_find_cap_offset(pci_dev, PCI_CAP_ID_MSI, 0); if (pos != 0 && kvm_check_extension(kvm_state, KVM_CAP_ASSIGN_DEV_IRQ)) { + if (!check_irqchip_in_kernel()) { + return -ENOTSUP; + } dev->cap.available |= ASSIGNED_DEVICE_CAP_MSI; /* Only 32-bit/no-mask currently supported */ ret = pci_add_capability(pci_dev, PCI_CAP_ID_MSI, pos, 10); @@ -1262,6 +1279,9 @@ static int assigned_device_pci_cap_init(PCIDevice *pci_dev) int bar_nr; uint32_t msix_table_entry; + if (!check_irqchip_in_kernel()) { + return -ENOTSUP; + } dev->cap.available |= ASSIGNED_DEVICE_CAP_MSIX; ret = pci_add_capability(pci_dev, PCI_CAP_ID_MSIX, pos, 12); if (ret < 0) { |