Received: from eggs.gnu.org ([2001:4830:134:3::10]:59449) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bQLPP-0002YJ-29 for qemu-devel@nongnu.org; Thu, 21 Jul 2016 17:21:32 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bQLPJ-0007A6-PE for qemu-devel@nongnu.org; Thu, 21 Jul 2016 17:21:29 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:19920) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bQLPJ-00078y-GR for qemu-devel@nongnu.org; Thu, 21 Jul 2016 17:21:25 -0400 Received: from pps.filterd (m0098404.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.11/8.16.0.11) with SMTP id u6LLJQWS017194 for ; Thu, 21 Jul 2016 17:21:24 -0400 Received: from e34.co.us.ibm.com (e34.co.us.ibm.com [32.97.110.152]) by mx0a-001b2d01.pphosted.com with ESMTP id 24a8f0xv7n-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Thu, 21 Jul 2016 17:21:23 -0400 Received: from localhost by e34.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 21 Jul 2016 15:21:23 -0600 From: Greg Kurz Date: Thu, 21 Jul 2016 23:21:16 +0200 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <146913602256.26732.547184422534259409.stgit@bahia.lan> Subject: [Qemu-devel] [PATCH v4] virtio-pci: error out when both legacy and modern modes are disabled List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: "Michael S. Tsirkin" Cc: Cornelia Huck , Eric Blake , qemu-devel@nongnu.org, Marcel Apfelbaum From: Greg Kurz Without presuming if we got there because of a user mistake or some more subtle bug in the tooling, it really does not make sense to implement a non-functional device. Signed-off-by: Greg Kurz Reviewed-by: Marcel Apfelbaum Signed-off-by: Greg Kurz --- v4: - rephrased error message and provide a hint to the user - split string literals to stay below 80 characters - added Marcel's R-b tag --- hw/virtio/virtio-pci.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/hw/virtio/virtio-pci.c b/hw/virtio/virtio-pci.c index 755f9218b77d..72c4b392ffda 100644 --- a/hw/virtio/virtio-pci.c +++ b/hw/virtio/virtio-pci.c @@ -1842,6 +1842,14 @@ static void virtio_pci_dc_realize(DeviceState *qdev, Error **errp) VirtIOPCIProxy *proxy = VIRTIO_PCI(qdev); PCIDevice *pci_dev = &proxy->pci_dev; + if (!(virtio_pci_modern(proxy) || virtio_pci_legacy(proxy))) { + error_setg(errp, "device cannot work when both modern and legacy modes" + " are disabled"); + error_append_hint(errp, "Set either disable-modern or disable-legacy" + " to off\n"); + return; + } + if (!(proxy->flags & VIRTIO_PCI_FLAG_DISABLE_PCIE) && virtio_pci_modern(proxy)) { pci_dev->cap_present |= QEMU_PCI_CAP_EXPRESS;