From patchwork Thu Aug 16 13:54:33 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Kiszka X-Patchwork-Id: 1332121 Return-Path: X-Original-To: patchwork-kvm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id 024B440210 for ; Thu, 16 Aug 2012 13:54:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757236Ab2HPNyo (ORCPT ); Thu, 16 Aug 2012 09:54:44 -0400 Received: from thoth.sbs.de ([192.35.17.2]:30066 "EHLO thoth.sbs.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756959Ab2HPNyk (ORCPT ); Thu, 16 Aug 2012 09:54:40 -0400 Received: from mail1.siemens.de (localhost [127.0.0.1]) by thoth.sbs.de (8.13.6/8.13.6) with ESMTP id q7GDsZE6008168; Thu, 16 Aug 2012 15:54:35 +0200 Received: from mchn199C.mchp.siemens.de ([139.25.109.49]) by mail1.siemens.de (8.13.6/8.13.6) with ESMTP id q7GDsYJT012893; Thu, 16 Aug 2012 15:54:35 +0200 From: Jan Kiszka To: Avi Kivity , Marcelo Tosatti Cc: kvm@vger.kernel.org, Alex Williamson Subject: [PATCH 19/19] pci-assign: Gracefully handle missing in-kernel irqchip support Date: Thu, 16 Aug 2012 15:54:33 +0200 Message-Id: X-Mailer: git-send-email 1.7.3.4 In-Reply-To: References: In-Reply-To: References: Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org Inform the user properly when trying to register an IRQ-using device without in-kernel irqchip enabled. Signed-off-by: Jan Kiszka --- 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 4f5daf3..9cce02c 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) {